/* ===== CSS Variables for Theming ===== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #242424;
    --text-primary: #f0f0f0;
    --text-secondary: #c0c0c0;
    --border-color: #505050;
    --primary-color: #4da3ff;
    --primary-hover: #3d93ef;
    --success-color: #28a745;
    --danger-color: #e74c3c;
    --warning-color: #ffc107;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.4);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
header {
    background: var(--bg-card);
    border-bottom: 2px solid var(--border-color);
    padding: 20px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    color: var(--text-primary);
    font-weight: 500;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

[data-theme="dark"] .theme-toggle {
    color: #ffffff;
    font-weight: 600;
}

/* ===== Navigation ===== */
nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.nav-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== Views ===== */
.view {
    display: none;
    animation: fadeIn 0.3s;
}

.view.active {
    display: block;
}

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

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: var(--shadow);
}

.card h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.card h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dark theme button improvements */
[data-theme="dark"] .btn-secondary {
    background: var(--bg-secondary);
    color: #ffffff;
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--primary-color);
    color: #ffffff;
}

[data-theme="dark"] .option-btn {
    color: #ffffff;
    font-weight: 600;
}

[data-theme="dark"] .nav-btn {
    color: #f0f0f0;
    font-weight: 600;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* ===== Home View ===== */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.home-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow);
    text-align: center;
}

.home-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.home-card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.home-card h3 {
    margin: 10px 0;
    color: var(--primary-color);
}

.home-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ===== Task List ===== */
.task-list {
    margin-top: 20px;
}

.task-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.task-info {
    flex: 1;
    min-width: 200px;
}

.task-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.task-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 8px;
}

.badge-verbal { background: #d1ecf1; color: #0c5460; }
.badge-numeric { background: #d4edda; color: #155724; }
.badge-visual { background: #fff3cd; color: #856404; }
.badge-concentration { background: #f8d7da; color: #721c24; }
.badge-memory { background: #e2d9f3; color: #4c2c72; }

[data-theme="dark"] .badge-verbal { background: #17a2b8; color: #ffffff; }
[data-theme="dark"] .badge-numeric { background: #28a745; color: #ffffff; }
[data-theme="dark"] .badge-visual { background: #ffc107; color: #000000; }
[data-theme="dark"] .badge-concentration { background: #dc3545; color: #ffffff; }
[data-theme="dark"] .badge-memory { background: #6f42c1; color: #ffffff; }

/* ===== Session View ===== */
.session-setup {
    max-width: 600px;
    margin: 0 auto;
}

.timer-display {
    text-align: center;
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
}

.task-display {
    margin: 30px 0;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.option-btn {
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.option-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.option-btn.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.option-btn.correct {
    border-color: var(--success-color);
    background: var(--success-color);
    color: white;
}

.option-btn.incorrect {
    border-color: var(--danger-color);
    background: var(--danger-color);
    color: white;
}

/* ===== Feedback ===== */
.feedback {
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

[data-theme="dark"] .feedback.correct {
    background: #1e5128;
    color: #90ee90;
    border: 2px solid #28a745;
}

[data-theme="dark"] .feedback.incorrect {
    background: #5a1a1a;
    color: #ffb3b3;
    border: 2px solid #e74c3c;
}

/* ===== Stats View ===== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

.session-history {
    margin-top: 30px;
}

.history-item {
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
}

/* ===== Alert/Toast Messages ===== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

[data-theme="dark"] .alert-success {
    background: #1e5128;
    color: #90ee90;
    border: 1px solid #28a745;
}

[data-theme="dark"] .alert-danger {
    background: #5a1a1a;
    color: #ffb3b3;
    border: 1px solid #e74c3c;
}

[data-theme="dark"] .alert-warning {
    background: #5a4a1a;
    color: #ffe066;
    border: 1px solid #ffc107;
}

[data-theme="dark"] .alert-info {
    background: #1a3a52;
    color: #7dd3fc;
    border: 1px solid #17a2b8;
}

/* ===== Privacy Notice ===== */
.privacy-notice {
    background: #e7f3ff;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
    font-size: 0.9rem;
}

[data-theme="dark"] .privacy-notice {
    background: #1a3a52;
    color: #d0e7ff;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    .header-content {
        justify-content: center;
        text-align: center;
    }

    nav {
        justify-content: center;
    }

    .nav-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .timer-display {
        font-size: 2rem;
    }

    .home-grid {
        grid-template-columns: 1fr;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }
.hidden { display: none !important; }
