/* =========================================
   BASE STYLES - design tokens & utilities
   ========================================= */

:root {
    /* Colors */
    --primary-color: #1F7D53;
    --primary-rgb: 31, 125, 83;
    --primary-light: rgba(var(--primary-rgb), 0.1);
    --primary-hover: #13887d;
    --dark-bg: #111827;
    /* Dark navy for bottom CTA */
    --text-main: #1f2937;
    /* Dark grey for headings */
    --text-body: #6b7280;
    /* Lighter grey for body text */
    --bg-color: #ffffff;
    --bg-secondary: #f9fafb;
    /* Light grey for sections */
    --input-bg: #f3f4f6;
    --white: #ffffff;
    --error-color: #ef4444;

    /* Surfaces */
    --page-bg: #f8fafc;

    --badge-bg: #fff7ed;
    --badge-text: #c2410c;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Spacing */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-12: 3rem;

    /* Borders */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;

    /* Variables for feature colors */
    --feature-icon-bg-streak: #fff7ed;
    --feature-icon-text-streak: #ea580c;
    --feature-icon-bg-correct: #ecfdf5;
    --feature-icon-text-correct: #059669;
    --feature-icon-bg-exam: #eff6ff;
    --feature-icon-text-exam: #2563eb;

    /* Onboarding additions */
    --primary-light-bg: rgba(var(--primary-rgb), 0.15);
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.bg-gray-50 {
    background-color: var(--page-bg);
}

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

ul {
    list-style: none;
}

/* ALerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-weight: bold;
}

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

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

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

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.text-center {
    text-align: center;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.flex-col {
    flex-direction: column;
}

.gap-2 {
    gap: var(--spacing-2);
}

.gap-4 {
    gap: var(--spacing-4);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

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

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

.btn-full {
    width: 100%;
}

.btn-pill {
    border-radius: 50px;
    padding-left: 2rem;
    padding-right: 2rem;
}

.relative {
    position: relative;
}

/* Header (Global) */
header {
    padding: var(--spacing-4) 0;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--bg-secondary);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.logo {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.logo span {
    color: var(--text-main);
}

.nav-links li a {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-main);
}

/* Footer (Global) */
footer {
    padding: var(--spacing-8) 0;
    text-align: center;
    color: var(--text-body);
    font-size: var(--text-sm);
    border-top: 1px solid #e5e7eb;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--spacing-6);
    margin-bottom: var(--spacing-4);
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Toast Notification (Shared) */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    min-width: 300px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-fade-out {
    animation: fadeOut 0.5s ease-in forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Dashboard Container (Shared across Dashboard, Profile, Rank) */
.dashboard-container {
    max-width: 480px;
    margin: 0 auto;
    background-color: var(--page-bg);
    min-height: 100vh;
    padding-bottom: 80px;
    position: relative;
}

/* Dashboard Header (Shared) */
.dashboard-header {
    background-color: var(--white);
    padding: 20px 20px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.greeting {
    font-size: 0.9rem;
    color: var(--text-body);
    margin-bottom: 2px;
}

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

.username {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    line-height: 1.2;
}

.exam-badge {
    background-color: #e0f2fe;
    color: #0284c7;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.profile-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--white);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Profile Dropdown (Shared) */
.profile-section {
    position: relative;
    z-index: 50;
}

.profile-avatar {
    cursor: pointer;
    transition: transform 0.2s;
}

.profile-avatar:hover {
    transform: scale(1.05);
}

.profile-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    width: 200px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease-in-out;
    border: 1px solid #f3f4f6;
    padding: 8px;
    z-index: 100;
}

.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
    text-decoration: none;
}

.dropdown-item:hover {
    background-color: #f9fafb;
}

.dropdown-item svg {
    color: var(--text-body);
}

.dropdown-item.text-red {
    color: #ef4444;
}

.dropdown-item.text-red svg {
    color: #ef4444;
}

.dropdown-item.text-red:hover {
    background-color: #fef2f2;
}

.dropdown-divider {
    height: 1px;
    background-color: #f3f4f6;
    margin: 6px 0;
}

/* Modals (Generic) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--white);
    width: 100%;
    max-width: 480px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--white);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
    margin: 0;
}

.close-btn {
    background: #f3f4f6;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
}

.close-btn:hover {
    background-color: #e5e7eb;
    color: var(--text-main);
}

.modal-body {
    padding: 16px 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}

.modal-desc {
    color: var(--text-body);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background-color: var(--white);
    position: sticky;
    bottom: 0;
}

.btn-secondary {
    background-color: var(--white);
    border: 1px solid #e5e7eb;
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.btn-primary-modal {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(26, 163, 151, 0.4);
    transition: transform 0.1s;
}

.btn-primary-modal:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

/* Avatar Modal Grid (Common enough to be in base as it is used in multiple places) */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-option img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}

.avatar-option:hover {
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary-color);
    background-color: #f0fdf4;
    transform: scale(1.1);
}

/* Form Styles */
.form-group {
    margin-bottom: var(--spacing-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: var(--spacing-2);
}

.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: var(--spacing-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-body);
    display: flex;
}

.input-icon svg {
    width: 20px;
    height: 20px;
}

.form-input {
    width: 100%;
    padding: 0.75rem var(--spacing-3) 0.75rem 2.75rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    color: var(--text-main);
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 163, 151, 0.1);
}

/* Bottom Nav (Shared) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--white);
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: 62px;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 12px;
    margin: 6px 4px;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.18s;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-color);
    background-color: var(--primary-light);
}

.nav-item.active svg {
    transform: scale(1.1);
}

/* Responsive Helper - Desktop view override */
@media (min-width: 640px) {
    .dashboard-container {
        max-width: 1000px;
        margin-top: 40px;
        border-radius: 20px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    }

    .dashboard-header {
        border-radius: 20px 20px 0 0;
    }
}