/* Basic Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #1A1B1E;
    color: #E9ECEF;
    line-height: 1.6;
    /* Fix mobile viewport issues */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    width: 100%;
}

.app-header {
    width: 100%;
    padding: 20px;
    text-align: center;
    background-color: #1A1B1E;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.8em;
    margin-bottom: 0.25em;
}

.app-header p {
    font-size: 0.9em;
    color: #A0AEC0;
}

.sticky-toolbar-wrapper {
    width: 100%;
    background-color: #25262B;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    /* CRITICAL: Allow overflow for dropdowns */
    overflow: visible !important;
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 10px;
    width: 100%;
    max-width: 800px;
    justify-content: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.controls button {
    font-family: 'Inter', sans-serif;
    background-color: #3B3C40;
    color: #E9ECEF;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap; /* Prevent button text wrapping */
    /* Ensure buttons are touchable on mobile */
    min-height: 44px;
    min-width: 44px;
}

.controls button:hover {
    background-color: #4A4B50;
}

.app-card {
    background-color: #25262B;
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
    margin-bottom: 50px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    /* REMOVED FLEXBOX PROPERTIES */
}

/* Auth Form Styling */
#login-form {
    display: flex;
    flex-wrap: nowrap; /* Keep all items on one line */
    gap: 0.3rem; /* Reduced gap for tighter packing */
    align-items: center;
    padding: 0.5rem; /* Reduced padding */
    justify-content: flex-start; /* Align items to the start */
    overflow-x: auto; /* Allow horizontal scrolling if needed on very small screens */
}

#login-form input[type="email"],
#login-form input[type="password"] {
    font-family: 'Inter', sans-serif;
    background-color: #3B3C40;
    color: #E9ECEF;
    border: 1px solid #4A4B50;
    padding: 5px 8px; /* Further reduced padding */
    border-radius: 3px; /* Slightly smaller border radius */
    font-size: 0.8em; /* Further reduced font size */
    flex-grow: 1; /* Allow inputs to grow */
    min-width: 120px; /* Adjust min-width as needed */
    height: 32px; /* Set a fixed height for alignment */
    box-sizing: border-box;
}

#login-form input[type="email"]::placeholder,
#login-form input[type="password"]::placeholder {
    color: #A0AEC0;
}

#login-form input[type="email"]:focus,
#login-form input[type="password"]:focus {
    outline: none;
    border-color: #5E87FF;
    box-shadow: 0 0 0 2px rgba(94, 135, 255, 0.3);
}

#login-form button {
    font-family: 'Inter', sans-serif;
    background-color: #3B3C40;
    color: #E9ECEF;
    border: none;
    padding: 5px 10px; /* Further reduced padding */
    border-radius: 3px; /* Slightly smaller border radius */
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.8em; /* Further reduced font size */
    white-space: nowrap;
    height: 32px; /* Set a fixed height for alignment */
    box-sizing: border-box;
    line-height: normal; /* Ensure text is centered vertically */
}

#login-form button:hover {
    background-color: #4A4B50;
}

#login-form button:active {
    background-color: #555;
}

#forgot-password-btn {
    background-color: #555;
    margin-left: 0.3rem; /* Keep a small margin if needed */
}

#forgot-password-btn:hover {
    background-color: #666;
}

/* Ensure the auth section itself doesn't have conflicting padding */
#auth-section {
    padding: 0.5rem; /* Adjust as needed */
}


#editor {
    background-color: #2E2E33;
    color: #E9ECEF;
    font-family: 'Fira Code', monospace;
    min-height: calc(93vh - 250px);
    height: auto;
    padding: 20px;
    border-radius: 0 0 8px 8px;
    outline: none;
    /* REMOVED FLEXBOX PROPERTIES */
}

