/* ==========================================================================
   JustautoExamPortal — shared design system (light theme, corporate blue)
   Loaded as a plain stylesheet (no build step) on top of Bootstrap 5.
   ========================================================================== */

:root {
  --brand-primary: #1d4ed8;
  --brand-primary-dark: #1e3a8a;
  --brand-primary-light: #dbeafe;
  --surface: #ffffff;
  --surface-muted: #f4f6fb;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --accent-blue: #1d4ed8;
  --accent-green: #16a34a;
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .07);
  --shadow: 0 2px 6px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 40px -10px rgba(15, 23, 42, .18), 0 8px 16px -8px rgba(15, 23, 42, .1);
  --sidebar-width: 268px;
  --topbar-height: 64px;

  /* Light sidebar shell */
  --sidebar-bg: #ffffff;
  --sidebar-border: var(--border);
  --sidebar-text: var(--text-muted);
  --sidebar-text-active: var(--brand-primary);
  --sidebar-hover-bg: var(--surface-muted);
  --sidebar-active-bg: var(--brand-primary-light);

  --bs-primary: var(--brand-primary);
  --bs-primary-rgb: 29, 78, 216;
  --bs-link-color: var(--brand-primary);
  --bs-link-hover-color: var(--brand-primary-dark);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--surface-muted);
  --bs-border-color: var(--border);
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

}

/* Bootstrap components (modal, dropdown, list-group, popover, accordion) each redeclare their own
   --bs-*-bg variable INSIDE their own component selector (e.g. ".modal{--bs-modal-bg:var(--bs-body-bg)}"),
   which beats a plain :root override on specificity. Since --bs-body-bg above is the page's muted
   tone, every one of these would otherwise render with the same low-contrast grey — so the fix has
   to target each component selector directly, not just the variable at :root. */
.modal-content, .dropdown-menu, .list-group-item, .popover, .accordion-item, .accordion-body {
  background-color: var(--surface);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--bs-font-sans-serif);
  background: var(--surface-muted);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }

/* Individual pages wrap their content in Bootstrap's .container, which has a
   fixed max-width and centers itself — fine on a full browser page, but inside
   the already-offset .main-content (sidebar takes 268px) it leaves a large dead
   gap on wide screens. The admin shell's own <main> padding is enough, so make
   .container behave like .container-fluid there. */
.main-content .container {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

/* ============ Buttons ============ */
.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: .9rem; padding: .4rem .9rem; transition: all .15s ease; line-height: 1.5; }
.btn-sm { border-radius: 7px; font-size: .8rem; padding: .28rem .65rem; }
.btn-lg { padding: .55rem 1.2rem; font-size: 1rem; }
.btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); }
.btn-outline-primary { color: var(--brand-primary); border-color: var(--brand-primary); }
.btn-outline-primary:hover { background: var(--brand-primary); border-color: var(--brand-primary); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-secondary { background: var(--text-muted); border-color: var(--text-muted); }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--surface-muted); border-color: var(--text-muted); color: var(--text); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-info:hover { filter: brightness(0.92); color: #fff; }
.btn-light { background: var(--surface-muted); border-color: var(--border); color: var(--text); }
.btn-light:hover { background: var(--border); }
.btn-dark { background: var(--text); border-color: var(--text); }
.btn-dark:hover { filter: brightness(1.2); }
.btn-link { color: var(--brand-primary); }
.btn:focus, .btn:focus-visible { box-shadow: 0 0 0 .2rem var(--brand-primary-light); }

/* ============ Cards / panels ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.5rem; }

/* ============ Tables ============ */
.table { --bs-table-bg: var(--surface); vertical-align: middle; font-size: .875rem; }
.table thead th {
  background: var(--surface-muted); color: var(--text-muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-responsive { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive .table { margin-bottom: 0; }
.table-responsive thead tr:first-child th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.table-responsive thead tr:first-child th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
.table > :not(caption) > * > * { border-bottom-width: 1px; border-color: var(--border); }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:nth-of-type(even) { background: rgba(15, 23, 42, .012); }
.table tbody tr:hover { background: var(--brand-primary-light); }
.table tbody td, .table thead th { padding: .75rem 1rem; }
.table tbody td { color: var(--text); }

/* ============ Table search box ============ */
.search-box { position: relative; max-width: 360px; margin-bottom: 1rem; width: 100%; }
.search-box input.form-control { padding-left: 2.35rem; }
.search-box i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .95rem; pointer-events: none; }
@media (max-width: 575.98px) { .search-box { max-width: 100%; } }

/* On narrow screens a wide table's first column (usually the row's identity —
   name, date, title) stays pinned while the rest scrolls underneath it, so you
   never lose track of which row you're looking at. */
@media (max-width: 767.98px) {
  .table-responsive thead th:first-child,
  .table-responsive tbody td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface); box-shadow: 1px 0 0 var(--border);
  }
  .table-responsive thead th:first-child { background: var(--surface-muted); z-index: 2; }
}

/* ============ Forms ============ */
.form-control, .form-select {
  background-color: var(--surface);
  border-radius: var(--radius-sm); border-color: var(--border); padding: .6rem .85rem;
  font-size: .9rem; transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:hover, .form-select:hover { border-color: var(--text-muted); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary); box-shadow: 0 0 0 .2rem var(--brand-primary-light);
}
.form-control::placeholder { color: var(--text-muted); opacity: .75; }
.form-control:disabled, .form-control[readonly], .form-select:disabled {
  background: var(--surface-muted); color: var(--text); border-color: var(--border); opacity: 1;
}
.form-check-input {
  background-color: var(--surface); border: 1px solid var(--text-muted);
}
.form-check-input:checked {
  background-color: var(--brand-primary); border-color: var(--brand-primary);
}
.form-check-input:focus {
  border-color: var(--brand-primary); box-shadow: 0 0 0 .2rem var(--brand-primary-light);
}
.form-switch .form-check-input { background-color: var(--border); }
.form-switch .form-check-input:checked { background-color: var(--brand-primary); }
label, .form-label { font-weight: 500; font-size: .875rem; color: var(--text); margin-bottom: .35rem; }
.select2-container--default .select2-selection--single {
  border-radius: var(--radius-sm) !important; border-color: var(--border) !important; height: calc(2.4rem + 2px) !important;
  background-color: var(--surface) !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 2.4rem !important; font-size: .9rem; color: var(--text) !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 2.4rem !important; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--brand-primary) !important; box-shadow: 0 0 0 .2rem var(--brand-primary-light);
}
.select2-dropdown { border-color: var(--border) !important; border-radius: var(--radius-sm) !important; box-shadow: var(--shadow-lg); overflow: hidden; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background-color: var(--brand-primary) !important; }
.select2-search--dropdown .select2-search__field { border-radius: var(--radius-sm) !important; border-color: var(--border) !important; padding: .4rem .6rem !important; }

