/* ============================================================
   ALMA ERP — Brand Edition — ERP Dashboards
   Sidebar/topbar shell + widgets for the Admin, Principal,
   Teacher and Student dashboards. Builds on top of the tokens
   and components already defined in style.css (clay panels,
   badges, xp-bar, rank-step, leaderboard-table) rather than
   duplicating them.
   ============================================================ */

html, body { height: 100%; }

/* AOS (scroll-animation CDN library) hides [data-aos] elements at
   opacity:0 until its JS reveals them. If that CDN is slow/blocked, or
   a layout shift below (e.g. the async-rendered charts) throws off its
   trigger-offset math, elements can stay invisible forever. Content
   must never depend on a third-party script succeeding, so force
   visible by default; AOS's own inline styles still win once/if it
   actually fires, so the animation is unaffected when things work. */
[data-aos] {
  opacity: 1 !important;
  transform: none !important;
}

/* ---------- 1. Shell layout --------------------------------------------*/

.dash-body {
  display: flex;
  min-height: 100vh;
  background: var(--clay-bg);
}

.dash-sidebar {
  width: 272px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid rgba(20, 101, 216, 0.12);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 60;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease, width 0.2s ease;
}

.dash-main {
  flex: 1;
  margin-left: 272px;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

/* Content grows to fill any leftover space so the footer (last flex child)
   always sits at the bottom of the viewport instead of riding up right
   under short/placeholder page content. */
.dash-main > main {
  flex: 1 0 auto;
}

.dash-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 15, 31, 0.5);
  z-index: 55;
}

@media (max-width: 1023px) {
  .dash-sidebar {
    transform: translateX(-100%);
    box-shadow: 16px 0 32px rgba(9, 15, 31, 0.25);
  }
  .dash-sidebar.is-open { transform: translateX(0); }
  .dash-main { margin-left: 0; }
  .dash-sidebar-backdrop.is-open { display: block; }
}

/* ---------- 2. Sidebar nav ----------------------------------------------*/

.dash-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  opacity: 0.7;
  padding: 1rem 1.25rem 0.4rem;
}

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.15rem 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.dash-nav-item i { width: 1.1rem; text-align: center; color: inherit; }
.dash-nav-item:hover { background: var(--clay-surface-mint); color: var(--color-text); }
.dash-nav-item.is-active {
  background: linear-gradient(160deg, var(--color-primary-light), var(--color-primary));
  color: #fff;
  box-shadow: 0 6px 14px rgba(11, 30, 91, 0.35);
}
.dash-nav-item.is-active:hover { transform: none; }

/* ---------- 2b. Sidebar nav groups (collapsible sub-menus) --------------*/

.dash-nav-group summary { list-style: none; cursor: pointer; }
.dash-nav-group summary::-webkit-details-marker { display: none; }
.dash-nav-group summary.dash-nav-item { justify-content: flex-start; }
.dash-nav-chevron { margin-left: auto; font-size: 0.7rem; transition: transform 0.2s ease; flex: none; width: auto; }
.dash-nav-group[open] > summary .dash-nav-chevron { transform: rotate(180deg); }
.dash-nav-subgroup { padding-left: 1.1rem; border-left: 2px solid rgba(20, 101, 216, 0.12); margin: 0.1rem 0.75rem 0.4rem 1.6rem; }
.dash-nav-subitem { font-size: 0.8rem; padding: 0.5rem 0.8rem; margin: 0.1rem 0; }

/* ---------- 2c. Sidebar collapse (desktop) -------------------------------*/

