/* =============================================================
   Smart Shiksha — Report Pages Theme (Bootstrap 5.3)
   -------------------------------------------------------------
   Premium SaaS-style UI for reports_stu/* and reports_trans/* pages.
   - Light & Dark mode via body.dark-mode / [data-theme="dark"]
   - Filter Card, floating labels, chip radios, sticky toolbar
   - Summary cards, active-filter badges, skeleton/empty states
   - Does NOT alter any input name/id/class/data-* — purely visual.
   ============================================================= */

/* ---------- Design tokens ---------- */
:root {
  --rt-bg: #f1f5f9;
  --rt-surface: #ffffff;
  --rt-surface-2: #f8fafc;
  --rt-border: #e2e8f0;
  --rt-border-strong: #cbd5e1;
  --rt-text: #0f172a;
  --rt-muted: #64748b;
  --rt-primary: #2563eb;
  --rt-primary-rgb: 37, 99, 235;
  --rt-primary-soft: rgba(37, 99, 235, 0.10);
  --rt-success: #10b981;
  --rt-success-soft: rgba(16, 185, 129, 0.10);
  --rt-warning: #f59e0b;
  --rt-warning-soft: rgba(245, 158, 11, 0.10);
  --rt-danger: #ef4444;
  --rt-danger-soft: rgba(239, 68, 68, 0.10);
  --rt-info: #0ea5e9;
  --rt-info-soft: rgba(14, 165, 233, 0.10);
  --rt-purple: #8b5cf6;
  --rt-purple-soft: rgba(139, 92, 246, 0.10);
  --rt-radius-sm: 8px;
  --rt-radius: 12px;
  --rt-radius-lg: 16px;
  --rt-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --rt-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --rt-shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12);
  --rt-transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode .rt-page,
[data-theme="dark"] .rt-page {
  --rt-bg: #0f172a;
  --rt-surface: #1e293b;
  --rt-surface-2: #172033;
  --rt-border: #334155;
  --rt-border-strong: #475569;
  --rt-text: #e2e8f0;
  --rt-muted: #94a3b8;
  --rt-primary-soft: rgba(37, 99, 235, 0.18);
  --rt-success-soft: rgba(16, 185, 129, 0.18);
  --rt-warning-soft: rgba(245, 158, 11, 0.18);
  --rt-danger-soft: rgba(239, 68, 68, 0.18);
  --rt-info-soft: rgba(14, 165, 233, 0.18);
  --rt-purple-soft: rgba(139, 92, 246, 0.18);
  --rt-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --rt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --rt-shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
}

/* ---------- Page wrapper ---------- */
.rt-page {
  font-family: inherit;
  color: var(--rt-text);
  animation: rtFadeIn 0.3s ease both;
}

@keyframes rtFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Breadcrumb ---------- */
.rt-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--rt-muted);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.rt-breadcrumb a {
  color: var(--rt-muted);
  text-decoration: none;
  transition: color var(--rt-transition);
}
.rt-breadcrumb a:hover { color: var(--rt-primary); }
.rt-breadcrumb .rt-breadcrumb-sep { opacity: 0.5; }
.rt-breadcrumb .rt-breadcrumb-current { color: var(--rt-text); font-weight: 600; }

/* ---------- Report header ---------- */
.rt-report-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: linear-gradient(135deg, var(--rt-surface) 0%, var(--rt-surface-2) 100%);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--rt-shadow);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.rt-report-icon {
  --rt-accent: var(--rt-primary);
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: var(--rt-radius);
  font-size: 1.5rem;
  color: var(--rt-accent);
  background: color-mix(in srgb, var(--rt-accent) 12%, transparent);
}

.rt-report-info { flex: 1; min-width: 200px; }

.rt-report-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 0.2rem;
  line-height: 1.3;
}

.rt-report-desc {
  font-size: 0.85rem;
  color: var(--rt-muted);
  margin: 0;
}

.rt-report-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--rt-muted);
  flex-wrap: wrap;
}

