/* ==========================================================================
   SchoolMS Master Semantic UI Elevation Stylesheet
   ========================================================================== */

/* ── 0. Beautiful Custom Scrollbars ──────────────────────────────────────── */

/* ① Main page scrollbar (the browser window itself) */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-hover) transparent;
}
html::-webkit-scrollbar { width: 8px; }
html::-webkit-scrollbar-track {
  background: var(--color-base);
}
html::-webkit-scrollbar-thumb {
  background: var(--color-border-hover);
  border-radius: 99px;
  border: 2px solid var(--color-base);
}
html::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--brand-primary) 65%, var(--color-border));
}

/* ② All table overflow-x-auto wrappers — covers every table in the app */
div.overflow-x-auto,
.table-scroll-wrap {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-hover) transparent;
}
div.overflow-x-auto::-webkit-scrollbar,
.table-scroll-wrap::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}
div.overflow-x-auto::-webkit-scrollbar-track,
.table-scroll-wrap::-webkit-scrollbar-track {
  background: var(--color-surface-hover);
  border-radius: 99px;
  margin-inline: 12px;
}
div.overflow-x-auto::-webkit-scrollbar-thumb,
.table-scroll-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--brand-primary) 35%, var(--color-border));
  border-radius: 99px;
}
div.overflow-x-auto::-webkit-scrollbar-thumb:hover,
.table-scroll-wrap::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--brand-primary) 70%, var(--color-border));
}

/* ③ Sidebar nav — ghost scrollbar, appears only on hover */
.scrollbar-sidebar {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.scrollbar-sidebar:hover {
  scrollbar-color: var(--color-border) transparent;
}
.scrollbar-sidebar::-webkit-scrollbar { width: 4px; }
.scrollbar-sidebar::-webkit-scrollbar-track { background: transparent; }
.scrollbar-sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 99px;
}
.scrollbar-sidebar:hover::-webkit-scrollbar-thumb {
  background: var(--color-border);
}

/* ④ Modals / dropdowns / any other scrollable containers */
.overflow-y-auto:not(html):not(nav):not(aside),
.overflow-auto:not(html):not(nav):not(aside) {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.overflow-y-auto:not(html):not(nav):not(aside)::-webkit-scrollbar,
.overflow-auto:not(html):not(nav):not(aside)::-webkit-scrollbar { width: 4px; }
.overflow-y-auto:not(html):not(nav):not(aside)::-webkit-scrollbar-track,
.overflow-auto:not(html):not(nav):not(aside)::-webkit-scrollbar-track { background: transparent; }
.overflow-y-auto:not(html):not(nav):not(aside)::-webkit-scrollbar-thumb,
.overflow-auto:not(html):not(nav):not(aside)::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 99px;
}
.overflow-y-auto:not(html):not(nav):not(aside)::-webkit-scrollbar-thumb:hover,
.overflow-auto:not(html):not(nav):not(aside)::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}


/* ── 1. Master Sidebar Aesthetics & Depth ────────────────────────────────── */
aside#sidebar {
  background-color: var(--sidebar-bg, var(--color-surface)) !important;
  border-right: 1px solid var(--color-border);
  box-shadow: 2px 0 24px -4px rgba(0, 0, 0, 0.12);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] aside#sidebar {
  box-shadow: 2px 0 20px -4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] aside#sidebar {
  box-shadow: 4px 0 30px -4px rgba(0, 0, 0, 0.5);
}

[data-theme="ocean"] aside#sidebar {
  box-shadow: 4px 0 30px -4px rgba(2, 12, 27, 0.85);
}

/* Sidebar Logo Header */
.sidebar-logo {
  background: var(--sidebar-bg, var(--color-surface)) !important;
  border-bottom: 1px solid var(--color-border) !important;
}

/* Sidebar Section Headers / Dividers */
.sidebar-section {
  position: relative;
}

/* Sidebar Group Button Header */
.sl-group-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sl-group-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-content);
}

.sl-group-btn.active-group {
  color: var(--color-content);
  background: color-mix(in srgb, var(--brand-primary) 8%, var(--color-surface));
}

.sl-group-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--color-surface-hover);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sl-group-btn:hover .sl-group-icon {
  background: var(--color-surface-active);
  color: var(--brand-primary);
  border-color: color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

.sl-group-btn.active-group .sl-group-icon {
  background: color-mix(in srgb, var(--brand-primary) 16%, transparent);
  color: var(--brand-primary);
  border-color: color-mix(in srgb, var(--brand-primary) 40%, transparent);
  box-shadow: 0 0 12px -2px color-mix(in srgb, var(--brand-primary) 35%, transparent);
}

/* Single Sidebar Link (.sl) */
.sl {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 2px;
}

.sl:hover {
  background: var(--color-surface-hover);
  color: var(--color-content);
  box-shadow: inset 2px 0 0 0 color-mix(in srgb, var(--brand-primary) 50%, transparent);
}

.sl.active {
  background: color-mix(in srgb, var(--brand-primary) 14%, transparent) !important;
  color: var(--brand-primary) !important;
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--brand-primary), 0 2px 8px -2px color-mix(in srgb, var(--brand-primary) 25%, transparent);
}