.dash-sidebar-toggle {
  align-items: center;
  gap: 0.6rem;
  margin: 0 0.75rem 0.5rem;
  padding: 0.55rem 0.9rem;
  border-radius: 0.9rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  border: 1px dashed rgba(20, 101, 216, 0.25);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dash-sidebar-toggle:hover { background: var(--clay-surface-mint); color: var(--color-text); }
.dash-sidebar-toggle-icon { transition: transform 0.2s ease; }

.dash-sidebar-collapse-all-btn { transition: background 0.15s ease, color 0.15s ease; }
.dash-sidebar-collapse-all-btn:hover { background: var(--clay-surface-mint); }

/* Scoped to lg+ only — the toggle itself is hidden below lg (see `hidden
   lg:flex` in sidebar.html), but a stale localStorage class shouldn't be
   allowed to shrink the mobile off-canvas menu if the viewport is resized
   or the page is loaded at mobile width. */
@media (min-width: 1024px) {
  body.sidebar-collapsed .dash-sidebar { width: 84px; }
  body.sidebar-collapsed .dash-main { margin-left: 84px; }
  body.sidebar-collapsed .dash-sidebar-header { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
  body.sidebar-collapsed .dash-sidebar-logo-text,
  body.sidebar-collapsed .dash-nav-label,
  body.sidebar-collapsed .dash-nav-chevron,
  body.sidebar-collapsed .dash-nav-subgroup,
  body.sidebar-collapsed .dash-sidebar-toggle-label,
  body.sidebar-collapsed .dash-sidebar-collapse-all-btn,
  body.sidebar-collapsed .dash-nav-item > *:not(i) { display: none; }
  body.sidebar-collapsed .dash-nav-item,
  body.sidebar-collapsed .dash-nav-group summary.dash-nav-item { justify-content: center; }
  body.sidebar-collapsed .dash-sidebar-toggle { justify-content: center; }
  body.sidebar-collapsed .dash-sidebar-toggle-icon { transform: rotate(180deg); }
}

/* ---------- 3. Topbar ----------------------------------------------------*/

.dash-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(20, 101, 216, 0.12);
}

.dash-icon-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--clay-surface);
  color: var(--color-primary);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: -4px -4px 10px var(--clay-shadow-light), 6px 7px 12px var(--clay-shadow-dark);
  position: relative;
  flex-shrink: 0;
}
.dash-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dash-icon-btn .dash-dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent-dark);
  border: 2px solid #fff;
}

/* ---------- 4. Stat cards & chart cards ----------------------------------*/

.stat-card-icon {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 1.1rem;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.chart-card { min-height: 1px; }
.chart-card canvas { max-width: 100%; }

/* Fixed-height wrapper so Chart.js (maintainAspectRatio:false) renders a
   stable height regardless of viewport width or browser zoom — without this
   the chart's aspect ratio scales with column width and looks stretched. */
.chart-canvas-wrap { position: relative; width: 100%; height: 240px; }
@media (min-width: 640px) { .chart-canvas-wrap { height: 280px; } }
@media (min-width: 1024px) { .chart-canvas-wrap { height: 300px; } }

/* ---------- 5. Data table -------------------------------------------------*/

.dash-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.dash-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: 0 0.75rem 0.75rem;
  font-weight: 700;
}
.dash-table td {
  padding: 0.65rem 0.75rem;
  font-size: 0.875rem;
  border-top: 1px solid rgba(20, 101, 216, 0.1);
}
.dash-table tbody tr { transition: background 0.15s ease; }
.dash-table tbody tr:hover { background: var(--clay-surface-mint); }
.dash-table tfoot td { padding: 0.65rem 0.75rem; font-size: 0.875rem; }

.dash-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.dash-field-icon { position: relative; }
.dash-field-icon > i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-ink-muted, #7C88A6);
  font-size: 0.8rem;
  pointer-events: none;
}
.dash-field-icon:has(textarea) > i { top: 1rem; transform: none; }

.password-toggle-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-ink-muted, #7C88A6);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.password-toggle-btn:hover { color: var(--color-primary, #2563EB); }

/* ---------- 6. Misc widgets -----------------------------------------------*/

/* Standalone rank medallion (style.css only defines `.rank-step .rank-medallion`,
   scoped to the homepage roadmap) so leaderboard rows here can reuse it directly. */
.rank-medallion {
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(160deg, var(--color-primary-light), var(--color-primary));
  border: 3px solid var(--clay-bg);
  box-shadow: 0 6px 14px rgba(11, 30, 91, 0.4);
  flex-shrink: 0;
}

.dash-activity-icon {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.9rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.dash-timetable-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px dashed rgba(20, 101, 216, 0.2);
}
.dash-timetable-row:last-child { border-bottom: none; }

