/* ============================================================
   University of Mirpurkhas AMS – Application Stylesheet
   ============================================================ */

:root {
  --ams-primary:       #1a56db;
  --ams-primary-dark:  #1245b5;
  --ams-sidebar-bg:    #0f172a;
  --ams-sidebar-hover: #1e293b;
  --ams-sidebar-text:  #cbd5e1;
  --ams-sidebar-active:#1a56db;
  --ams-navbar-bg:     #1a56db;
  --ams-sidebar-w:     250px;
  --ams-navbar-h:      58px;
  --ams-footer-h:      42px;
  --ams-radius:        0.6rem;
  --ams-shadow:        0 1px 6px rgba(0,0,0,.08);
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: .9rem;
  background: #f1f5f9;
  color: #1e293b;
}

a { color: var(--ams-primary); }
code { color: #be185d; font-size: .85em; }

/* ── Navbar ───────────────────────────────────────────────── */
.ams-navbar {
  background: var(--ams-navbar-bg) !important;
  height: var(--ams-navbar-h);
  z-index: 1040;
}

.ams-logo-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
}

/* ── Layout ───────────────────────────────────────────────── */
.ams-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--ams-navbar-h);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.ams-sidebar {
  position: fixed;
  top: var(--ams-navbar-h);
  left: 0;
  bottom: 0;
  width: var(--ams-sidebar-w);
  background: var(--ams-sidebar-bg);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .25s ease, transform .25s ease;
}

.sidebar-header {
  border-bottom-color: rgba(255,255,255,.08) !important;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 10px; }

.sidebar-nav .nav-label {
  display: block;
  padding: .55rem 1rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .52rem 1rem;
  color: var(--ams-sidebar-text);
  border-radius: 6px;
  margin: 1px 6px;
  font-size: .85rem;
  transition: background .15s, color .15s;
}

.sidebar-nav .nav-link:hover {
  background: var(--ams-sidebar-hover);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--ams-sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav .nav-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Main Content ─────────────────────────────────────────── */
.ams-main {
  margin-left: var(--ams-sidebar-w);
  flex: 1;
  min-height: calc(100vh - var(--ams-navbar-h) - var(--ams-footer-h));
  transition: margin-left .25s ease;

  /*
   * Bootstrap 5.3 introduced color-mode CSS vars. When the OS is in
   * dark mode (or Bootstrap inherits stale vars from a dark ancestor),
   * --bs-body-color-rgb flips to ~white, making text-muted / text-secondary
   * nearly invisible on the light content background. Lock these to
   * light-mode values so all soft badges and muted text stay readable.
   */
  --bs-body-color:          #212529;
  --bs-body-color-rgb:      33, 37, 41;
  --bs-secondary-rgb:       108, 117, 125;
  --bs-secondary-color:     rgba(108, 117, 125, 0.75);
  --bs-secondary-color-rgb: 108, 117, 125;
  --bs-tertiary-color:      rgba(33, 37, 41, 0.5);
  --bs-emphasis-color:      #000;
  --bs-emphasis-color-rgb:  0, 0, 0;
}

/* ── Footer ───────────────────────────────────────────────── */
.ams-footer {
  margin-left: var(--ams-sidebar-w);
  height: var(--ams-footer-h);
  transition: margin-left .25s ease;
}

/* ── Sidebar Collapsed ────────────────────────────────────── */
body.sidebar-collapsed .ams-sidebar {
  width: 64px;
}
body.sidebar-collapsed .sidebar-nav .nav-label,
body.sidebar-collapsed .sidebar-nav .nav-link span,
body.sidebar-collapsed .sidebar-header div { display: none; }
body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; gap: 0; padding: .55rem; }
body.sidebar-collapsed .sidebar-nav .nav-link i { width: auto; }
body.sidebar-collapsed .ams-main,
body.sidebar-collapsed .ams-footer { margin-left: 64px; }

/* ── Login Page ───────────────────────────────────────────── */
.ams-login-bg {
  background: linear-gradient(135deg, #1a56db 0%, #0f172a 100%);
  min-height: 100vh;
}

.ams-login-logo {
  width: 80px; height: 80px;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: #fff;
  margin: 0 auto;
}

/* ── UMPK Logo ────────────────────────────────────────────── */
/* Navbar logo – white bg pill keeps logo visible on dark bar */
.ams-navbar img.umpk-nav-logo {
  width: 34px; height: 34px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}

/* Sidebar logo */
.ams-sidebar img.umpk-sidebar-logo {
  width: 32px; height: 32px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}

/* Credential fill animation */
@keyframes credFill {
  0%   { background-color: transparent; }
  40%  { background-color: rgba(26,86,219,.12); }
  100% { background-color: transparent; }
}
.filling { animation: credFill .45s ease; }

/* ── Cards & Stats ────────────────────────────────────────── */
.stat-card { transition: transform .15s, box-shadow .15s; cursor: pointer; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12) !important; }

