/* =====================================================================
   Chaitanya Deemed University Admin — chaitanya.edu.in palette
   navy primary · maroon accent · gold highlights · white surfaces
   ===================================================================== */
:root {
  --navy:        #0a2157;
  --navy-dark:   #071840;
  --navy-light:  #163882;
  --accent:      #9b1c2e;
  --accent-dark: #7a1524;
  --gold:        #c9a84c;
  --bg:          #f4f6fb;
  --surface:     #ffffff;
  --text:        #1e2b45;
  --text-muted:  #6b7a99;
  --border:      #d6dce8;
  --green:       #1f9d55;
  --green-bg:    #e7f6ee;
  --red:         #d93025;
  --red-bg:      #fdecea;
  --shadow:      0 1px 3px rgba(10,33,87,.08), 0 1px 2px rgba(10,33,87,.06);
  --radius:      10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--navy-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--navy);
  color: #cdd6e8;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 20px 18px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  letter-spacing: .3px;
  line-height: 1.3;
}
.sidebar .brand span { color: var(--gold); }
.sidebar .brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-close { display: none; background: none; border: none; color: #cdd6e8; cursor: pointer; padding: 4px; }
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: #cdd6e8;
  font-weight: 500;
}
.sidebar nav a .icon { opacity: .85; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a:hover .icon { opacity: 1; }
.sidebar nav a.active {
  background: var(--navy-dark);
  color: #fff;
  border-left: 4px solid var(--accent);
  padding-left: 16px;
}
.sidebar nav a.active .icon { opacity: 1; color: var(--gold); }
.sidebar .sb-foot { padding: 16px 20px; font-size: 12px; color: #8295bb; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar h1 { font-size: 19px; margin: 0; color: var(--navy); }
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.breadcrumb .icon { opacity: .6; }
.hamburger {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--navy); cursor: pointer; flex-shrink: 0;
}
.hamburger:hover { background: #f0f3fa; }
.topbar .who { color: var(--text-muted); font-size: 14px; display: flex; align-items: center; gap: 10px; }
.topbar .who a { color: var(--accent-dark); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.content { padding: 26px; }
.sb-overlay { display: none; }

/* ---- Cards & KPIs ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 18px; margin-bottom: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.kpi .label { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 32px; font-weight: 700; color: var(--navy); margin-top: 6px; }
.kpi.present .value { color: var(--green); }
.kpi.absent  .value { color: var(--red); }
.kpi.accent  .value { color: var(--accent-dark); }

/* ---- Panel ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 16px; color: var(--navy); }
.panel-body { padding: 20px; }

/* ---- Tables ---- */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: #f0f3fa; color: var(--navy); font-size: 13px; text-transform: uppercase; letter-spacing: .3px; }
table.data tr:hover td { background: #fafbfe; }

/* ---- Attendance register grid (month view) ---- */
.reg-scroll { overflow-x: auto; }
table.reg-table th, table.reg-table td { padding: 8px 6px; white-space: nowrap; }
table.reg-table th.reg-day { text-align: center; font-size: 11px; padding: 8px 3px; }
td.reg-cell { text-align: center; font-weight: 700; font-size: 12px; padding: 8px 2px; }
td.reg-cell.present { background: var(--green-bg); color: var(--green); }
td.reg-cell.absent  { background: var(--red-bg);   color: var(--red); }
td.reg-cell.pending { color: var(--text-muted); }
td.reg-cell.future  { background: #f7f8fb; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.present { background: var(--green-bg); color: var(--green); }
.badge.absent  { background: var(--red-bg);   color: var(--red); }
.badge.pending { background: #fff3e0; color: var(--accent-dark); }
.badge.muted   { background: #eef1f7; color: var(--text-muted); }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px; }
label.field { display: block; font-size: 13px; }
label.field span { display: block; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(28,64,144,.12); }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }

/* ---- Buttons ---- */
.btn { display: inline-block; padding: 10px 18px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); text-decoration: none; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: #eef1f7; color: var(--navy); }
.btn-ghost:hover { background: #e2e7f2; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: var(--red-bg); color: var(--red); }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.success { background: var(--green-bg); color: var(--green); }
.flash.error   { background: var(--red-bg);   color: var(--red); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 18px 40px rgba(0,0,0,.25); width: 100%; max-width: 400px; padding: 34px; }
.login-card .logo { text-align: center; margin-bottom: 8px; font-size: 18px; font-weight: 800; color: var(--navy); }
.login-card .logo span { color: var(--gold); }
.login-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 8px; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--text-muted); }
#map { height: 320px; border-radius: 10px; border: 1px solid var(--border); }
.help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.btn .icon { vertical-align: -3px; margin-right: 4px; }

/* ---- Page head (title + count + inline help) ---- */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.count-pill { background: #eef1f7; color: var(--navy); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }

/* ---- Inline help tooltip ---- */
.help-icon { display: inline-flex; color: var(--text-muted); cursor: help; vertical-align: -3px; }
.help-icon:hover { color: var(--navy-light); }
.field-label { display: flex; align-items: center; gap: 5px; }
.required-note { font-size: 12px; color: var(--text-muted); margin: -6px 0 14px; }
.required-note .req { color: var(--accent); }

/* ---- Empty state ---- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { color: var(--border); width: 44px; height: 44px; }
.empty-state strong { color: var(--text); font-size: 15px; }
.empty-state p { margin: 0; font-size: 13px; max-width: 320px; }

/* ---- Toast-style flash messages ---- */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--green);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(10,33,87,.16); padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; font-weight: 500;
  animation: toast-in .18s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast .icon:first-child { flex-shrink: 0; margin-top: 1px; }
.toast.success .icon:first-child { color: var(--green); }
.toast.error .icon:first-child { color: var(--red); }
.toast-msg { flex: 1; }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
/* Static (non-JS) flash — used on forms/login */
.flash { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.success { background: var(--green-bg); color: var(--green); }
.flash.error   { background: var(--red-bg);   color: var(--red); }

/* ---- Confirm modal (replaces native confirm()) ---- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,20,45,.45);
  align-items: center; justify-content: center; z-index: 2000; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-box { background: #fff; border-radius: 12px; max-width: 380px; width: 100%; padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.3); text-align: center; }
.modal-box .icon-wrap { width: 48px; height: 48px; border-radius: 50%; background: var(--red-bg); color: var(--red); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.modal-box h3 { margin: 0 0 8px; font-size: 16px; color: var(--navy); }
.modal-box p { margin: 0 0 20px; font-size: 13.5px; color: var(--text-muted); }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { flex: 1; }

/* ---- Attendance mini bar-chart ---- */
.attendance-bar { display: flex; height: 22px; border-radius: 999px; overflow: hidden; background: #eef1f7; width: 100%; }
.attendance-bar .seg { height: 100%; }
.attendance-bar .seg.present { background: var(--green); }
.attendance-bar .seg.absent  { background: var(--red); margin-left: 2px; }
.attendance-bar .seg.pending { background: #c7cede; margin-left: 2px; }
.attendance-legend { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
.attendance-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.attendance-legend .dot.present { background: var(--green); }
.attendance-legend .dot.absent  { background: var(--red); }
.attendance-legend .dot.pending { background: #c7cede; }
.attendance-legend strong { color: var(--text); }
.mini-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #eef1f7; width: 90px; }
.mini-bar .seg.present { background: var(--green); }
.mini-bar .seg.absent { background: var(--red); margin-left: 1px; }

/* ---- Sortable table headers ---- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable .icon { opacity: .45; }
th.sortable:hover .icon { opacity: .9; }
th.sortable.sorted .icon { opacity: 1; color: var(--gold); }

/* ---- Password visibility toggle ---- */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; display: flex; }
.pw-toggle:hover { color: var(--navy); }

/* ---- Scope tag pickers (admin_form.php) ---- */
.tag-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 8px; }
.tag-check {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500;
  background: #f8f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; cursor: pointer;
}
.tag-check:has(input:checked) { background: #eef3ff; border-color: var(--navy-light); }
.tag-check input { margin: 0; accent-color: var(--navy); }

/* ---- Callout ---- */
.callout { display: flex; gap: 10px; background: #f0f3fa; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--text); margin-bottom: 16px; }
.callout .icon { color: var(--navy-light); flex-shrink: 0; margin-top: 1px; }

@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1500;
    transform: translateX(-100%); transition: transform .2s ease-out; width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand, .sidebar nav a span, .sidebar .sb-foot { display: flex; }
  .sidebar .brand span { display: inline; }
  .sidebar-close { display: inline-flex; }
  .sb-overlay.open { display: block; position: fixed; inset: 0; background: rgba(10,20,45,.4); z-index: 1400; }
  .toast-stack { left: 12px; right: 12px; max-width: none; }
}

@media print {
  .sidebar, .topbar, .toolbar, .toast-stack, .modal-backdrop, .btn, .page-head .count-pill + .btn { display: none !important; }
  .content { padding: 0; }
  .panel { box-shadow: none; border: none; }
  body { background: #fff; }
}