/* ============ Badges / alerts ============ */
.badge { font-weight: 600; padding: .4em .65em; border-radius: 6px; }
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ============ Toast notifications (replaces plain JS alert()) ============ */
.toast-stack {
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 2000;
  display: flex; flex-direction: column; gap: .6rem; max-width: min(360px, calc(100vw - 2rem));
}
.app-toast {
  display: flex; align-items: flex-start; gap: .65rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .8rem 1rem;
  font-size: .875rem; color: var(--text);
  opacity: 0; transform: translateX(20px); transition: opacity .2s ease, transform .2s ease;
}
.app-toast--show { opacity: 1; transform: translateX(0); }
.app-toast i { font-size: 1.1rem; margin-top: .1rem; flex-shrink: 0; }
.app-toast--success { border-left-color: var(--success); } .app-toast--success i { color: var(--success); }
.app-toast--danger { border-left-color: var(--danger); } .app-toast--danger i { color: var(--danger); }
.app-toast--warning { border-left-color: var(--warning); } .app-toast--warning i { color: var(--warning); }
.app-toast--info { border-left-color: var(--info); } .app-toast--info i { color: var(--info); }
.app-toast__msg { flex-grow: 1; line-height: 1.4; }
.app-toast__close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0; }
.app-toast__close:hover { color: var(--text); }

/* ============ Autofill normalization (Chrome/Safari tint suggested/saved fields) ============ */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--surface) inset;
  box-shadow: 0 0 0px 1000px var(--surface) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* ============ Page header ============ */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-header h1, .page-header h4 { margin: 0; font-weight: 700; font-size: 1.35rem; }

/* ============ Admin shell: sidebar + topbar ============ */
.sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); }
.sidebar .offcanvas-header { border-bottom: 1px solid var(--sidebar-border) !important; }
.sidebar .offcanvas-title { color: var(--text); }
.sidebar-brand {
  height: var(--topbar-height); display: flex; align-items: center; gap: .65rem;
  padding: 0 1.25rem; border-bottom: 1px solid var(--sidebar-border); font-weight: 700; font-size: 1.02rem; color: var(--text);
}
.sidebar-brand .brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-primary), #3b82f6);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem;
  box-shadow: 0 4px 10px rgba(29, 78, 216, .3);
}
.sidebar-nav { padding: 1rem .75rem; flex-wrap: nowrap !important; width: 100%; }
.sidebar-section-label {
  color: var(--text-muted); font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; padding: .5rem .8rem .35rem;
}
.sidebar .nav-link {
  color: var(--sidebar-text) !important; border-radius: var(--radius-sm); padding: .62rem .85rem; margin: .2rem 0;
  font-size: .9rem; font-weight: 500; display: flex; align-items: center; gap: .7rem; transition: all .15s ease;
  position: relative;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: var(--sidebar-hover-bg); color: var(--text) !important; }