.sl-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sl:hover .sl-icon {
  background: var(--color-surface-active);
  color: var(--brand-primary);
  border-color: color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

.sl.active .sl-icon {
  background: var(--color-surface);
  color: var(--brand-primary);
  border-color: color-mix(in srgb, var(--brand-primary) 40%, transparent);
  box-shadow: 0 0 10px -2px color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

/* Sub-links (Inside Sidebar Groups) */
.sl-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.sl-sub:hover {
  background: var(--color-surface-hover);
  color: var(--color-content);
  box-shadow: inset 2px 0 0 0 color-mix(in srgb, var(--brand-primary) 40%, transparent);
}

.sl-sub.active {
  background: color-mix(in srgb, var(--brand-primary) 12%, transparent) !important;
  color: var(--brand-primary) !important;
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--brand-primary);
}

.sl-sub::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.sl-sub:hover::before {
  opacity: 0.8;
  transform: scale(1.3);
}

.sl-sub.active::before {
  background: var(--brand-primary);
  opacity: 1;
  transform: scale(1.4);
  box-shadow: 0 0 8px var(--brand-primary);
}

/* ── 2. Top Header Glassmorphism ────────────────────────────────────────── */
header {
  background: color-mix(in srgb, var(--color-base) 85%, transparent) !important;
  backdrop-filter: blur(16px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
  border-bottom: 1px solid var(--color-border) !important;
  box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.04) !important;
}

/* ── 3. Master Button & Interactive Elevation ────────────────────────────── */
.bg-brand-600,
.btn-brand,
.btn-primary,
.site-settings-btn,
.site-settings-btn-add {
  background: linear-gradient(180deg, var(--brand-primary) 0%, color-mix(in srgb, var(--brand-primary) 90%, black) 100%) !important;
  border: 1px solid color-mix(in srgb, var(--brand-primary) 75%, black) !important;
  color: #ffffff !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 4px 12px -2px color-mix(in srgb, var(--brand-primary) 40%, transparent), inset 0 1px 0 0 rgba(255, 255, 255, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  font-weight: 600 !important;
  border-radius: 10px !important;
}

.bg-brand-600:hover:not(.absolute),
.btn-brand:hover,
.btn-primary:hover,
.site-settings-btn:hover,
.site-settings-btn-add:hover {
  transform: translateY(-1.5px) !important;
  filter: brightness(1.06) !important;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.05), 0 8px 20px -2px color-mix(in srgb, var(--brand-primary) 55%, transparent), inset 0 1px 0 0 rgba(255, 255, 255, 0.25) !important;
}

/* Suppress lift on absolutely-positioned inline buttons (e.g. icon buttons inside inputs) */
.absolute.bg-brand-600:hover {
  transform: translateY(-50%) !important; /* preserve the -translate-y-1/2 centering */
  filter: brightness(1.06) !important;
}

.bg-brand-600:active,
.btn-brand:active,
.btn-primary:active,
.site-settings-btn:active,
.site-settings-btn-add:active {
  transform: translateY(0) scale(0.98) !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 2px 6px -1px color-mix(in srgb, var(--brand-primary) 30%, transparent) !important;
}

/* Danger Buttons */
.bg-red-600,
.bg-rose-600,
.btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%) !important;
  border: 1px solid #b91c1c !important;
  color: #ffffff !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 4px 12px -2px rgba(239, 68, 68, 0.4), inset 0 1px 0 0 rgba(255, 255, 255, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  font-weight: 600 !important;
  border-radius: 10px !important;
}

.bg-red-600:hover,
.bg-rose-600:hover,
.btn-danger:hover {
  transform: translateY(-1.5px) !important;
  filter: brightness(1.06) !important;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.05), 0 8px 20px -2px rgba(239, 68, 68, 0.55), inset 0 1px 0 0 rgba(255, 255, 255, 0.25) !important;
}

.bg-red-600:active,
.bg-rose-600:active,
.btn-danger:active {
  transform: translateY(0) scale(0.98) !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(239, 68, 68, 0.3) !important;
}

