/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #ffffff;
    --bg-secondary: #f8fafc;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 6px;
    --transition: all 0.15s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-color: #e5e5e5;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-secondary);
    color: var(--text-color);
    line-height: 1.6;
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================
   Main Container
   ============================================ */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    width: 100%;
    height: calc(100vh - 56px);
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    flex: 1;
    min-width: 0;
}

.toolbar::-webkit-scrollbar {
    height: 4px;
}

.toolbar::-webkit-scrollbar-track {
    background: transparent;
}

.toolbar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.toolbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* File Menu Dropdown */
.file-menu-wrapper {
    position: relative;
    z-index: 1001;
}

.file-menu-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: var(--transition);
    font-family: var(--font-family);
    white-space: nowrap;
    flex-shrink: 0;
}

.file-menu-btn:hover {
    background: var(--bg-secondary);
}

.file-menu-btn .dropdown-arrow {
    font-size: 0.7rem;
    transition: var(--transition);
}

.file-menu-wrapper.active .dropdown-arrow {
    transform: rotate(180deg);
}

.file-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    display: none;
    z-index: 1002;
    overflow: hidden;
}

.file-menu-wrapper.active .file-dropdown {
    display: block;
}

.dropdown-item {
    width: 100%;
    background: none;
    border: none;
    padding: 0.625rem 1rem;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
    transition: var(--transition);
    font-family: var(--font-family);
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
    flex-shrink: 0;
}

.toolbar-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: var(--transition);
    font-family: var(--font-family);
    white-space: nowrap;
    flex-shrink: 0;
}

.toolbar-btn:hover {
    background: var(--bg-secondary);
}

.toolbar-btn:active {
    transform: scale(0.98);
}

.toolbar-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.toolbar-select:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.quill-toolbar {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
}

/* ============================================
   Editor
   ============================================ */
.editor-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: var(--bg-color);
}

.editor-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.editor-wrapper-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
}

#editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#editor .ql-container {
    border: none;
    font-family: var(--font-family);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#editor .ql-editor {
    flex: 1;
    padding: 1.5rem 1.5rem;
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-color);
    background: var(--bg-color);
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

#editor .ql-editor.ql-blank::before {
    color: var(--text-secondary);
    font-style: normal;
    left: 1.5rem;
}

#editor .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    display: none;
}

#editor .ql-toolbar .ql-stroke {
    stroke: var(--text-color);
}

#editor .ql-toolbar .ql-fill {
    fill: var(--text-color);
}

#editor .ql-toolbar button:hover,
#editor .ql-toolbar button.ql-active {
    color: var(--primary-color);
}

#editor .ql-toolbar button:hover .ql-stroke,
#editor .ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--primary-color);
}

#editor .ql-toolbar button:hover .ql-fill,
#editor .ql-toolbar button.ql-active .ql-fill {
    fill: var(--primary-color);
}

.editor-footer {
    padding: 0.75rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    display: flex;
    justify-content: flex-end;
}

.stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Fullscreen Mode */
body.fullscreen {
    overflow: hidden;
}

body.fullscreen .main-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    margin: 0;
    max-width: 100%;
    height: 100vh;
}

body.fullscreen .header {
    display: none;
}

body.fullscreen .header {
    display: none;
}

body.fullscreen .main-container {
    height: 100vh;
}

body.fullscreen .editor-wrapper-inner {
    border-radius: 0;
}

body.fullscreen #editor .ql-editor {
    max-width: 100%;
    padding: 1.5rem 1.5rem;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: var(--font-family);
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .header-content {
        padding: 0.625rem 1rem;
        flex-wrap: wrap;
    }

    .logo {
        font-size: 1rem;
    }

    .main-container {
        height: calc(100vh - 52px);
    }

    .toolbar {
        width: 100%;
        order: 2;
        margin-top: 0.5rem;
        padding: 0.25rem 0;
        gap: 0.25rem;
    }

    .toolbar-btn {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    .toolbar-select {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    #editor .ql-editor {
        padding: 1rem 1rem;
    }

    #editor .ql-editor.ql-blank::before {
        left: 1rem;
    }

    .editor-footer {
        padding: 0.5rem 1rem;
    }

    .stats {
        font-size: 0.6875rem;
        gap: 1rem;
    }

    .file-dropdown {
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0.5rem 0.75rem;
    }

    .logo {
        font-size: 0.9375rem;
    }

    .toolbar {
        padding: 0.25rem 0;
    }

    .toolbar-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    #editor .ql-editor {
        padding: 1rem 0.75rem;
    }

    #editor .ql-editor.ql-blank::before {
        left: 0.75rem;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .header,
    .toolbar,
    .editor-footer {
        display: none !important;
    }

    .main-container {
        height: auto;
    }

    .editor-wrapper-inner {
        border: none;
    }

    #editor .ql-editor {
        padding: 1rem;
        max-width: 100%;
    }
}