/* When logo is hidden */
.logo-hidden .app-header {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

/* Quill Toolbar Customization */
.sticky-toolbar-wrapper .ql-toolbar {
    background-color: #2E2E33;
    border: none;
    border-radius: 4px;
    padding: 8px;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    /* CRITICAL: Remove overflow constraints that clip dropdowns */
    overflow: visible !important;
    position: relative;
}

/* CRITICAL: Fix for Quill dropdown positioning */
.ql-toolbar .ql-picker {
    position: relative;
}

.ql-toolbar .ql-picker-options {
    position: absolute !important;
    z-index: 1000 !important;
    top: 100% !important;
    left: 0 !important;
    background-color: #2E2E33 !important;
    border: 1px solid #4A4B50 !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    min-width: 120px !important;
}

.ql-toolbar .ql-picker-item {
    background-color: #2E2E33 !important;
    color: #E9ECEF !important;
    padding: 8px 12px !important;
    border: none !important;
}

.ql-toolbar .ql-picker-item:hover {
    background-color: #4A4B50 !important;
    color: #FFFFFF !important;
}

/* Style Quill icons for dark theme */
.ql-toolbar .ql-stroke {
    stroke: #A0AEC0;
}
.ql-toolbar .ql-fill {
    fill: #A0AEC0;
}
.ql-toolbar .ql-picker-label {
    color: #A0AEC0;
}
.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button:focus .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke {
    stroke: #E9ECEF;
}
.ql-toolbar button:hover .ql-fill,
.ql-toolbar button:focus .ql-fill,
.ql-toolbar button.ql-active .ql-fill {
    fill: #E9ECEF;
}
.ql-toolbar button:hover .ql-picker-label,
.ql-toolbar button:focus .ql-picker-label,
.ql-toolbar button.ql-active .ql-picker-label {
    color: #E9ECEF;
}

#editor .ql-container.ql-snow {
    border: none;
    font-family: inherit;
}

#editor .ql-editor {
    padding: 0;
    font-size: 1rem;
    line-height: 1.6;
    width: 100%;
    min-height: 50vh;
    padding-bottom: 50px;
    /* Ensure proper text rendering on mobile */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Style Quill placeholder text for dark theme */
#editor .ql-editor.ql-blank::before {
    color: #A0AEC0;
    font-style: normal;
}

.sticky-toolbar-wrapper .controls {
    width: 100%;
    max-width: 800px;
    justify-content: center;
}

/* Mobile-specific fixes */
@media (max-width: 768px) {
    .sticky-toolbar-wrapper {
        padding: 10px;
        /* CRITICAL: Maintain overflow visible on mobile */
        overflow: visible !important;
    }

    .controls {
        flex-direction: row; /* Keep horizontal on tablets */
        flex-wrap: wrap;
        gap: 8px;
        padding: 0;
        justify-content: center;
    }

    .controls button {
        flex: 1;
        min-width: 80px;
        max-width: 150px;
        font-size: 0.9em;
    }

    .app-card {
        margin: 10px;
        border-radius: 8px;
    }

    #editor {
        min-height: 60vh;
        padding: 15px;
    }

    /* Fix Quill toolbar on mobile */
    .sticky-toolbar-wrapper .ql-toolbar {
        padding: 6px;
        /* CRITICAL: No white-space nowrap that can cause issues */
        overflow: visible !important;
    }

    .ql-toolbar .ql-formats {
        margin-right: 8px;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.4em;
    }
    .app-header p {
        font-size: 0.8em;
    }

    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .controls button {
        flex: 1;
        min-width: 70px;
        max-width: calc(50% - 4px);
        margin-bottom: 0;
        font-size: 0.85em;
        padding: 8px 6px;
    }

    #editor {
        min-height: 50vh;
        padding: 12px;
        font-size: 0.95rem;
    }

    /* Ensure toolbar buttons are accessible on small screens */
    .ql-toolbar button {
        min-width: 32px;
        min-height: 32px;
    }

    /* Fix any remaining text direction issues */
    .ql-editor p,
    .ql-editor div,
    .ql-editor span {
        direction: ltr;
        writing-mode: horizontal-tb;
    }
}