:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f0f5;
    --text-secondary: #9898a8;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-2: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg-primary: #f5f5f8;
    --bg-secondary: #ffffff;
    --bg-card: rgba(0, 0, 0, 0.03);
    --bg-glass: rgba(255, 255, 255, 0.8);
    --border: rgba(0, 0, 0, 0.08);
    --text-primary: #1a1a2e;
    --text-secondary: #64648c;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--gradient-1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.sidebar-nav { padding: 16px 12px; }

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 16px 12px 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active { background: rgba(99, 102, 241, 0.15); color: var(--accent-hover); }

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
}

.topbar-search { flex: 1; max-width: 400px; }

.search-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 40px; height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.icon-btn:hover { background: var(--bg-glass); }

.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 500; font-size: 0.9rem; }

.main-content { padding: 24px; flex: 1; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title { font-size: 1.75rem; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 4px; }

.card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-gradient {
    background: var(--gradient-1);
    border: none;
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-1);
}

.stat-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-change { font-size: 0.8rem; margin-top: 8px; }
.stat-change.up { color: var(--success); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-hover);
}

.badge-success { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-error { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

tr:hover td { background: var(--bg-glass); }

.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-textarea { min-height: 120px; resize: vertical; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--error); }

.progress-bar {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

.chart-container { position: relative; height: 300px; }

.topic-input-hero {
    text-align: center;
    padding: 60px 40px;
}

.topic-input-hero h2 {
    font-size: 2rem;
    margin-bottom: 12px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topic-input-wrapper {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: 32px auto 0;
}

.topic-input {
    flex: 1;
    padding: 16px 24px;
    font-size: 1.1rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
}

.topic-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.15), transparent 50%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; text-align: center; }
.auth-subtitle { color: var(--text-secondary); text-align: center; margin-bottom: 32px; font-size: 0.9rem; }

.auth-links { text-align: center; margin-top: 20px; font-size: 0.9rem; }
.auth-links a { color: var(--accent-hover); text-decoration: none; }

.install-steps { display: flex; gap: 8px; margin-bottom: 32px; justify-content: center; }
.install-step {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
}
.install-step.active { background: var(--gradient-1); border-color: transparent; color: white; }
.install-step.done { background: var(--success); border-color: transparent; color: white; }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.media-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
}

.media-item:hover { transform: translateY(-2px); }
.media-thumb { aspect-ratio: 16/9; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.media-info { padding: 12px; font-size: 0.8rem; }

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 200;
    max-height: 400px;
    overflow-y: auto;
}

.notifications-dropdown { position: relative; }
.dropdown-menu.show { display: block; }

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.notif-item:last-child { border-bottom: none; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .grid-2 { grid-template-columns: 1fr; }
    .topic-input-wrapper { flex-direction: column; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.processing { animation: pulse 2s infinite; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; }

.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 1.1rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.oauth-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

.hidden { display: none !important; }
