/* ==============================================================
   FLN System - Components (cards, stat tiles, tables, buttons, login)
============================================================== */

/* ---------- Generic cards ---------- */
.card {
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
  padding: 14px 18px;
}
.card-body { padding: 18px; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-card {
  border: none; border-radius: var(--radius-md); padding: 20px 22px;
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-card i.bg-icon { position: absolute; right: 14px; bottom: 4px; font-size: 3.4rem; opacity: .2; transform: rotate(-8deg); }
/* Explicit override: base.css's global "h1-h6 { color: var(--text-main) }" rule
   directly targets this h2, which beats the inherited white from .stat-card above
   (same root cause as the login header fix) - without this, KPI numbers rendered
   as dark navy text on colorful gradient backgrounds, hard to read on several cards. */
.stat-card h2 { font-weight: 800; margin-bottom: 2px; font-size: 1.9rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.15); }
.stat-card .label { font-size: .84rem; opacity: .92; font-weight: 500; letter-spacing: .01em; }

.bg-slab1 { background: linear-gradient(135deg, var(--slab1), var(--slab1-dark)); }
.bg-slab2 { background: linear-gradient(135deg, var(--slab2), var(--slab2-dark)); }
.bg-slab3 { background: linear-gradient(135deg, var(--slab3), var(--slab3-dark)); }
.bg-primary-grad { background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary)); }
.bg-info-grad { background: linear-gradient(135deg, var(--info), var(--info-dark)); }

.badge-slab1 { background: var(--slab1); }
.badge-slab2 { background: var(--slab2); }
.badge-slab3 { background: var(--slab3); }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  border: none;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-primary-light), var(--brand-primary)); box-shadow: var(--shadow-sm); }
.btn-success { background: linear-gradient(135deg, var(--slab3), var(--slab3-dark)); border: none; }
.btn-warning { background: linear-gradient(135deg, var(--slab2), var(--slab2-dark)); border: none; color: #fff; }
.btn-warning:hover { color: #fff; }
.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-flash-success { background: linear-gradient(135deg, var(--slab3), var(--slab3-dark)) !important; }

/* ---------- Login ---------- */
.login-wrapper {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--brand-primary-light) 0%, var(--brand-primary-dark) 55%, #08222c 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-wrapper::before, .login-wrapper::after {
  content: ""; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.login-wrapper::before { width: 420px; height: 420px; top: -140px; right: -120px; }
.login-wrapper::after { width: 280px; height: 280px; bottom: -100px; left: -80px; background: rgba(242,165,65,.12); }

.login-card {
  max-width: 420px; width: 100%; border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
  animation: flnFadeIn var(--transition-slow) both;
}
.login-card .card-header {
  background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary));
  color: #fff; text-align: center; padding: 32px 20px; border-radius: 0;
}
/* Explicit override: the global "h1-h6 { color: var(--text-main) }" rule in base.css
   directly targets this h4, which beats the inherited white from .card-header above
   (a direct match always wins over an inherited value) - without this, the app name
   rendered as dark navy text on this dark gradient background, unreadable. */
