:root {
    /* Paleta de Cores */
    --bg-light: #f4f6f9;
    --card-bg: #ffffff;
    --text-main: #0f2b48;
    --text-muted: #64748b;
    --brand-blue: #1d68bd;
    --brand-blue-hover: #1555a0;
    --brand-yellow: #f59e0b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    
    /* Layout */
    --sidebar-width: 260px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
}

/* Utilitários */
.hidden { display: none !important; }
.btn-primary {
    background-color: var(--brand-blue);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.btn-primary:hover { background-color: var(--brand-blue-hover); }

/* Autenticação */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--text-main), var(--brand-blue));
}
.auth-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
}
.auth-header h2 { color: var(--text-main); display: flex; align-items: center; gap: 10px; margin-bottom: 5px;}
.auth-header h2 i { color: var(--brand-yellow); }
.auth-header p { color: var(--text-muted); margin-bottom: 24px; font-size: 0.95rem;}
.input-group { margin-bottom: 16px; }
.input-group label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-size: 1rem;
}
.input-group input:focus { border-color: var(--brand-blue); }
#auth-form button { width: 100%; margin-top: 10px; }
.error-msg { color: var(--danger); font-size: 0.85rem; margin-bottom: 10px; }
.auth-footer { margin-top: 20px; text-align: center; }
.auth-footer a { color: var(--brand-blue); text-decoration: none; font-size: 0.9rem; font-weight: 500;}

/* Layout Principal */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--text-main);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}
.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-header h2 i { color: var(--brand-yellow); }

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--brand-yellow);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.avatar { 
    width: 32px; height: 32px; 
    border-radius: 50%; 
    background: var(--brand-blue); 
    display: flex; justify-content: center; align-items: center;
}
.email-text { font-size: 0.85rem; word-break: break-all; color: rgba(255,255,255,0.8); }
.btn-logout {
    width: 100%; padding: 8px; border: none; border-radius: 6px;
    background: rgba(255,255,255,0.1); color: white; cursor: pointer;
    font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-logout:hover { background: rgba(239, 68, 68, 0.8); }

/* Conteúdo Principal */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    position: relative;
}

/* Loading Overlay for Saves */
.loading-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--brand-blue);
    display: flex; align-items: center; gap: 10px;
    z-index: 1000;
}

/* Headers de Abas */
.dashboard-header, .tab-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.header-text h1, .tab-header h1 { font-size: 1.5rem; color: var(--text-main); margin-bottom: 8px; }
.header-text p, .tab-header p { color: var(--text-muted); font-size: 0.95rem; }

/* Progress Bar */
.progress-container { width: 300px; }
.progress-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600;}
.progress-text { color: var(--brand-blue); }
.progress-bar-bg { background: var(--border-color); height: 8px; border-radius: 4px; overflow: hidden; }
.progress-bar-fill { background: var(--brand-yellow); height: 100%; transition: width 0.3s ease; }

/* Aba 1: Cronograma */
.schedule-grid { display: grid; gap: 20px; }
.week-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.week-header {
    padding: 16px 24px;
    background: var(--text-main);
    color: white;
    font-weight: 600;
    display: flex; justify-content: space-between;
}
.week-body { padding: 10px 24px; }
.task-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.task-item:last-child { border-bottom: none; }
.task-checkbox {
    width: 20px; height: 20px;
    cursor: pointer;
    accent-color: var(--brand-blue);
}
.task-day {
    font-weight: 600; font-size: 0.9rem;
    background: var(--bg-light);
    padding: 4px 8px; border-radius: 6px;
    min-width: 45px; text-align: center;
}
.task-desc { flex: 1; font-size: 0.95rem; }
.task-desc.simulado { color: var(--brand-yellow); font-weight: 600; }
.task-item.completed .task-desc { text-decoration: line-through; color: var(--text-muted); }

