/* ==================== RAIO-X ENEM — Design System ==================== */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-card: #141414;
  --bg-hover: #1e1e1e;
  --bg-input: #1a1a1a;
  --border-primary: #2a2a2a;
  --border-secondary: #333333;
  --border-focus: #d4a843;
  --text-primary: #f5f5f5;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --gold: #d4a843;
  --gold-light: #e8c96a;
  --gold-dark: #b8922e;
  --gold-bg: rgba(212,168,67,0.08);
  --gold-bg-hover: rgba(212,168,67,0.15);
  --success: #34d399;
  --success-bg: rgba(52,211,153,0.1);
  --error: #f87171;
  --error-bg: rgba(248,113,113,0.1);
  --warning: #fbbf24;
  --info: #60a5fa;
  --c1: #60a5fa; --c1-bg: rgba(96,165,250,0.1);
  --c2: #a78bfa; --c2-bg: rgba(167,139,250,0.1);
  --c3: #34d399; --c3-bg: rgba(52,211,153,0.1);
  --c4: #fbbf24; --c4-bg: rgba(251,191,36,0.1);
  --c5: #f87171; --c5-bg: rgba(248,113,113,0.1);
  --font-body: 'Inter', system-ui, sans-serif;
  --font-heading: 'Manrope', 'Inter', sans-serif;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --sidebar-w: 260px;
  --header-h: 64px;
  --mobile-nav-h: 64px;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-x: hidden; }
a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }
h1,h2,h3,h4 { font-family: var(--font-heading); font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ==================== LAYOUT ==================== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh; background: var(--bg-secondary); border-right: 1px solid var(--border-primary); display: flex; flex-direction: column; z-index: 100; overflow-y: auto; }
.sidebar-brand { padding: 20px; border-bottom: 1px solid var(--border-primary); display: flex; align-items: center; gap: 12px; }
.sidebar-brand .brand-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--gold), var(--gold-dark)); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #000; font-size: 14px; }
.sidebar-brand h1 { font-size: 1.1rem; color: var(--text-primary); }
.sidebar-brand span { font-size: 0.7rem; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-md); color: var(--text-secondary); font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all var(--transition); border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--gold-bg); color: var(--gold); }
.nav-item i { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-section { padding: 8px 14px 4px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-top: 8px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-primary); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-md); cursor: pointer; transition: background var(--transition); }
.sidebar-user:hover { background: var(--bg-hover); }
.sidebar-user .avatar { width: 32px; height: 32px; background: var(--gold-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--gold); font-weight: 600; font-size: 0.85rem; }
.sidebar-user .user-info { flex: 1; overflow: hidden; }
.sidebar-user .user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 0.7rem; color: var(--text-muted); }

.main-content { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; }
.page-header { padding: 20px 28px; border-bottom: 1px solid var(--border-primary); background: var(--bg-secondary); }
.page-header h1 { margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; }
.page-body { padding: 24px 28px; max-width: 1200px; }

/* Mobile Nav */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--mobile-nav-h); background: var(--bg-secondary); border-top: 1px solid var(--border-primary); z-index: 100; padding: 0 8px; }
.mobile-nav-inner { display: flex; justify-content: space-around; align-items: center; height: 100%; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; color: var(--text-muted); font-size: 0.65rem; cursor: pointer; border: none; background: none; transition: color var(--transition); }
.mobile-nav-item.active { color: var(--gold); }
.mobile-nav-item i { font-size: 1.2rem; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .main-content { margin-left: 0; padding-bottom: calc(var(--mobile-nav-h) + 16px); }
  .page-header { padding: 16px; }
  .page-body { padding: 16px; }
}

/* ==================== COMPONENTS ==================== */
/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-lg); padding: 20px; transition: all var(--transition); }
.card:hover { border-color: var(--border-secondary); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.stat-card { text-align: center; padding: 20px; }
.stat-value { font-size: 2rem; font-weight: 800; font-family: var(--font-heading); color: var(--gold); }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-size: 1.3rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-md); font-size: 0.9rem; font-weight: 600; font-family: var(--font-body); cursor: pointer; border: 1px solid transparent; transition: all var(--transition); line-height: 1; }
.btn-primary { background: var(--gold); color: #000; }
.btn-primary:hover { background: var(--gold-light); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-secondary); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--gold-dark); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: var(--error-bg); color: var(--error); border-color: rgba(248,113,113,0.2); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-primary); border-radius: var(--radius-md); color: var(--text-primary); font-size: 0.9rem; font-family: var(--font-body); transition: border-color var(--transition); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(212,168,67,0.1); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-error { color: var(--error); font-size: 0.8rem; margin-top: 4px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-gold { background: var(--gold-bg); color: var(--gold); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: rgba(96,165,250,0.1); color: var(--info); }
.badge-c1 { background: var(--c1-bg); color: var(--c1); }
.badge-c2 { background: var(--c2-bg); color: var(--c2); }
.badge-c3 { background: var(--c3-bg); color: var(--c3); }
.badge-c4 { background: var(--c4-bg); color: var(--c4); }
.badge-c5 { background: var(--c5-bg); color: var(--c5); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-primary); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 16px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; transition: all var(--transition); white-space: nowrap; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab:hover { color: var(--text-primary); }

/* Progress */
.progress-bar { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; background: var(--gold); }
.progress-fill.c1 { background: var(--c1); }
.progress-fill.c2 { background: var(--c2); }
.progress-fill.c3 { background: var(--c3); }
.progress-fill.c4 { background: var(--c4); }
.progress-fill.c5 { background: var(--c5); }

/* Toast */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-md); font-size: 0.85rem; font-weight: 500; animation: slideIn 0.3s ease; max-width: 360px; box-shadow: var(--shadow-lg); }
.toast-success { background: #065f46; color: #a7f3d0; border: 1px solid #047857; }
.toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
.toast-info { background: #1e3a5f; color: #93c5fd; border: 1px solid #1e40af; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-lg); padding: 24px; max-width: 520px; width: 100%; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.3rem; padding: 4px; }
.modal-close:hover { color: var(--text-primary); }

/* Empty State */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; color: var(--border-secondary); }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* Disclaimer */
.disclaimer { background: rgba(251,191,36,0.05); border: 1px solid rgba(251,191,36,0.15); border-radius: var(--radius-md); padding: 12px 16px; font-size: 0.8rem; color: var(--warning); display: flex; align-items: flex-start; gap: 10px; }
.disclaimer i { margin-top: 2px; flex-shrink: 0; }

/* List Item */
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius-md); border: 1px solid var(--border-primary); background: var(--bg-card); transition: all var(--transition); cursor: pointer; margin-bottom: 8px; }
.list-item:hover { border-color: var(--gold-dark); background: var(--bg-hover); }
.list-item-icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.1rem; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 0.8rem; color: var(--text-muted); }
.list-item-meta { text-align: right; font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }

/* ==================== AUTH PAGES ==================== */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg-primary); }
.auth-card { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-xl); padding: 40px; max-width: 420px; width: 100%; }
.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-brand .brand-icon { width: 56px; height: 56px; background: linear-gradient(135deg, var(--gold), var(--gold-dark)); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #000; font-size: 20px; margin: 0 auto 12px; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-brand p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.85rem; color: var(--text-muted); }

/* ==================== ONBOARDING ==================== */
.onboarding-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.onboarding-card { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-xl); padding: 40px; max-width: 520px; width: 100%; }
.onboarding-steps { display: flex; gap: 8px; margin-bottom: 28px; }
.onboarding-step { flex: 1; height: 4px; border-radius: 2px; background: var(--border-primary); transition: background var(--transition); }
.onboarding-step.done { background: var(--gold); }
.onboarding-step.current { background: var(--gold-dark); }
.onboarding-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.onboarding-option { padding: 12px; border: 1px solid var(--border-primary); border-radius: var(--radius-md); text-align: center; cursor: pointer; transition: all var(--transition); font-size: 0.85rem; }
.onboarding-option:hover { border-color: var(--gold-dark); }
.onboarding-option.selected { border-color: var(--gold); background: var(--gold-bg); color: var(--gold); }

/* ==================== ESSAY EDITOR ==================== */
.editor-layout { display: flex; gap: 20px; min-height: calc(100vh - var(--header-h) - 48px); }
.editor-main { flex: 1; display: flex; flex-direction: column; }
.editor-textarea { flex: 1; min-height: 400px; padding: 20px; background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-lg); color: var(--text-primary); font-family: 'Inter', sans-serif; font-size: 1rem; line-height: 1.8; resize: none; transition: border-color var(--transition); }
.editor-textarea:focus { outline: none; border-color: var(--border-focus); }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.editor-stats { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-muted); }
.editor-sidebar { width: 320px; flex-shrink: 0; }
@media (max-width: 768px) {
  .editor-layout { flex-direction: column; }
  .editor-sidebar { width: 100%; }
}

/* ==================== ANALYSIS RESULTS ==================== */
.score-circle { width: 140px; height: 140px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--gold-bg); border: 3px solid var(--gold); margin: 0 auto 16px; }
.score-circle .score-value { font-size: 2.5rem; font-weight: 800; font-family: var(--font-heading); color: var(--gold); line-height: 1; }
.score-circle .score-max { font-size: 0.8rem; color: var(--text-muted); }
.competency-card { padding: 16px; border-radius: var(--radius-md); border: 1px solid var(--border-primary); margin-bottom: 12px; }
.competency-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.competency-name { font-weight: 600; font-size: 0.9rem; }
.competency-score { font-weight: 700; font-family: var(--font-heading); }

/* ==================== EXERCISE PLAYER ==================== */
.exercise-modal { max-width: 640px; }
.exercise-question { font-size: 1rem; line-height: 1.7; margin-bottom: 20px; padding: 16px; background: var(--bg-tertiary); border-radius: var(--radius-md); }
.option-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--border-primary); border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); margin-bottom: 8px; }
.option-item:hover { border-color: var(--gold-dark); background: var(--bg-hover); }
.option-item.selected { border-color: var(--gold); background: var(--gold-bg); }
.option-item.correct { border-color: var(--success); background: var(--success-bg); }
.option-item.incorrect { border-color: var(--error); background: var(--error-bg); }
.option-label { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-secondary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.option-item.selected .option-label { border-color: var(--gold); color: var(--gold); }
.option-item.correct .option-label { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.option-item.incorrect .option-label { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.option-text { flex: 1; font-size: 0.9rem; line-height: 1.5; }
.option-explanation { font-size: 0.8rem; color: var(--text-secondary); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-primary); }

/* ==================== LOADING ==================== */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-primary); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