.rt-report-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.rt-report-meta-item i { font-size: 0.85rem; }

/* ---------- Summary cards ---------- */
.rt-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.rt-summary-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--rt-surface);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--rt-shadow);
  transition: transform var(--rt-transition), box-shadow var(--rt-transition);
}

.rt-summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--rt-shadow-md);
}

.rt-summary-icon {
  --rt-accent: var(--rt-primary);
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 1.15rem;
  color: var(--rt-accent);
  background: color-mix(in srgb, var(--rt-accent) 12%, transparent);
}

.rt-summary-body { min-width: 0; }
.rt-summary-value { font-size: 1.3rem; font-weight: 800; line-height: 1.1; }
.rt-summary-label { font-size: 0.72rem; color: var(--rt-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Filter card ---------- */
.rt-filter-card {
  background: var(--rt-surface);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius-lg);
  box-shadow: var(--rt-shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.rt-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--rt-border);
  flex-wrap: wrap;
}

.rt-filter-head-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
}

.rt-filter-head-title i { color: var(--rt-primary); }

.rt-filter-head-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rt-filter-body { padding: 1.25rem; }

/* ---------- Filter grid ---------- */
.rt-filter-grid {
  display: grid;
  /* Self-balancing: every row is always filled with equal-width fields for
     ANY number of filters — 4 fields → one equal row, 3 → three equal
     columns, 5/6 → a full second row, and a lone field (Generate-only
     reports) spans the full width. Conditional fields that hide/show just
     reflow, so no per-page span bookkeeping is needed. */
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 1rem;
}

.rt-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }

.rt-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rt-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.rt-field-label i { font-size: 0.8rem; }

/* Generate / action buttons stretch to match the inputs beside them so
   every field in the row stays visually aligned and the card looks
   symmetric regardless of how many fields a report has. */
.rt-filter-grid .rt-field > .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 38px;
  border-radius: var(--rt-radius-sm);
  font-weight: 600;
  transition: all var(--rt-transition);
}
.rt-filter-grid .rt-field > .btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--rt-shadow-md);
}

/* Dark mode for inputs */
body.dark-mode .rt-page .form-control,
body.dark-mode .rt-page .form-select,
[data-theme="dark"] .rt-page .form-control,
[data-theme="dark"] .rt-page .form-select {
  background-color: var(--rt-surface-2);
  border-color: var(--rt-border);
  color: var(--rt-text);
}
body.dark-mode .rt-page .form-control:focus,
body.dark-mode .rt-page .form-select:focus,
[data-theme="dark"] .rt-page .form-control:focus,
[data-theme="dark"] .rt-page .form-select:focus {
  border-color: var(--rt-primary);
  box-shadow: 0 0 0 3px var(--rt-primary-soft);
}

/* ---------- Date range pair ---------- */
.rt-date-pair {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rt-date-pair .form-control { flex: 1; min-width: 0; }
.rt-date-sep {
  font-size: 0.75rem;
  color: var(--rt-muted);
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- Field controls (generic input pairs, e.g. date range) ---------- */
.rt-field-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}
.rt-field-controls > .form-control,
.rt-field-controls > .form-select {
  flex: 1 1 0;
  min-width: 0;
}
.rt-field-sep {
  font-size: 0.72rem;
  color: var(--rt-muted);
  font-weight: 600;
  flex-shrink: 0;
  text-transform: lowercase;
}

/* ---------- Symmetric 6-column filter grid (optional modifier) ----------
   Add .cols-6 to .rt-filter-grid and span the fields with .rt-span-2/.rt-span-3/
   .rt-span-6 so rows always balance regardless of how many filters a report has.
   Rows fill exactly 6 columns: 2+2+2 (three equal fields) or 3+3 (two equal). */
.rt-filter-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.rt-filter-grid.cols-6 .rt-span-2 { grid-column: span 2; }
.rt-filter-grid.cols-6 .rt-span-3 { grid-column: span 3; }
.rt-filter-grid.cols-6 .rt-span-6 { grid-column: span 6; }
/* Class multi-select fills its field so the symmetric row stays balanced. */
.rt-filter-grid.cols-6 .rt-cms { max-width: none; }

/* ---------- Generate / Preview action button ---------- */
.rt-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 38px;
  font-weight: 600;
  border-radius: var(--rt-radius-sm);
  transition: all var(--rt-transition);
}
.rt-preview-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--rt-shadow-md);
}
.rt-preview-btn i { font-size: 0.95rem; }

