/* ========================================
   IELTS HUB — Design System & Global Styles
   ======================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Color Palette — Deep Space Theme */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(255, 255, 255, 0.05);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(99, 102, 241, 0.4);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-secondary: #8b5cf6;
    --accent-gold: #f59e0b;
    --accent-gold-soft: rgba(245, 158, 11, 0.15);

    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                   radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
                   radial-gradient(ellipse at 50% 80%, rgba(245, 158, 11, 0.04) 0%, transparent 50%);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 260px;
    --header-height: 64px;

    --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--gradient-bg);
    pointer-events: none;
    z-index: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* ---------- App Layout ---------- */
#app {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    transition: transform var(--transition-slow);
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
}

.nav-item:hover:not(.disabled) {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary-hover);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--gradient-primary);
    border-radius: 0 3px 3px 0;
}

.nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.badge-soon {
    margin-left: auto;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-gold);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.main-content.full-width {
    margin-left: 0;
}

/* ---------- Page Container ---------- */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 40px;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header h1 i {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-accent);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* ---------- Search Bar ---------- */
.search-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-base);
    outline: none;
}

.search-bar input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(255, 255, 255, 0.07);
}

.search-bar input::placeholder {
    color: var(--text-tertiary);
}

.search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-card);
    opacity: 0;
    transition: opacity var(--transition-base);
    pointer-events: none;
}

.card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.card:hover::before {
    opacity: 1;
}

.card-clickable {
    cursor: pointer;
}

/* ---------- Document Card ---------- */
.doc-card {
    position: relative;
}

.doc-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.doc-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    flex: 1;
    margin-right: 12px;
}

.doc-card-visibility {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.visibility-private {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-tertiary);
}

.visibility-team {
    background: var(--accent-gold-soft);
    color: var(--accent-gold);
}

.doc-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.doc-card-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.doc-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ---------- Tags ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.tag-system {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary-hover);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.tag-custom {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.tag-clickable {
    cursor: pointer;
}

.tag-clickable:hover {
    transform: scale(1.05);
}

.tag-removable .tag-remove {
    cursor: pointer;
    margin-left: 2px;
    opacity: 0.6;
}

.tag-removable .tag-remove:hover {
    opacity: 1;
}

/* ---------- Tab Navigation ---------- */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    overflow-x: auto;
    margin-bottom: 24px;
}

.tab {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    white-space: nowrap;
    cursor: pointer;
    text-align: center;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-glass-hover);
}

.tab.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary-hover);
    font-weight: 600;
}

/* ---------- Document Grid ---------- */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

/* ---------- Auth Pages ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.5s ease;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 40px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .auth-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    margin: 0 auto 16px;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

.auth-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ---------- Form Elements ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-base);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(255, 255, 255, 0.07);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-base);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* ---------- Auth Link ---------- */
.auth-link {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--accent-primary-hover);
    font-weight: 600;
    transition: color var(--transition-fast);
}

.auth-link a:hover {
    color: #a78bfa;
}

/* ---------- Alert / Toast ---------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

.toast-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.toast-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.toast-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--info);
}

.toast-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

/* ---------- Section Badges ---------- */
.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent-primary-hover);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 15px;
    margin-bottom: 20px;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* ---------- Document View Page ---------- */
.doc-view-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.doc-view-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.3;
}

.doc-view-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.doc-view-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.doc-view-meta-item i {
    color: var(--text-tertiary);
}

.doc-view-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.doc-view-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
}

.doc-view-content h1,
.doc-view-content h2,
.doc-view-content h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
}

.doc-view-content p {
    margin-bottom: 12px;
}

.doc-view-content img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 16px 0;
}

.doc-view-content a {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

.doc-view-content blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
}

.doc-view-content code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.doc-view-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 16px 0;
}

.doc-view-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* ---------- Document Edit Page ---------- */
.edit-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 0px);
}

.edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(10px);
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.edit-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.edit-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.edit-title-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    outline: none;
    flex: 1;
    min-width: 200px;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: border-color var(--transition-base);
}

.edit-title-input:focus {
    border-bottom-color: var(--accent-primary);
}

.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--bg-glass);
}

.save-status.saving {
    color: var(--warning);
}

.save-status.saved {
    color: var(--success);
}

.save-status.error {
    color: var(--danger);
}

.online-users {
    display: flex;
    align-items: center;
    gap: -4px;
}

.online-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    border: 2px solid var(--bg-primary);
    margin-left: -6px;
    position: relative;
    cursor: default;
}

.online-user-avatar:first-child {
    margin-left: 0;
}

.online-user-avatar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-primary);
}

.edit-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.edit-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.edit-sidebar {
    width: 280px;
    border-left: 1px solid var(--border-subtle);
    padding: 20px;
    overflow-y: auto;
    background: rgba(10, 14, 26, 0.5);
    flex-shrink: 0;
}

.edit-sidebar h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.edit-sidebar .form-group {
    margin-bottom: 20px;
}

/* ---------- Quill Editor Overrides ---------- */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    background: rgba(10, 14, 26, 0.5);
    padding: 8px 16px !important;
}

.ql-container.ql-snow {
    border: none !important;
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-sans);
}

.ql-editor {
    padding: 32px 48px !important;
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    min-height: 100%;
}

.ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
    left: 48px !important;
    top: 32px !important;
    right: 48px !important;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.ql-editor.ql-blank:focus::before {
    display: none !important;
}

.ql-snow .ql-stroke {
    stroke: var(--text-secondary) !important;
}

.ql-snow .ql-fill {
    fill: var(--text-secondary) !important;
}

.ql-snow .ql-picker {
    color: var(--text-secondary) !important;
}

.ql-snow .ql-picker-options {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-medium) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
}

.ql-snow .ql-active .ql-stroke {
    stroke: var(--accent-primary-hover) !important;
}

.ql-snow .ql-active .ql-fill {
    fill: var(--accent-primary-hover) !important;
}

.ql-snow .ql-active {
    color: var(--accent-primary-hover) !important;
}

.ql-snow button:hover .ql-stroke {
    stroke: var(--text-primary) !important;
}

.ql-snow button:hover .ql-fill {
    fill: var(--text-primary) !important;
}

.ql-editor img {
    max-width: 100%;
    border-radius: var(--radius-md);
}

/* ---------- Tag Input Component ---------- */
.tag-input-container {
    position: relative;
}

.tag-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-height: 42px;
    align-items: center;
    transition: all var(--transition-base);
    cursor: text;
}

.tag-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.tag-input-wrapper .tag {
    font-size: 11px;
}

.tag-input-field {
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
    min-width: 80px;
    padding: 2px 0;
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.tag-suggestions.visible {
    display: block;
    animation: slideDown 0.2s ease;
}

.tag-suggestion-item {
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-suggestion-item:hover {
    background: var(--bg-glass-hover);
}

.tag-suggestion-item .tag-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary-hover);
}

/* ---------- Filter Bar ---------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-tag {
    cursor: pointer;
}

.filter-tag.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--accent-primary);
}

/* ---------- Stats Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(10px);
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---------- Section Title ---------- */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title i {
    color: var(--accent-primary-hover);
    font-size: 16px;
}

/* ---------- Loading ---------- */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Visibility Toggle ---------- */
.visibility-toggle {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.visibility-option {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-tertiary);
}

.visibility-option.active {
    background: var(--accent-primary);
    color: white;
}

/* ---------- Back Button ---------- */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 0;
    margin-bottom: 16px;
    transition: color var(--transition-fast);
}

.btn-back:hover {
    color: var(--text-primary);
}