.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Tables ───────────────────────────────────────────────── */
/*
 * Explicit contrast values prevent the "invisible text" bug that
 * appears when Bootstrap's CSS variable defaults are inherited
 * from a dark ancestor (e.g. dark cards, dark sidebar bleed-in).
 * These override Bootstrap 5 table CSS vars at the .table level
 * so all descendants (th, td) pick them up automatically.
 */
.table {
  --bs-table-bg:            #ffffff;
  --bs-table-color:         #212529;
  --bs-table-border-color:  #dee2e6;
  --bs-table-striped-bg:    rgba(0, 0, 0, .025);
  --bs-table-striped-color: #212529;
  --bs-table-active-bg:     rgba(0, 0, 0, .05);
  --bs-table-active-color:  #212529;
  --bs-table-hover-bg:      rgba(26, 86, 219, .04);
  --bs-table-hover-color:   #212529;
}

/* Thead: slightly off-white background so headers read as headers */
.table > thead > tr > th,
.table > thead > tr > td {
  background-color: #f8fafc;
  color: #1e293b;
  border-bottom: 2px solid #dee2e6;
}

/* Body cells: always white-on-dark-text regardless of parent bg */
.table > tbody > tr > td,
.table > tbody > tr > th {
  background-color: var(--bs-table-bg, #ffffff);
  color: var(--bs-table-color, #212529);
}

/* Preserve Bootstrap dark-table variant readability */
.table-dark {
  --bs-table-bg:            #212529;
  --bs-table-color:         #ffffff;
  --bs-table-border-color:  #373b3e;
  --bs-table-striped-bg:    rgba(255, 255, 255, .05);
  --bs-table-striped-color: #ffffff;
  --bs-table-hover-bg:      rgba(255, 255, 255, .075);
  --bs-table-hover-color:   #ffffff;
}
.table-dark > thead > tr > th,
.table-dark > thead > tr > td {
  background-color: #343a40;
  color: #ffffff;
  border-bottom-color: #373b3e;
}
.table-dark > tbody > tr > td,
.table-dark > tbody > tr > th {
  background-color: var(--bs-table-bg, #212529);
  color: var(--bs-table-color, #ffffff);
}

.table th { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.table td { vertical-align: middle; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-xs {
  padding: .2rem .55rem;
  font-size: .75rem;
  border-radius: .3rem;
}

.quick-btn { transition: transform .1s, box-shadow .1s; }
.quick-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.1); }

/* ── Avatar ───────────────────────────────────────────────── */
.ams-avatar-sm {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--ams-primary), #7c3aed);
  color: #fff; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Notifications ────────────────────────────────────────── */
.notification-panel { max-height: 380px; overflow-y: auto; }
.notif-item { padding: .65rem 1rem !important; }
.notif-item.unread { background: #eff6ff; border-left: 3px solid var(--ams-primary); }
.notif-item:hover { background: #f0f4ff; }

/* ── Attendance Sheet ─────────────────────────────────────── */
.exam-sheet-table td, .exam-sheet-table th {
  font-size: .8rem;
  padding: .5rem .6rem;
}

/* ── Student Chips (Present-All) ──────────────────────────── */
.student-chip {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: .5rem .6rem;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  user-select: none;
}
.student-chip.present { border-color: #22c55e; background: #f0fdf4; }
.student-chip.absent  { border-color: #ef4444; background: #fef2f2; }
.student-chip.absent .present-icon,
.student-chip.present .absent-icon { display: none; }
.chip-status { font-size: .9rem; margin-top: .2rem; }

/* ── Misc ─────────────────────────────────────────────────── */
.border-start.border-4 { border-left-width: 4px !important; }

.nav-tabs .nav-link { font-size: .85rem; }

/* Scrollbars for main content */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Print Styles ─────────────────────────────────────────── */
@media print {
  .ams-navbar, .ams-sidebar, .ams-footer,
  .btn, .alert, form, .card-header, nav { display: none !important; }
  .ams-main { margin-left: 0 !important; }
  .ams-layout { padding-top: 0; }
  body { background: white; font-size: 11pt; }
  .table-success { background: #d4edda !important; -webkit-print-color-adjust: exact; }
  .table-warning { background: #fff3cd !important; -webkit-print-color-adjust: exact; }
  .table-danger  { background: #f8d7da !important; -webkit-print-color-adjust: exact; }
  .badge { border: 1px solid currentColor; }
  .card { border: 1px solid #dee2e6 !important; box-shadow: none !important; }
}

/* ── Responsive: Mobile ───────────────────────────────────── */
@media (max-width: 767.98px) {
  .ams-sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-open .ams-sidebar {
    transform: translateX(0);
  }
  .ams-main, .ams-footer {
    margin-left: 0 !important;
  }
  .ams-sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1025;
  }
  body.sidebar-open .ams-sidebar-overlay { display: block; }
}

/* ── Per-column search row ────────────────────────────────── */
.col-search-row th {
  padding: .25rem .35rem;
  background: #f8fafc;
}
.col-search-row .form-control-sm {
  font-size: .75rem;
  padding: .2rem .4rem;
  height: auto;
}