/* ---------- Chip radio group ---------- */
.rt-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.rt-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rt-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--rt-text);
  background: var(--rt-surface);
  cursor: pointer;
  transition: all var(--rt-transition);
  user-select: none;
  white-space: nowrap;
}

.rt-chip:hover {
  border-color: var(--rt-primary);
  color: var(--rt-primary);
  transform: translateY(-1px);
}

.rt-chip input[type="radio"],
.rt-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.rt-chip input[type="radio"]:checked + .rt-chip-label,
.rt-chip input[type="checkbox"]:checked + .rt-chip-label {
  color: #fff;
}

.rt-chip:has(input:checked) {
  background: var(--rt-primary);
  border-color: var(--rt-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--rt-primary-rgb), 0.3);
}

.rt-chip:has(input:checked) .rt-chip-label { color: #fff; }

.rt-chip i { font-size: 0.85rem; }

/* Fallback for browsers without :has() */
.rt-chip.active {
  background: var(--rt-primary);
  border-color: var(--rt-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--rt-primary-rgb), 0.3);
}

/* ---------- Advanced filters collapse ---------- */
.rt-advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--rt-primary);
  background: transparent;
  border: 0;
  padding: 0.3rem 0;
  cursor: pointer;
  transition: color var(--rt-transition);
}
.rt-advanced-toggle:hover { text-decoration: underline; }
.rt-advanced-toggle i { transition: transform var(--rt-transition); }
.rt-advanced-toggle[aria-expanded="true"] i { transform: rotate(180deg); }

/* ---------- Active filter badges ---------- */
.rt-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--rt-border);
  background: var(--rt-surface-2);
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, min-height 0.3s ease;
  padding-top: 0;
  padding-bottom: 0;
  border-top: 0;
}

.rt-active-filters.show {
  min-height: 48px;
  max-height: 200px;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--rt-border);
}

.rt-active-filters-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rt-muted);
  margin-right: 0.25rem;
}

.rt-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--rt-primary-soft);
  color: var(--rt-primary);
  border: 1px solid transparent;
  transition: all var(--rt-transition);
  animation: rtBadgeIn 0.2s ease both;
}

@keyframes rtBadgeIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.rt-filter-badge .rt-badge-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.65rem;
  transition: background var(--rt-transition);
}
.rt-filter-badge .rt-badge-remove:hover {
  background: rgba(var(--rt-primary-rgb), 0.2);
}

/* ---------- Sticky action toolbar ---------- */
.rt-toolbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--rt-surface);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius);
  padding: 0.6rem 0.85rem;
  box-shadow: var(--rt-shadow-md);
  margin-bottom: 1rem;
  flex-wrap: wrap;
  backdrop-filter: blur(8px);
}

.rt-toolbar .btn {
  border-radius: var(--rt-radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--rt-transition);
}

.rt-toolbar .btn:hover { transform: translateY(-1px); }

/* ---------- Buttons ---------- */
.rt-page .btn-primary {
  background: var(--rt-primary);
  border-color: var(--rt-primary);
}
.rt-page .btn-primary:hover {
  background: color-mix(in srgb, var(--rt-primary) 88%, black);
  border-color: color-mix(in srgb, var(--rt-primary) 88%, black);
}

/* ---------- Report output area ---------- */
.rt-output {
  background: var(--rt-surface);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius-lg);
  box-shadow: var(--rt-shadow);
  min-height: 300px;
  overflow: hidden;
}