/* ---------- Confirm Dialog ---------- */
.confirm-message {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: 0;
    }
    .page-container {
        padding: 20px 16px;
    }
    .doc-grid {
        grid-template-columns: 1fr;
    }
    .edit-sidebar {
        display: none;
    }
    .edit-toolbar {
        padding: 8px 12px;
    }
}

/* ---------- Stagger Animation ---------- */
.stagger-item {
    animation: fadeInUp 0.4s ease both;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.4s; }
.stagger-item:nth-child(9) { animation-delay: 0.45s; }
.stagger-item:nth-child(10) { animation-delay: 0.5s; }

/* ---------- Tooltip ---------- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 100;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ---------- Creator New Doc Modal ---------- */
.new-doc-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.section-option {
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.section-option:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.section-option.selected {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary-hover);
}

/* ---------- Search Results ---------- */
.search-results-header {
    margin-bottom: 24px;
}

.search-results-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.search-results-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.highlight {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-gold);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ---------- Theme Transition & Variables ---------- */
* {
    transition: background-color var(--transition-base),
                border-color var(--transition-base);
}

body[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: rgba(241, 245, 249, 0.9);
    --bg-glass: rgba(0, 0, 0, 0.02);
    --bg-glass-hover: rgba(0, 0, 0, 0.04);
    --bg-input: rgba(0, 0, 0, 0.03);

    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
    --border-accent: rgba(99, 102, 241, 0.3);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;

    --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.02) 100%);
    --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
                   radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
                   radial-gradient(ellipse at 50% 80%, rgba(245, 158, 11, 0.02) 0%, transparent 50%);

    --shadow-sm: 0 1px 3px 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);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* User Avatar Image */
.user-avatar {
    background-size: cover;
    background-position: center;
    background-color: var(--accent-primary);
}

/* Team Square Styles */
.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}
.team-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.team-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 12px 0;
    line-height: 1.5;
}
.team-stats {
    display: flex;
    gap: 16px;
    color: var(--text-tertiary);
    font-size: 13px;
    margin-bottom: 16px;
}
.team-status-badge {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}
.status-approved, .status-creator, .status-admin { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.status-rejected { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ---------- Unified Action Buttons (Issue #6) ---------- */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.btn-action-approve {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}
.btn-action-approve:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

.btn-action-reject {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}
.btn-action-reject:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn-action-remove {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}
.btn-action-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

/* ---------- Team Member Row ---------- */
.team-member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}

.team-member-row:last-child {
    border-bottom: none;
}

.team-action-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ---------- Notification Items ---------- */
.notification-item {
    padding: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.notification-unread {
    background: var(--bg-card);
    border-left: 3px solid var(--accent-primary);
}

/* ---------- Sidebar Light Theme (Issue #8) ---------- */
body[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .sidebar-brand {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .nav-item {
    color: var(--text-secondary);
}

body[data-theme="light"] .nav-item:hover:not(.disabled) {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

body[data-theme="light"] .nav-item.active {
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent-primary);
}

body[data-theme="light"] .sidebar-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .btn-logout:hover {
    background: rgba(239, 68, 68, 0.08);
}

body[data-theme="light"] .btn-ghost {
    color: var(--text-secondary);
}

body[data-theme="light"] .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

body[data-theme="light"] .user-name {
    color: var(--text-primary);
}

/* Quill editor light theme */
body[data-theme="light"] .ql-toolbar.ql-snow {
    background: rgba(248, 250, 252, 0.8);
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .ql-snow .ql-stroke {
    stroke: var(--text-secondary) !important;
}

body[data-theme="light"] .ql-snow .ql-fill {
    fill: var(--text-secondary) !important;
}

body[data-theme="light"] .ql-snow .ql-picker {
    color: var(--text-secondary) !important;
}

body[data-theme="light"] .edit-toolbar {
    background: rgba(248, 250, 252, 0.9);
}

body[data-theme="light"] .edit-sidebar {
    background: rgba(248, 250, 252, 0.8);
}

/* Scrollbar light theme */
body[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
}

body[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}