/* ============================================================
   ReaderScribe — Premium Design System
   Digital Reader & Scribe Exam Platform
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --brand-primary: #1B4332;
    --brand-secondary: #2D6A4F;
    --brand-accent: #40916C;
    --brand-light: #D8F3DC;
    --brand-lighter: #F0FFF4;
    --brand-dark: #081C15;
    --brand-text: #1A1A2E;
    --brand-body: #424242;
    --brand-muted: #6B7280;
    --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;
    --white: #FFFFFF;
    --danger: #DC2626;
    --danger-light: #FEF2F2;
    --warning: #D97706;
    --warning-light: #FFFBEB;
    --success: #059669;
    --success-light: #ECFDF5;
    --info: #2563EB;
    --info-light: #EFF6FF;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.15);
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', 'Inter', sans-serif;
    --transition: all 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    color: var(--brand-body);
    line-height: 1.6;
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--brand-text);
    font-weight: 600;
    line-height: 1.3;
}

a { color: var(--brand-secondary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--brand-accent); }

img { max-width: 100%; height: auto; }

/* ---- Utilities ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--brand-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(27, 67, 50, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-secondary) 0%, var(--brand-accent) 100%);
    box-shadow: 0 4px 16px rgba(27, 67, 50, 0.4);
    transform: translateY(-1px);
    color: var(--white);
}

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

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

.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-lg { padding: 14px 32px; font-size: 1.0625rem; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--brand-text);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--brand-text);
    background: var(--white);
    transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}
.form-input::placeholder { color: var(--gray-400); }

.form-input.is-error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.8125rem; margin-top: 4px; }

.input-icon-wrapper {
    position: relative;
}
.input-icon-wrapper .form-input {
    padding-left: 42px;
}
.input-icon-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1rem;
}

/* ---- Cards ---- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2, .card-header h3 {
    font-size: 1.125rem;
    margin: 0;
}
.card-body { padding: 24px; }
.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ---- Alerts ---- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.25rem;
    position: relative;
}
.alert i { font-size: 1.125rem; flex-shrink: 0; }
.alert-close {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.6;
    color: inherit;
}
.alert-success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.alert-error { background: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--warning-light); color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: var(--info-light); color: #1E40AF; border: 1px solid #BFDBFE; }

/* ---- Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white);
    letter-spacing: 0.02em;
}

/* ---- Tables ---- */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9375rem;
}
table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--brand-text);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
table tbody tr:hover { background: var(--brand-lighter); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(160deg, #050d09 0%, #0a1f14 25%, var(--brand-primary) 60%, var(--brand-secondary) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -15%;
    width: 70%;
    height: 160%;
    background: radial-gradient(ellipse, rgba(64, 145, 108, 0.12) 0%, transparent 60%);
    pointer-events: none;
    animation: floatGlow 8s ease-in-out infinite alternate;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -10%;
    width: 50%;
    height: 100%;
    background: radial-gradient(ellipse, rgba(45, 106, 79, 0.1) 0%, transparent 60%);
    pointer-events: none;
    animation: floatGlow 10s ease-in-out 2s infinite alternate-reverse;
}

@keyframes floatGlow {
    0% { transform: translate(0, 0) scale(1); opacity: 0.8; }
    100% { transform: translate(30px, -20px) scale(1.05); opacity: 1; }
}

/* Geometric pattern overlay */
.login-page .login-left::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(64, 145, 108, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(216, 243, 220, 0.05) 0%, transparent 50%),
        linear-gradient(60deg, transparent 40%, rgba(255,255,255,0.015) 40%, rgba(255,255,255,0.015) 60%, transparent 60%),
        linear-gradient(-60deg, transparent 40%, rgba(255,255,255,0.01) 40%, rgba(255,255,255,0.01) 60%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 60px 60px 80px;
    color: var(--white);
    position: relative;
    z-index: 1;
}

.login-brand {
    margin-bottom: 48px;
}
.login-brand .brand-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}
.login-brand .brand-icon {
    width: 52px;
    height: 52px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    backdrop-filter: blur(10px);
}
.login-brand h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.02em;
}
.login-brand .tagline {
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
    margin-left: 66px;
}

.login-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.login-features li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    font-size: 1rem;
    color: rgba(255,255,255,0.85);
    line-height: 1.5;
}
.login-features li .feature-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    color: var(--brand-light);
    backdrop-filter: blur(10px);
}
.login-features li strong {
    display: block;
    color: var(--white);
    font-weight: 600;
    margin-bottom: 2px;
}

.login-right {
    width: 520px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255,255,255,0.06);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 44px 40px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1);
}

.login-card h2 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 8px;
}
.login-card .login-subtitle {
    text-align: center;
    color: var(--brand-muted);
    font-size: 0.9375rem;
    margin-bottom: 28px;
}

.login-card .form-group .input-icon-wrapper .form-input {
    height: 48px;
    font-size: 0.9375rem;
}

.login-card .btn-primary {
    height: 48px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--gray-400);
    font-size: 0.8125rem;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8125rem;
    color: var(--gray-400);
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
}
.password-toggle:hover { color: var(--brand-secondary); }

/* ---- Login tabs (School / Super Admin) ---- */
.login-tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 24px;
}
.login-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: var(--transition);
}
.login-tab.active {
    background: var(--white);
    color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
}

/* ---- Responsive ---- */
@media (max-width: 960px) {
    .login-page { flex-direction: column; }
    .login-left { padding: 40px 24px; min-height: auto; }
    .login-features { display: none; }
    .login-right { width: 100%; min-height: auto; padding: 0 24px 40px; }
    .login-card { max-width: 100%; }
}

@media (max-width: 480px) {
    .login-card { padding: 28px 20px; }
    .login-brand h1 { font-size: 1.375rem; }
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    background: var(--brand-dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.sidebar-brand h2 {
    font-size: 1.0625rem;
    color: var(--white);
    font-weight: 600;
}
.sidebar-brand .brand-sub {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}
.sidebar-section {
    margin-bottom: 24px;
}
.sidebar-section-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    padding: 0 12px 8px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.7);
    font-size: 0.9375rem;
    font-weight: 400;
    transition: var(--transition);
    margin-bottom: 2px;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}
.sidebar-link.active {
    background: var(--brand-secondary);
    color: var(--white);
    font-weight: 500;
}
.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.8;
}
.sidebar-link.active i { opacity: 1; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--white);
}
.sidebar-user-info {
    flex: 1;
    min-width: 0;
}
.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.5);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    background: var(--gray-50);
}

.topbar {
    height: 64px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--brand-text);
}
.topbar-breadcrumb {
    font-size: 0.8125rem;
    color: var(--gray-400);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--brand-text);
    cursor: pointer;
    padding: 8px;
}

.page-content {
    padding: 32px;
}

/* ---- Stats Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-200);
}
.stat-card .stat-info h3 {
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--brand-text);
    line-height: 1;
}
.stat-card .stat-change {
    font-size: 0.8125rem;
    margin-top: 6px;
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ---- Responsive Dashboard ---- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-menu-toggle {
        display: block;
    }
    .page-content {
        padding: 20px;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .topbar {
        padding: 0 16px;
    }
    .page-content {
        padding: 16px;
    }
}