.sidebar .nav-link.active {
  background: var(--sidebar-active-bg); color: var(--sidebar-text-active) !important; font-weight: 600;
}
.sidebar .nav-link.active::before {
  content: ''; position: absolute; left: -.75rem; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand-primary); border-radius: 0 2px 2px 0;
}

.topbar { height: var(--topbar-height); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .btn-icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar-circle {
  width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-primary), #3b82f6); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
  box-shadow: 0 3px 8px rgba(29, 78, 216, .3);
}

.main-content { min-height: 100vh; }

@media (min-width: 768px) {
  #sidebarMenu.offcanvas {
    position: sticky; top: 0; height: 100vh; transform: none !important; visibility: visible !important;
    box-shadow: none; border-right: 1px solid var(--sidebar-border);
    width: var(--sidebar-width);
  }
  #sidebarMenu .offcanvas-header { display: none; }
}
@media (max-width: 767.98px) {
  #sidebarMenu.offcanvas { width: min(84vw, 300px); }
}

/* ============ Split-screen auth layout ============ */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .auth-shell { grid-template-columns: 1fr 1fr; } }
.auth-brand-panel {
  display: none; position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--brand-primary-dark), var(--brand-primary));
  color: #fff; padding: 3rem; flex-direction: column; justify-content: space-between;
}
.auth-brand-panel::before {
  content: ''; position: absolute; inset: 0; opacity: .5; pointer-events: none;
  background: radial-gradient(circle at 85% 80%, rgba(59, 130, 246, .45), transparent 55%);
}
.auth-brand-panel > * { position: relative; z-index: 1; }
@media (min-width: 900px) { .auth-brand-panel { display: flex; } }
.auth-brand-panel .brand-mark {
  width: 48px; height: 48px; border-radius: 13px;
  background: rgba(255, 255, 255, .15);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.25rem;
}
.auth-form-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--surface-muted); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-card h1, .auth-card h4 { font-weight: 700; font-size: 1.4rem; margin-bottom: .25rem; }
.auth-card .subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* ============ Stat cards (dashboard) ============ */
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.25rem; display: flex; align-items: center; gap: 1rem; position: relative; overflow: hidden; transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--stat-color, var(--brand-primary)); }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: color-mix(in srgb, var(--stat-color, var(--brand-primary)) 14%, white); color: var(--stat-color, var(--brand-primary)); flex: 0 0 auto;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); }
.stat-card--blue { --stat-color: var(--accent-blue); }
.stat-card--green { --stat-color: var(--accent-green); }
.stat-card--amber { --stat-color: var(--accent-amber); }
.stat-card--purple { --stat-color: var(--accent-purple); }

/* ============ Student portal top-nav ============ */
.public-nav { background: var(--surface); border-bottom: 1px solid var(--border); }
.public-nav .navbar-brand { font-weight: 700; color: var(--text) !important; display: flex; align-items: center; gap: .55rem; }

/* ============ Holiday calendar ============ */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-dow { text-align: center; font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding-bottom: 4px; }
.calendar-cell {
  min-height: 68px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  padding: 6px; text-align: left; font: inherit; display: flex; flex-direction: column;
}
.calendar-cell--empty { border: none; background: transparent; }
.calendar-cell--open { cursor: pointer; transition: all .12s ease; }
.calendar-cell--open:hover { background: var(--brand-primary-light); border-color: var(--brand-primary); }
.calendar-cell--today { border-color: var(--brand-primary); border-width: 2px; }
.calendar-cell--holiday { background: var(--brand-primary-light); border-color: var(--brand-primary); }
.calendar-daynum { font-weight: 600; font-size: .85rem; }
.calendar-label { font-size: .7rem; color: var(--brand-primary-dark); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-remove { background: none; border: none; color: var(--danger); font-size: 1rem; line-height: 1; padding: 0 2px; cursor: pointer; }
@media (max-width: 575.98px) {
  .calendar-grid { gap: 3px; }
  .calendar-cell { min-height: 46px; padding: 4px; }
  .calendar-dow { font-size: .6rem; }
  .calendar-label { display: none; }
}