.task-metrics {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-light);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-left: 10px;
}
.metric-input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-size: 0.85rem;
    outline: none;
    background: #fff;
    color: var(--text-main);
}
.metric-input:focus {
    border-color: var(--brand-blue);
}
/* Ocultar as setinhas (spinners) do input type="number" para economizar espaço visual */
.metric-input::-webkit-outer-spin-button,
.metric-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.metric-input[type=number] {
    -moz-appearance: textfield;
}
.metric-percent {
    font-weight: 600;
    min-width: 42px;
    text-align: right;
    display: inline-block;
}
.pct-green { color: var(--success); }
.pct-yellow { color: #d97706; } /* darker yellow for readability */
.pct-red { color: var(--danger); }
/* Aba 2: Questões */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.question-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex; flex-direction: column; gap: 15px;
}
.q-title { font-weight: 600; font-size: 1.1rem; color: var(--brand-blue); }
.q-desc { font-size: 0.9rem; color: var(--text-muted); flex: 1; }
.btn-drive {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: #f1f5f9; color: var(--text-main);
    padding: 10px; border-radius: 8px; text-decoration: none; font-size: 0.9rem; font-weight: 500;
}
.btn-drive:hover { background: #e2e8f0; }
.q-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border-color); padding-top: 15px; mt-auto;}
.q-meta { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

/* Aba 3: Simulados */
.simulados-list { display: flex; flex-direction: column; gap: 15px; }
.simulado-item {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 15px;
}
.sim-info h3 { font-size: 1.1rem; color: var(--text-main); margin-bottom: 4px; }
.sim-info p { font-size: 0.85rem; color: var(--text-muted); }
.sim-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.input-score {
    display: flex; align-items: center; gap: 8px;
}
.input-score label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted);}
.input-score input {
    width: 70px; padding: 6px; border: 1px solid var(--border-color); border-radius: 6px; text-align: center;
}
.status-btn {
    padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; border: none; transition: 0.2s;
}
.status-pending { background: #fef3c7; color: #d97706; }
.status-completed { background: #d1fae5; color: #059669; }

/* ==================================
   TAB 4: FLASHCARDS E MODAL
================================== */
.fc-dashboard { display: flex; flex-direction: column; gap: 30px; }
.fc-stats { display: flex; gap: 20px; }
.fc-stat-box {
    flex: 1; background: var(--card-bg); padding: 20px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border-top: 4px solid #ccc;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.fc-stat-num { font-size: 2rem; font-weight: 700; color: var(--text-main); }
.fc-stat-label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; margin-top: 5px; }

.fc-filter-section {
    background: var(--card-bg); padding: 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}

.fc-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 43, 72, 0.95); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}
.fc-modal-content {
    background: #f4f6f9; width: 90%; max-width: 800px; height: 90%; max-height: 700px;
    border-radius: var(--radius-lg); display: flex; flex-direction: column; position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3); overflow: hidden;
}
.fc-modal-header {
    padding: 20px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center; background: white;
}
.fc-close-btn {
    background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
}
.fc-close-btn:hover { color: var(--danger); }

/* FLIP CARD */
.fc-card-container {
    flex: 1; padding: 40px; display: flex; justify-content: center; align-items: center;
    perspective: 1000px;
}
.fc-card {
    width: 100%; height: 100%; max-width: 600px; max-height: 400px;
    position: relative; transition: transform 0.6s; transform-style: preserve-3d;
}
.fc-card.flipped { transform: rotateX(180deg); }

.fc-card-front, .fc-card-back {
    position: absolute; width: 100%; height: 100%; backface-visibility: hidden;
    background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    padding: 30px; display: flex; flex-direction: column; justify-content: center; align-items: center;
    font-size: 1.3rem; text-align: center; color: var(--text-main); overflow-y: auto;
}
.fc-card-back { transform: rotateX(180deg); border-top: 4px solid var(--brand-blue); }