/* ── 4. Card & Container Elevation ─────────────────────────────────────── */
.bg-surface,
.card {
  background-color: var(--color-surface) !important;
  border: var(--card-border) !important;
  box-shadow: var(--card-shadow) !important;
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.bg-surface:hover,
.card:hover {
  border-color: var(--color-border-hover) !important;
}

/* Stat & Metric Cards with Top Accent Glow (Applies to .stat-card, .metric-card, and all KPI grid cards) */
.stat-card,
.metric-card,
.grid > div:has(> div > .text-3xl),
.grid > a:has(> div > .text-3xl),
.grid > div:has(> p.text-3xl),
.grid > a:has(> p.text-3xl),
.grid > div:has(> .text-2xl),
.grid > a:has(> .text-2xl),
.grid > div:has(> div > .text-2xl),
.grid > a:has(> div > .text-2xl) {
  position: relative;
  background: var(--color-surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: 14px;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.stat-card::after,
.metric-card::after,
.grid > div:has(> div > .text-3xl)::after,
.grid > a:has(> div > .text-3xl)::after,
.grid > div:has(> p.text-3xl)::after,
.grid > a:has(> p.text-3xl)::after,
.grid > div:has(> .text-2xl)::after,
.grid > a:has(> .text-2xl)::after,
.grid > div:has(> div > .text-2xl)::after,
.grid > a:has(> div > .text-2xl)::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-primary), transparent);
  opacity: 0.7;
}

.stat-card:hover,
.metric-card:hover,
.grid > div:has(> div > .text-3xl):hover,
.grid > a:has(> div > .text-3xl):hover,
.grid > div:has(> p.text-3xl):hover,
.grid > a:has(> p.text-3xl):hover,
.grid > div:has(> .text-2xl):hover,
.grid > a:has(> .text-2xl):hover,
.grid > div:has(> div > .text-2xl):hover,
.grid > a:has(> div > .text-2xl):hover {
  transform: translateY(-2px);
  border-color: var(--color-border-hover) !important;
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.18);
}

/* Trend Micro-Badges */
.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

.trend-up {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.trend-down {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* ── 5. Master Table Aesthetics ────────────────────────────────────────── */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

table thead tr {
  background-color: var(--color-surface-hover) !important;
}

table thead th {
  color: var(--color-muted) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  border-bottom: 1px solid var(--color-border) !important;
  padding: 11px 16px !important;
}

table thead th:first-child {
  border-top-left-radius: 10px;
}

table thead th:last-child {
  border-top-right-radius: 10px;
}

table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

table tbody tr:last-child {
  border-bottom: none;
}

table tbody tr:hover {
  background-color: var(--color-surface-hover) !important;
}

table tbody tr:hover td:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

table tbody tr:hover td:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

table tbody td {
  padding: 12px 16px;
  color: var(--color-content);
  font-size: 13.5px;
}

/* ── 6. Form Controls & Inputs Focus Glow ───────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="time"],
select,
textarea {
  border-radius: 10px !important;
  border: 1px solid var(--color-border) !important;
  background-color: var(--color-surface) !important;
  color: var(--color-content) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

input:focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand-primary) 22%, transparent) !important;
}

/* ── 7. Living Status Badges with Pulsing Dots ──────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  line-height: 1.3;
  transition: all 0.15s ease;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.25);
}

.badge-success::before {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-warning::before {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}

.badge-danger::before {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.25);
}

.badge-info::before {
  background: #3b82f6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
}

/* ── 8. Collapsed Sidebar Active & Layout Enhancements ──────────────────── */
[data-sidebar-collapsed] aside#sidebar {
  width: 68px !important;
}

[data-sidebar-collapsed] .sl {
  padding: 0 !important;
  width: 42px !important;
  height: 42px !important;
  margin: 4px auto !important;
  justify-content: center !important;
  align-items: center !important;
  border-radius: 12px !important;
}

[data-sidebar-collapsed] .sl.active {
  background: color-mix(in srgb, var(--brand-primary) 20%, transparent) !important;
  color: var(--brand-primary) !important;
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--brand-primary) 50%, transparent), 0 4px 14px -2px color-mix(in srgb, var(--brand-primary) 40%, transparent) !important;
}

[data-sidebar-collapsed] .sl.active .sl-icon {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--brand-primary) !important;
  box-shadow: none !important;
}

[data-sidebar-collapsed] .sl-group-btn {
  display: none !important;
}

/* ── 9. Modals, Toasts & Skeleton Shimmer ───────────────────────────────── */
.modal-backdrop {
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
}

@keyframes skeleton-shimmer {
  0% { opacity: 0.5; }
  50% { opacity: 0.85; }
  100% { opacity: 0.5; }
}

.skeleton-shimmer {
  background: var(--color-surface-hover);
  border-radius: 8px;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}


