@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* LIGHT THEME */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: rgba(255,255,255,0.1);
    --header-bg: #ffffff;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    
    /* Layout Variables */
    --sidebar-width: 260px;
    --header-height: 70px;
}

[data-theme="dark"] {
    /* DARK THEME */
    --bg-body: #020617;
    --bg-card: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --sidebar-bg: #000000;
    --sidebar-text: #64748b;
    --sidebar-hover: rgba(255,255,255,0.05);
    --header-bg: #0f172a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

/* 100% FULL SCREEN STRICT LOCK */
html, body { height: 100%; width: 100%; overflow: hidden; background: var(--bg-body); color: var(--text-main); }
.app-wrapper { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* --- SIDEBAR --- */
.sidebar { width: var(--sidebar-width); background: var(--sidebar-bg); display: flex; flex-direction: column; transition: transform 0.3s ease, width 0.3s ease; flex-shrink: 0; z-index: 1050; border-right: 1px solid var(--border-color); height: 100vh; }
.sidebar.collapsed { width: 75px; }

.sidebar-header { height: var(--header-height); display: flex; align-items: center; padding: 0 20px; color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.05); overflow: hidden; white-space: nowrap; flex-shrink: 0; }
.sidebar-header img { transition: 0.3s; }

.sidebar-menu { padding: 10px 0; overflow-y: auto; flex: 1; }
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.menu-label { padding: 20px 20px 8px; font-size: 0.75rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.sidebar.collapsed .menu-label { display: none; }

.nav-link { display: flex; align-items: center; padding: 12px 20px; color: var(--sidebar-text); text-decoration: none; font-weight: 500; transition: 0.2s; border-left: 3px solid transparent; white-space: nowrap; overflow: hidden; gap: 12px; }
.nav-link i { font-size: 1.35rem; min-width: 25px; text-align: center; }
.nav-link:hover, .nav-link.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--primary); }
.sidebar.collapsed .nav-link span { display: none; }

/* --- MAIN WRAPPER & HEADER --- */
.main-wrapper { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--bg-body); min-width: 0; transition: margin-left 0.3s ease; }
.top-header { height: var(--header-height); background: var(--header-bg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 25px; flex-shrink: 0; z-index: 1000; width: 100%; }

.header-left, .header-right { display: flex; align-items: center; gap: 15px; }

/* Header Badges & User Profile */
.role-badge-container { display: flex; gap: 5px; flex-wrap: wrap; max-width: 55vw; overflow: hidden; height: 26px; }
.role-badge-container:hover { overflow-x: auto; overflow-y: hidden; }
.role-badge-container::-webkit-scrollbar { display: none; }

.header-btn { background: var(--bg-body); border: 1px solid var(--border-color); font-size: 1.3rem; color: var(--text-main); cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; outline: none; }
.header-btn:hover { background: var(--border-color); color: var(--primary); border-color: var(--primary); }

.session-badge { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(79, 70, 229, 0.2); padding: 8px 15px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }

.user-profile { display: flex; align-items: center; gap: 12px; padding-left: 10px; border-left: 1px solid var(--border-color); }
.user-name { font-weight: 600; color: var(--text-main); font-size: 0.95rem; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3); }

/* Mobile Only Elements (Hidden on Desktop) */
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-main); }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1040; backdrop-filter: blur(2px); }
.mobile-role-strip { display: none; }

/* --- CONTENT AREA --- */
.content-area { flex: 1; overflow-y: auto; padding: 30px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-wrap: wrap; gap: 15px; }
.page-title { font-size: 1.6rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 12px; margin: 0; }

/* --- CARDS & TABLES --- */
.card { background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border-color); padding: 25px; margin-bottom: 25px; box-shadow: var(--shadow-sm); transition: 0.3s ease; }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { font-weight: 600; font-size: 1.15rem; padding-bottom: 15px; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; color: var(--text-main); }