.login-card .card-header h4 { color: #fff; }
.login-card .card-header i { font-size: 2.8rem; color: var(--brand-accent); filter: drop-shadow(0 4px 10px rgba(0,0,0,.25)); }
.login-card .card-body { padding: 30px; }
.login-card .input-group-text { background: #f4f7f9; border-right: none; color: var(--text-muted); }
.login-card input.form-control { border-left: none; }
.login-card .input-group:focus-within { box-shadow: 0 0 0 3px rgba(30,95,116,.15); border-radius: var(--radius-sm); }

/* ---------- Tables ---------- */
.table-report { border-radius: var(--radius-sm); overflow: hidden; }
.table-report th, .table-report td { vertical-align: middle; text-align: center; font-size: .9rem; padding: 10px 12px; }
.table-report thead th { background: var(--brand-primary-dark); color: #fff; font-weight: 600; border: none; }
.table-report tbody tr { transition: background var(--transition-fast); }
.table-report tbody tr:nth-child(odd) { background: #f8fafb; }
.table-report tbody tr:hover { background: #eef6f8; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: #dbe2e8;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary-light);
  box-shadow: 0 0 0 3px rgba(30,95,116,.12);
}
.form-label { font-weight: 600; color: #3c4753; margin-bottom: 6px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); border: none; }
.alert-light { background: #f6f8fa; }

/* Export toolbar */
.export-toolbar .btn { border-radius: var(--radius-sm); font-weight: 600; }

/* ---------- Utility fade / hover-lift for generic cards on hover ---------- */
.hover-lift { transition: transform var(--transition-base), box-shadow var(--transition-base); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* ==============================================================
   Timeline / Task widget (dashboard + student My Result page)
============================================================== */
.timeline-widget .card-body { padding: 14px 18px; }
.timeline-list {
  list-style: none; margin: 0; padding: 0 2px 0 0;
  max-height: 400px; /* tuned to comfortably fit ~5 entries before scrolling */
  overflow-y: auto;
  scroll-behavior: smooth;
}
.timeline-list::-webkit-scrollbar { width: 6px; }
.timeline-list::-webkit-scrollbar-thumb { background: #d7dee2; border-radius: 3px; }
.timeline-list::-webkit-scrollbar-thumb:hover { background: #b9c4ca; }

.timeline-item {
  position: relative;
  padding: 6px 4px 18px 24px;
  border-left: 2px solid var(--border-soft);
}
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 2px; }
.timeline-dot {
  position: absolute; left: -7px; top: 9px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #cfd8dd; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-soft);
  transition: all var(--transition-fast);
}
.timeline-item-current { border-left-color: var(--brand-accent); }
.timeline-item-current .timeline-dot {
  background: var(--brand-accent);
  width: 14px; height: 14px; left: -8px; top: 8px;
  box-shadow: 0 0 0 5px rgba(214,134,42,.16);
}
.timeline-item-current .timeline-content {
  background: linear-gradient(135deg, #fff9ef, #fff3e0);
  border: 1px solid #f2dcb8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-left: -4px;
  box-shadow: 0 1px 3px rgba(214,134,42,.12);
}
.timeline-current-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  color: #8a5a17; background: #ffe6bf; border-radius: 20px;
  padding: 2px 9px; margin-bottom: 4px;
}
/* Past (already-ended) tasks stay visible but visually recede - muted text,
   subdued dot, small "done" badge - so the list can show a school's/CRC's whole
   task history without the finished items competing for attention with what's
   current or upcoming. */
.timeline-item-past .timeline-dot { background: #dfe4e7; box-shadow: 0 0 0 1px var(--border-soft); }
.timeline-item-past .timeline-text { color: var(--text-muted); font-weight: 500; }
.timeline-past-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  color: #5a6b74; background: #eef2f4; border-radius: 20px;
  padding: 2px 9px; margin-bottom: 4px;
}
.timeline-text { font-weight: 600; font-size: .92rem; color: var(--text-main); line-height: 1.35; }
.timeline-dates { margin-top: 3px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }

/* ==============================================================
   વિધાન પત્રક (statement-level detail report) - vertical/rotated
   topic headers, matching the standard FLN remedial-sheet layout,
   with a numbered sub-row (1,2,3...) directly beneath the topics.
============================================================== */
.vidhan-patrak-table {
  table-layout: fixed;
}
.vidhan-patrak-table th.vidhan-header-cell {
  height: 170px;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  padding: 6px 2px;
  vertical-align: bottom;
}
.vidhan-header-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  margin: 0 auto;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.3;
}
.vidhan-patrak-table th.vidhan-no-cell {
  font-weight: 700;
  background: var(--brand-accent);
  color: #fff;
  width: 34px;
  min-width: 34px;
}
/* ક્રમ / નામ get their own fixed widths; કુલ ગુણ (last column) is capped at exactly
   2x a single topic column (34px * 2 = 68px) so it never balloons wider than the
   rest, no matter how long "કુલ ગુણ" looks un-rotated. */
.vidhan-patrak-table th:first-child, .vidhan-patrak-table td:first-child {
  width: 36px;
}
.vidhan-patrak-table th:nth-child(2), .vidhan-patrak-table td:nth-child(2) {
  width: 150px;
}
.vidhan-patrak-table th:last-child, .vidhan-patrak-table td:last-child {
  width: 68px;
  max-width: 68px;
}

/* ==============================================================
   Dashboard Quick Actions - big tappable shortcuts (mobile-first,
   so small-screen users never have to open the side menu just to
   reach their most-used page, e.g. Mark Entry).
============================================================== */
.quick-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.quick-action-tile {
  flex: 0 0 auto;
  width: 108px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
  text-decoration: none;
  text-align: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  border: 1px solid var(--border-soft);
}
.quick-action-tile i { font-size: 1.6rem; color: var(--brand-primary); }
.quick-action-tile span { font-size: .76rem; font-weight: 600; line-height: 1.15; }
.quick-action-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); color: var(--text-main); }
.quick-action-tile:active { transform: scale(.96); }

/* The single most important action per role (e.g. Mark Entry for teachers) stands
   out with a solid brand color instead of the plain white tile. */
.quick-action-tile.qa-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  border-color: transparent;
  color: #fff;
}
.quick-action-tile.qa-primary i { color: var(--brand-accent); }
.quick-action-tile.qa-primary:hover { color: #fff; }

/* New/notable features get their own distinct color (not the brand teal used for
   qa-primary) plus a small "NEW" badge, so they actually stand out in the row
   instead of blending in with everything else - e.g. Target Analysis (Principal),
   Re-evaluation Analysis (Admin). */
.quick-action-tile.qa-new {
  background: linear-gradient(135deg, #8e44ad, #5f2d73);
  border-color: transparent;
  color: #fff;
  position: relative;
  overflow: visible;
}
.quick-action-tile.qa-new i { color: #ffd54f; }
.quick-action-tile.qa-new:hover { color: #fff; }
.quick-action-tile.qa-new::after {
  content: "NEW";
  position: absolute;
  top: -7px;
  right: -7px;
  background: #e74c3c;
  color: #fff;
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}

/* Dashboard top section: Quick Actions + KPI cards take 70% width on the left,
   Timeline takes 30% on the right - a precise split Bootstrap's 12-column grid
   can't express exactly (8/4 only gives 66/33), so it's custom flex-basis here.

   IMPORTANT: this 70/30 split is of .main-content's width, which is already
   "whatever's left after the sidebar" (.app-sidebar is a fixed 264px flex
   sibling, .main-content is flex:1 - see .app-wrapper in layout.css). But that
   means the breakpoint for switching from stacked-mobile to side-by-side-desktop
   can't just be Bootstrap's usual 992px: at exactly 992px viewport, remaining
   width after the 264px sidebar + main-content's own padding is only ~665px,
   which splits into a cramped ~465px/~185px - not a usable 30% column. 1300px
   leaves enough remaining room (~950px+) for the 30% column to stay comfortably
   readable (~280px+) once the sidebar has actually been subtracted. */
@media (min-width: 1300px) {
  .dash-top-row { display: flex; gap: 1rem; align-items: flex-start; }
  .dash-col-left { flex: 0 0 70%; max-width: 70%; min-width: 0; }
  .dash-col-right { flex: 0 0 30%; max-width: 30%; min-width: 0; }
}
@media (max-width: 1299.98px) {
  .dash-col-left, .dash-col-right { width: 100%; }
}

@media (max-width: 575.98px) {
  .quick-action-tile { width: 92px; padding: 12px 6px; }
  .quick-action-tile i { font-size: 1.4rem; }
  .quick-action-tile span { font-size: .72rem; }
}

/* ==============================================================
   ON/OFF toggle switch for Active/Inactive status - replaces the
   old "Active"/"Inactive" text button, which was ambiguous (does
   clicking it show current state, or change it?). A slid-right,
   green switch unambiguously reads as "on"; slid-left, gray reads
   as "off" - no label needed, and it auto-submits on change.
============================================================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  vertical-align: middle;
}
.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  margin: 0;
  pointer-events: none;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #c9d0d4;
  border-radius: 24px;
  transition: background var(--transition-fast, .15s);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform var(--transition-fast, .15s);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--slab3, #2f9e44);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}
.toggle-switch input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(46,204,113,.35);
}
