/* style.css */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #0A192F;
    --primary-hover: #172a45;
    --secondary: #E31837;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #E31837;
    --background: #F8FAFC;
    --card-bg: #ffffff;
    --text-main: #0A192F;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-bg: #0A192F;
    --sidebar-hover: #172a45;
    --accent: #E31837;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
}

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

body {
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    display: flex;
    height: 100vh;
    background-color: var(--background);
    background-image: radial-gradient(#cbd5e1 0.8px, transparent 0.8px);
    background-size: 20px 20px;
    color: var(--text-main);
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-main);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Sidebar Styles */
#sidebar-container {
    height: 100%;
    display: flex;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 10;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 24px;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.sidebar a {
    color: #94a3b8;
    text-decoration: none;
    padding: 14px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.sidebar a:hover, .sidebar a.active {
    background-color: var(--sidebar-hover);
    color: white;
    border-left: 4px solid var(--accent);
}

.sidebar a i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 12px;
    text-align: center;
    color: #64748b;
    transition: color 0.3s;
}

.sidebar a:hover i, .sidebar a.active i {
    color: var(--accent);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header Styles */
.top-header {
    height: 70px;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.user-profile {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Dashboard Content */
.content-area {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}
.page-header p {
    color: var(--text-muted);
    margin-top: 4px;
}

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

/* Form Styles & Cards */
.config-card {
    background: var(--card-bg);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.rule-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    align-items: flex-end;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: var(--font-body);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -2px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}
.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}
.btn-secondary:hover {
    background: #cbd5e1;
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn i {
    font-size: 1rem;
}

/* Cards & Stats */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Table Style */
.table-container {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: #f8fafc;
    padding: 16px 24px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-primary { background: rgba(79, 70, 229, 0.1); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Result Box */
.result-box {
    margin-top: 24px;
    padding: 20px;
    background: #f0fdf4;
    border-left: 4px solid var(--success);
    color: #166534;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    display: none;
    animation: fadeIn 0.3s ease;
}

.result-box i {
    color: var(--success);
    margin-right: 8px;
    font-size: 1.2rem;
    vertical-align: middle;
}

/* Exam Screen / Focus-driven UI */
.exam-layout {
    background-color: #0f172a;
    background-image: none;
    color: #f8fafc;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.exam-header {
    height: 60px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exam-main {
    flex: 1;
    display: flex;
    padding: 40px;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    align-items: center;
}

.exam-display-panel {
    flex: 1.2;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 24px;
    padding: 48px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 400px;
    position: relative;
}

.exam-input-panel {
    flex: 0.8;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.numpad-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
    font-size: 1.8rem;
    font-weight: 600;
    font-family: var(--font-heading);
    padding: 20px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
}

.numpad-btn:active, .numpad-btn.pressed {
    background: #38bdf8;
    color: #0f172a;
    transform: scale(0.95);
}

.question-text {
    font-size: 5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin-bottom: 24px;
    letter-spacing: 2px;
    text-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.answer-box {
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 16px;
    padding: 16px;
    font-size: 3rem;
    font-family: var(--font-heading);
    font-weight: 700;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    letter-spacing: 1px;
}

.exam-progress {
    width: 100%;
    height: 8px;
    background: #334155;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 24px;
}

.exam-progress-bar {
    height: 100%;
    background: linear-gradient(to right, #3b82f6, #38bdf8);
    width: 0%;
    transition: width 0.3s ease;
}

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

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 1.5s infinite;
}

/* Modal Overlay for Break / Dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #1e293b;
    border: 1px solid #334155;
    color: white;
    border-radius: 24px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

/* Auth Portal Cards */
.auth-container {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 40px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 2.2rem;
    color: var(--primary);
    font-weight: 800;
}

.auth-tab-buttons {
    display: flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Practice styling */
.streak-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--warning);
}

/* Responsive design adjustments */
@media(max-width: 768px) {
    body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        padding: 12px 0;
    }
    .sidebar h2 {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }
    .sidebar a {
        padding: 10px 16px;
    }
    .exam-main {
        flex-direction: column;
        padding: 16px;
    }
    .exam-display-panel {
        min-height: 250px;
        padding: 24px;
    }
    .question-text {
        font-size: 3rem;
    }
}

/* Abacus Grid Taking Styles */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.question-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 220px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.question-card-header {
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.question-card-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin-bottom: 12px;
    padding-right: 16px;
    color: var(--text-main);
}

.question-card-stack span {
    line-height: 1.4;
    text-align: right;
    width: 100%;
}

.question-card-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

.question-card-input:focus {
    outline: none;
    border-color: var(--secondary);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(227, 24, 55, 0.15);
}