.table-responsive { width: 100%; overflow-x: auto; border-radius: 8px; border: 1px solid var(--border-color); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: var(--bg-card); white-space: nowrap; }
.table th, .table td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border-color); color: var(--text-main); vertical-align: middle; }
.table th { background: var(--bg-body); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); position: sticky; top: 0; z-index: 10; letter-spacing: 0.5px; }
.table tr:hover { background: var(--bg-body); }

/* --- BUTTONS & INPUTS --- */
.form-control { width: 100%; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-body); color: var(--text-main); font-size: 0.95rem; outline: none; transition: 0.2s; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: var(--bg-card); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; color: var(--text-muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: 8px; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; transition: all 0.2s ease; text-decoration: none; outline: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3); }

.btn-outline, .btn-sm { background: var(--bg-body); border: 1px solid var(--border-color); color: var(--text-muted); padding: 6px 12px; border-radius: 6px; font-size: 0.9rem; height: 32px; }
.btn-outline:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(239, 68, 68, 0.1) !important; color: var(--danger) !important; border: 1px solid rgba(239, 68, 68, 0.2) !important; }
.btn-danger:hover { background: var(--danger) !important; color: #fff !important; }
.btn-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.btn-success:hover { background: var(--success); color: #fff; }

.badge { padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.badge-blue { background: rgba(14, 165, 233, 0.1); color: #0ea5e9; border: 1px solid rgba(14, 165, 233, 0.2); }
.badge-green { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-red { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.2); }
.badge-gray { background: var(--border-color); color: var(--text-main); border: 1px solid transparent; }

/* --- GRID & UTILITIES --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }
.search-box { position: relative; width: 100%; max-width: 320px; }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.1rem; }
.search-box .form-control { padding-left: 40px; border-radius: 20px; }

/* --- EXCEL GRID (MARKS ENTRY SPECIFIC) --- */
.excel-container { overflow-x: auto; max-height: 65vh; border: 1px solid var(--border-color); border-radius: 8px; box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.excel-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-card); white-space: nowrap; }
.excel-table th, .excel-table td { border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 0; }
.excel-table th { background: var(--bg-body); color: var(--text-main); font-weight: 700; text-align: center; position: sticky; top: 0; z-index: 10; padding: 10px; }
.sticky-col { position: sticky; left: 0; background: var(--bg-card); z-index: 5; text-align: center !important; padding: 10px !important; box-shadow: 2px 0 5px rgba(0,0,0,0.05); }
.sticky-col-2 { position: sticky; left: 60px; background: var(--bg-card); z-index: 5; text-align: left !important; padding: 10px 15px !important; box-shadow: 2px 0 5px rgba(0,0,0,0.05); }
.excel-table thead th.sticky-col, .excel-table thead th.sticky-col-2 { z-index: 20; background: var(--border-color) !important; }
.excel-input { width: 100%; min-width: 65px; height: 100%; min-height: 45px; border: none; padding: 5px; text-align: center; font-weight: 600; font-size: 1rem; color: var(--text-main); outline: none; background: transparent; transition: 0.2s; }
.excel-input:focus { background: var(--primary-light); box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); }
.excel-table tbody tr:hover td { background: var(--bg-body); }
.excel-table tbody tr:hover td.sticky-col, .excel-table tbody tr:hover td.sticky-col-2 { background: var(--bg-body); }

/* --- MODALS --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 9999; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-content { background: var(--bg-card); width: 100%; max-width: 500px; border-radius: 12px; border: 1px solid var(--border-color); display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04); transform: scale(0.95); animation: scaleUp 0.2s ease forwards; }
.modal-header { padding: 20px 25px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: var(--bg-body); }
.modal-header h3 { font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin: 0; }
.close-btn { background: var(--bg-body); border: 1px solid var(--border-color); font-size: 1.2rem; color: var(--text-muted); cursor: pointer; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.close-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.2); }
.modal-body { padding: 25px; overflow-y: auto; }
.modal-footer { padding: 15px 25px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; background: var(--bg-body); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { transform: scale(0.95); } to { transform: scale(1); } }

/* ========================================================
   MOBILE RESPONSIVE RULES (Max Width 992px)
   ======================================================== */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); position: fixed; height: 100vh; z-index: 1050; }
    .sidebar.open { transform: translateX(0); }
    
    .mobile-menu-btn { display: block; }
    .role-badge-container { display: none; } /* Hide from top header */
    .hide-on-mobile { display: none; }
    
    .mobile-role-strip { 
        display: flex; overflow-x: auto; padding: 10px; 
        background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; 
        margin-bottom: 15px; gap: 5px; box-shadow: var(--shadow-sm); align-items: center;
        -webkit-overflow-scrolling: touch;
    }
    .mobile-role-strip::-webkit-scrollbar { height: 4px; }
    .mobile-role-strip::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

    .content-area { padding: 15px; }
    .card { padding: 15px; }
}
/* ========================================================
   PROFILE DROPDOWN & HEADER FIXES
   ======================================================== */
