/* SchoolProAI - Purple Theme */
:root {
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --primary-light: #A78BFA;
    --primary-bg: #F5F3FF;
    --secondary: #1E1B4B;
    --accent: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* --- Navbar --- */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand span { color: var(--secondary); }

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}

.navbar-nav a {
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.navbar-nav a:hover { color: var(--primary); }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-700);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.5rem;
}

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

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

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

.btn-accent:hover { background: #059669; }

.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* --- Container --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- Hero --- */
.hero {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 50%, #4F46E5 100%);
    color: white;
    padding: 5rem 2rem;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

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

.hero .btn-primary:hover {
    background: var(--gray-100);
}

.hero .btn-outline {
    border-color: white;
    color: white;
}

.hero .btn-outline:hover {
    background: rgba(255,255,255,0.15);
}

/* --- Cards --- */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--gray-900);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* --- Grid --- */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Section --- */
.section {
    padding: 4rem 0;
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.section-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
    color: var(--gray-800);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: auto; }

/* --- Flash Messages --- */
.flash {
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.flash-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.flash-info { background: #EDE9FE; color: #5B21B6; border: 1px solid #DDD6FE; }

/* --- Dashboard --- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 64px);
}

.sidebar {
    background: white;
    border-right: 1px solid var(--gray-200);
    padding: 1.5rem;
}

.sidebar-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.15s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.sidebar-section {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin: 1.5rem 0 0.5rem 1rem;
}

.main-content {
    padding: 2rem;
    max-width: 900px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

/* --- Stats --- */
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* --- Result Display --- */
.result-box {
    background: white;
    border: 2px solid var(--primary-bg);
    border-radius: var(--radius);
    padding: 2rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.result-box h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.result-content {
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

/* --- Flashcard UI --- */
.flashcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.flashcard {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    cursor: pointer;
    position: relative;
    min-height: 180px;
    perspective: 1000px;
    transition: transform 0.2s;
}

.flashcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
    backface-visibility: hidden;
}

.flashcard-front {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
}

.flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg);
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    color: var(--gray-700);
}

.flashcard-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--gray-400);
    margin-bottom: 0.5rem;
}

/* --- Practice Test --- */
.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.question-num {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.option {
    padding: 0.6rem 1rem;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.95rem;
}

.option:hover { border-color: var(--primary); background: var(--primary-bg); }
.option.correct { border-color: var(--accent); background: #D1FAE5; }
.option.incorrect { border-color: var(--danger); background: #FEE2E2; }

.explanation {
    background: var(--primary-bg);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--gray-700);
    display: none;
}

/* --- Pricing --- */
.pricing-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pricing-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.pricing-card.featured {
    border: 2px solid var(--primary);
    transform: scale(1.05);
}

.pricing-card.featured:hover { transform: scale(1.05) translateY(-4px); }

.pricing-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.pricing-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.pricing-price {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.pricing-price span { font-size: 1rem; color: var(--gray-400); font-weight: 500; }

.pricing-features {
    list-style: none;
    margin: 1.5rem 0;
    text-align: left;
}

.pricing-features li {
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pricing-features li::before {
    content: "\2713";
    color: var(--accent);
    font-weight: 700;
}

/* --- History List --- */
.history-list {
    margin-top: 2rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    font-size: 0.95rem;
}

.history-item-title { font-weight: 600; color: var(--gray-800); }
.history-item-date { font-size: 0.85rem; color: var(--gray-400); }

/* --- Auth Forms --- */
.auth-wrapper {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--primary-bg);
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.auth-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* --- Features Grid (homepage) --- */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.feature-card {
    text-align: center;
    padding: 2rem 1.5rem;
}

.feature-card .card-icon { margin: 0 auto 1rem; }

/* --- Loading --- */
.loading {
    display: none;
    text-align: center;
    padding: 2rem;
}

.loading.active { display: block; }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Footer --- */
.footer {
    background: var(--secondary);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
}

.footer p { opacity: 0.7; font-size: 0.9rem; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }

    .navbar-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow-lg);
    }

    .navbar-nav.open { display: flex; }

    .hero h1 { font-size: 2rem; }
    .hero { padding: 3rem 1.5rem; }

    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
        padding: 1rem;
    }

    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-nav a { font-size: 0.85rem; padding: 0.5rem 0.75rem; }
    .sidebar-section { display: none; }

    .main-content { padding: 1.5rem; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .feature-grid { grid-template-columns: 1fr; }

    .pricing-card.featured { transform: scale(1); }
    .pricing-card.featured:hover { transform: translateY(-4px); }

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

@media (max-width: 480px) {
    .hero h1 { font-size: 1.6rem; }
    .container { padding: 0 1rem; }
    .auth-card { padding: 1.5rem; }
}

/* --- Usage Bar --- */
.usage-bar-wrapper {
    margin-bottom: 2rem;
}

.usage-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.usage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.3s;
}

.usage-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* --- Role Toggle --- */
.role-toggle {
    display: flex;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 1rem;
}

.role-toggle label {
    flex: 1;
    text-align: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: var(--gray-500);
}

.role-toggle input { display: none; }
.role-toggle input:checked + label {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

/* --- Tool Cards --- */
.tool-card {
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-left: 3px solid var(--primary);
}

/* --- Print / PDF Export --- */
@media print {
    .navbar, .sidebar, .footer, .no-print,
    form, .loading, .history-list, .flash,
    .btn, .page-subtitle, .nav-toggle {
        display: none !important;
    }

    .dashboard-layout {
        display: block !important;
    }

    .main-content {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .result-box {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .result-box h3 {
        font-size: 1.4rem;
        margin-bottom: 1rem;
        color: #000;
    }

    .result-content {
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }

    body {
        background: white !important;
        color: #000 !important;
    }

    .page-title {
        font-size: 1.6rem;
        color: #000;
        margin-bottom: 0.25rem;
    }
}