.rt-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--rt-border);
  font-size: 0.85rem;
  font-weight: 700;
}

.rt-output-body { padding: 1.25rem; }

/* ---------- Loading / skeleton ---------- */
.rt-skeleton {
  background: linear-gradient(90deg, var(--rt-surface-2) 25%, var(--rt-border) 50%, var(--rt-surface-2) 75%);
  background-size: 200% 100%;
  animation: rtShimmer 1.5s infinite;
  border-radius: var(--rt-radius-sm);
}

@keyframes rtShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.rt-skeleton-line { height: 14px; margin-bottom: 0.6rem; border-radius: 6px; }
.rt-skeleton-line:last-child { margin-bottom: 0; width: 60%; }

/* ---------- Empty state ---------- */
.rt-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--rt-muted);
}
.rt-empty-state i {
  font-size: 3rem;
  opacity: 0.35;
  display: block;
  margin-bottom: 0.8rem;
}
.rt-empty-state h5 { font-weight: 700; color: var(--rt-text); margin-bottom: 0.3rem; }
.rt-empty-state p { font-size: 0.85rem; max-width: 380px; margin: 0 auto; }

/* ---------- Toast container ---------- */
.rt-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---------- Selectpicker / Select2 dark mode fixes ---------- */
body.dark-mode .rt-page .bootstrap-select .dropdown-menu,
[data-theme="dark"] .rt-page .bootstrap-select .dropdown-menu {
  background-color: var(--rt-surface);
  border-color: var(--rt-border);
}
body.dark-mode .rt-page .bootstrap-select .dropdown-item,
[data-theme="dark"] .rt-page .bootstrap-select .dropdown-item {
  color: var(--rt-text);
}
body.dark-mode .rt-page .bootstrap-select .dropdown-item:hover,
[data-theme="dark"] .rt-page .bootstrap-select .dropdown-item:hover {
  background-color: var(--rt-primary-soft);
}
body.dark-mode .rt-page .bootstrap-select .bs-searchbox .form-control,
[data-theme="dark"] .rt-page .bootstrap-select .bs-searchbox .form-control {
  background-color: var(--rt-surface-2);
  border-color: var(--rt-border);
  color: var(--rt-text);
}

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
  .rt-filter-grid,
  .rt-filter-grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
  /* On the 2-column tablet layout an odd-count last field (3/5/7-field
     reports) spans the full row so the card stays balanced. */
  .rt-filter-grid > .rt-field:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .rt-filter-grid.cols-6 .rt-span-2,
  .rt-filter-grid.cols-6 .rt-span-3,
  .rt-filter-grid.cols-6 .rt-span-6 { grid-column: span 2; }
  .rt-summary-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767.98px) {
  .rt-filter-grid,
  .rt-filter-grid.cols-6 { grid-template-columns: 1fr; }
  .rt-filter-grid.cols-6 .rt-span-2,
  .rt-filter-grid.cols-6 .rt-span-3,
  .rt-filter-grid.cols-6 .rt-span-6 { grid-column: span 1; }
  .rt-summary-row { grid-template-columns: repeat(2, 1fr); }
  .rt-report-header { padding: 1rem; }
  .rt-toolbar { position: static; }
  .rt-toolbar .btn span { display: none; }
  .rt-toolbar .btn { padding: 0.45rem 0.6rem; }
  .rt-report-title { font-size: 1.1rem; }
}

@media (max-width: 575.98px) {
  .rt-summary-row { grid-template-columns: 1fr; }
  .rt-date-pair { flex-direction: column; align-items: stretch; }
  .rt-date-sep { display: none; }
  .rt-field-controls { flex-direction: column; align-items: stretch; }
  .rt-field-controls .rt-field-sep { display: none; }
}

/* ---------- Print styles ---------- */
@media print {
  .rt-toolbar, .rt-filter-card, .rt-report-header, .rt-breadcrumb, .rt-summary-row { display: none !important; }
  .rt-output { border: 0; box-shadow: none; }
}