.profile-dropdown { position: relative; cursor: pointer; padding: 5px; border-radius: 8px; transition: 0.2s; }
.profile-dropdown:hover { background: var(--border-color); }
.dropdown-menu { 
    position: absolute; top: 110%; right: 0; background: var(--bg-card); 
    border: 1px solid var(--border-color); border-radius: 10px; 
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); width: 220px; 
    display: none; flex-direction: column; z-index: 2000; overflow: hidden; 
}
.profile-dropdown.active .dropdown-menu { display: flex; animation: fadeIn 0.2s ease; }
.dropdown-item { 
    padding: 12px 20px; display: flex; align-items: center; gap: 12px; 
    color: var(--text-main); text-decoration: none; font-size: 0.95rem; 
    font-weight: 500; transition: 0.2s; border-bottom: 1px solid var(--border-color); 
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); padding-left: 25px; }
.dropdown-item.text-danger:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

/* ========================================================
   DARK THEME DEEP FIXES (Inputs, Tables, Modals)
   ======================================================== */
[data-theme="dark"] .table th { background: #0f172a; border-bottom-color: #334155; }
[data-theme="dark"] .table td, [data-theme="dark"] .table th { border-color: #1e293b; }
[data-theme="dark"] .table tr:hover td { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .form-control { background: #0f172a; border-color: #334155; color: #f8fafc; }
[data-theme="dark"] .form-control:focus { background: #000; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }
[data-theme="dark"] .modal-content { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .modal-header, [data-theme="dark"] .modal-footer { background: #020617; border-color: #334155; }
[data-theme="dark"] .btn-outline { background: transparent; border-color: #334155; color: #cbd5e1; }
[data-theme="dark"] .btn-outline:hover { background: rgba(255,255,255,0.1); color: #fff; }
[data-theme="dark"] .sticky-col, [data-theme="dark"] .sticky-col-2 { background: #0f172a !important; border-color:#334155 !important; }
[data-theme="dark"] .excel-table th { background: #020617 !important; border-color:#334155 !important; }
/* ========================================================
   MOBILE SPECIFIC FIXES (Max Width 768px)
   ======================================================== */
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .search-box { max-width: 100%; }
    
    /* Excel Grid Mobile Optimizations */
    .excel-container { max-height: 75vh; }
    .sticky-col { left: 0 !important; width: 40px !important; font-size: 0.8rem !important; padding: 5px !important; }
    .sticky-col-2 { left: 40px !important; width: 110px !important; font-size: 0.85rem !important; padding: 5px 8px !important; white-space: normal !important; line-height: 1.2; }
    .excel-table thead th.sticky-col-2 { left: 40px !important; }
    .excel-input { font-size: 0.95rem; min-height: 45px; min-width: 50px; }
}