.fc-controls {
    padding: 20px; background: white; border-top: 1px solid var(--border-color);
}
.fc-answer-buttons {
    display: flex; gap: 10px; width: 100%;
}
.fc-ans-btn {
    flex: 1; padding: 12px 10px; border: none; border-radius: 6px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px; color: white;
    font-family: 'Inter', sans-serif; transition: 0.2s;
}
.fc-ans-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.fc-ans-btn .time { font-size: 0.8rem; opacity: 0.9; font-weight: 500; }
.fc-ans-btn .label { font-size: 1rem; font-weight: 600; }
.fc-ans-1 { background: #ef4444; }
.fc-ans-2 { background: #f59e0b; }
.fc-ans-3 { background: #10b981; }
.fc-ans-4 { background: #3b82f6; }

.btn-flashcard-inline {
    background: rgba(59, 130, 246, 0.1); color: var(--brand-blue); border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px; margin-left: auto; transition: 0.2s;
}
.btn-flashcard-inline:hover { background: rgba(59, 130, 246, 0.2); }

/* --- Anki Style Deck Tree --- */
.fc-deck-section {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 20px;
    font-family: 'Inter', sans-serif;
}
.fc-deck-header {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: var(--brand-blue);
}
.fc-deck-stats-header {
    display: flex;
    gap: 30px;
    width: 250px;
    justify-content: flex-end;
}
.fc-deck-stats-header span {
    width: 65px;
    text-align: right;
    font-size: 0.85rem;
    text-transform: uppercase;
}
.fc-deck-tree {
    display: flex;
    flex-direction: column;
}
.fc-deck-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-main);
    align-items: center;
}
.fc-deck-row:hover {
    background: #f8fafc;
}
.fc-deck-row:last-child {
    border-bottom: none;
}
.fc-deck-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    flex: 1;
}
.fc-deck-row.subdeck .fc-deck-name {
    padding-left: 30px;
    font-weight: 400;
    color: var(--text-muted);
}
.fc-deck-row.subdeck .fc-deck-name::before {
    content: '-';
    color: #cbd5e1;
}
.fc-deck-stats {
    display: flex;
    gap: 30px;
    width: 250px;
    justify-content: flex-end;
}
.fc-deck-stats span {
    width: 65px;
    text-align: right;
    font-weight: 600;
}
.fc-deck-row.empty .fc-deck-stats span {
    opacity: 0.3;
}
.fc-color-new { color: #3b82f6; }
.fc-color-learn { color: #ef4444; }
.fc-color-review { color: #22c55e; }
.fc-toggle-icon {
    width: 15px;
    display: inline-block;
    color: var(--brand-blue);
    font-weight: bold;
}

/* --- Review Heatmap (Dark Theme) --- */
.fc-heatmap-wrapper {
    background-color: #272828;
    color: #e5e7eb;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 30px;
    margin-top: 20px;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.hm-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    border-bottom: 1px solid #4b5563;
    padding-bottom: 15px;
    text-align: center;
}
.hm-title {
    font-size: 1rem;
    font-weight: 500;
}
.hm-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.9rem;
    color: #cbd5e1;
}
.hm-grid-container {
    display: flex;
    align-items: center;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 0;
    width: 100%;
    justify-content: center;
}
.hm-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 6px;
    grid-auto-flow: column;
}
.hm-day {
    width: 20px;
    height: 20px;
    background-color: #3f3f46;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}
.hm-day.lvl-1 { background-color: #a7f3d0; } /* 1-20 cards (very light bright green) */
.hm-day.lvl-2 { background-color: #6ee7b7; } /* 21-50 */
.hm-day.lvl-3 { background-color: #34d399; } /* 51-100 */
.hm-day.lvl-4 { background-color: #10b981; } /* 101-200 */
.hm-day.lvl-5 { background-color: #059669; } /* 200+ (intense dark green) */

.hm-day:hover::after {
    content: attr(data-info);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    margin-bottom: 8px;
}
.hm-footer {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    font-size: 0.9rem;
    font-weight: 500;
}

.hm-stat-item {
    color: #e5e7eb;
}
.hm-stat-item span {
    color: #34d399;
}
