/* ==========================================================================
   SRRPS ExamPress - Master UI & Theme Stylesheet
   Shri Ram Radhe Public School, Kanpur
   ========================================================================== */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #1e293b;
    --accent-gold: #d97706;
    --accent-gold-hover: #b45309;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --border-color: #334155;
    --sidebar-width: 250px;
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-devanagari: 'Noto Sans Devanagari', 'Mangal', 'Arial Unicode MS', sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Light Theme Override */
body.light-theme {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
}

/* Layout Architecture */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.brand-header {
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.15), transparent);
}

.brand-logo {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    border: 2px solid var(--accent-gold);
    object-fit: cover;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--accent-gold);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    list-style: none;
    padding: 1rem 0.5rem;
    flex: 1;
}

.nav-item {
    margin-bottom: 0.35rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    background-color: var(--accent-gold);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
}

/* Top Navbar */
.top-navbar {
    min-height: 64px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
    gap: 1rem;
    flex-wrap: wrap;
}

.role-switcher-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(217, 119, 6, 0.15);
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--accent-gold);
}

.role-switcher-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.role-select {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.role-select option {
    background: var(--bg-secondary);
    color: var(--text-main);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-gold);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* Content Body */
.content-body {
    padding: 1.5rem;
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Cards & Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.stat-info .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-icon.gold { background: rgba(217, 119, 6, 0.15); color: var(--accent-gold); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

/* Badges & Pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-pill.draft { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.status-pill.formatting { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.status-pill.review { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-pill.correction { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status-pill.approved { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-pill.locked { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid #c084fc; }

.conf-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.conf-badge.green { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.conf-badge.yellow { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.conf-badge.red { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.custom-table th {
    background-color: rgba(255,255,255,0.03);
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
    vertical-align: middle;
}

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

.custom-table tr:hover {
    background-color: var(--bg-card-hover);
}

/* Modals Overlay Architecture */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    animation: modalSlideUp 0.25s ease-out;
    overflow: hidden;
}

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

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
}

.close-btn:hover {
    color: var(--accent-red);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    background: rgba(0,0,0,0.1);
}

/* Form Controls & Inputs */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    background-color: var(--bg-primary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

/* Drag & Drop OCR Zone */
.upload-dropzone {
    border: 2px dashed var(--accent-gold);
    background: rgba(217, 119, 6, 0.05);
    border-radius: 10px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-dropzone:hover {
    background: rgba(217, 119, 6, 0.1);
}

/* Symbol Grid */
.symbol-btn-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Paper Editor Container */
.editor-toolbar {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.marks-validator-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.88rem;
}

.marks-validator-box.valid {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid #10b981;
}

.marks-validator-box.invalid {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid #ef4444;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary { background-color: var(--accent-gold); color: #ffffff; }
.btn-primary:hover { background-color: var(--accent-gold-hover); }
.btn-secondary { background-color: #334155; color: #ffffff; }
.btn-secondary:hover { background-color: #475569; }
.btn-success { background-color: var(--accent-green); color: #ffffff; }
.btn-danger { background-color: var(--accent-red); color: #ffffff; }
.btn-warning { background-color: #f59e0b; color: #000000; font-weight: 700; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Section Box */
.section-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
    gap: 1rem;
    flex-wrap: wrap;
}

.question-row {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
    .sidebar {
        width: 200px;
    }
    .main-content {
        margin-left: 200px;
        width: calc(100% - 200px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .app-container {
        flex-direction: column;
    }
}

#print-render-container {
    display: none;
}