.dash-approval-card { transition: opacity 0.25s ease, transform 0.25s ease; }
.dash-approval-card.is-resolved {
  opacity: 0;
  transform: translateX(12px) scale(0.97);
  pointer-events: none;
  height: 0;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

.dash-attendance-row.is-absent { background: rgba(196, 95, 31, 0.08); }

.dash-progress-ring { transform: rotate(-90deg); }

/* Pagination + tab buttons (Admin list/settings pages) */
.pagination-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--clay-surface);
  color: var(--color-text-muted);
}
.pagination-btn.is-active { background: var(--color-primary); color: #fff; }
.pagination-btn:disabled { opacity: 0.4; }

.tab-btn {
  padding: 0.6rem 1.1rem;
  border-radius: 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
}
.tab-btn.is-active { background: var(--color-primary); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Quick-action tile */
.dash-quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  border-radius: 1.1rem;
  background: var(--clay-surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: -4px -4px 10px var(--clay-shadow-light), 6px 7px 12px var(--clay-shadow-dark);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text);
  transition: transform 0.18s ease;
}
.dash-quick-action:hover { transform: translateY(-3px); }

/* Role-picker card (login.html) */
.role-card { cursor: pointer; }
.role-card .role-card-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .dash-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- Institute Admin dashboard: quick-action strip + colored KPI tiles.
   Neither sets `background`/`background-color` itself — a `bg-*` Tailwind
   utility supplies the color on the element, so there's no cascade fight
   with .clay's own `background` shorthand rule. ---------- */
.dash-icon-chip {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.9rem;
  display: grid;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 6px 14px rgba(9, 15, 31, 0.2);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.dash-icon-chip:hover { transform: translateY(-2px); opacity: 0.92; }

.dash-stat-tile {
  border-radius: 1.25rem;
  padding: 1.1rem 1.25rem;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: -6px -6px 14px rgba(255, 255, 255, 0.12) inset, 0 10px 22px rgba(9, 15, 31, 0.22);
}

/* ---------- Bulk-operation guard overlay ------------------------------
   Full-screen blocker shown while a bulk import/promotion/transfer/rollover
   form is submitting. These pages are a classic full-page POST (see
   dashboard.js's data-bulk-guard handler) that can take up to a few
   minutes server-side, during which the old page is otherwise still fully
   interactive — a user can click a sidebar link and navigate away mid-upload.
   This overlay sits above .dash-body (which gets `inert` + blurred) so
   clicks/focus can't reach the rest of the page; dashboard.js pairs it
   with a `beforeunload` prompt so leaving the tab needs a deliberate
   browser-native confirmation, not just an "inspect element" delete. */
.dash-body[inert] {
  filter: blur(3px) saturate(0.9);
  pointer-events: none;
  user-select: none;
}

body.bulk-guard-active {
  overflow: hidden;
}

.bulk-guard-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(11, 30, 91, 0.45);
  animation: bulkGuardFadeIn 0.2s ease-out;
}

@keyframes bulkGuardFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bulk-guard-card {
  width: min(400px, 100%);
  background: var(--clay-surface);
  border-radius: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: -10px -10px 22px var(--clay-shadow-light), 12px 14px 26px var(--clay-shadow-dark);
  padding: 2rem 1.75rem 1.75rem;
  text-align: center;
}

.bulk-guard-spinner {
  width: 68px;
  height: 68px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: var(--clay-surface);
  box-shadow: -6px -6px 14px var(--clay-shadow-light), 8px 9px 16px var(--clay-shadow-dark);
  display: grid;
  place-items: center;
  position: relative;
}

.bulk-guard-spinner::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 4px solid rgba(20, 101, 216, 0.15);
  border-top-color: #1465D8;
  animation: bulkGuardSpin 0.85s linear infinite;
}

@keyframes bulkGuardSpin {
  to { transform: rotate(360deg); }
}

.bulk-guard-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #10192E;
  margin-bottom: 0.4rem;
}

.bulk-guard-status {
  font-size: 0.8rem;
  color: #57607A;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.bulk-guard-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #E6EDFA;
  box-shadow: inset 3px 3px 6px rgba(20, 101, 216, 0.22), inset -3px -3px 6px rgba(255, 255, 255, 0.8);
}

.bulk-guard-fill {
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1465D8, #4F9BEE);
  animation: bulkGuardIndeterminate 1.4s ease-in-out infinite;
}

@keyframes bulkGuardIndeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(60%); }
  100% { transform: translateX(280%); }
}

.bulk-guard-note {
  font-size: 0.7rem;
  font-weight: 700;
  color: #1465D8;
  margin-top: 1.1rem;
}
