/* Digital School Portal - Main Stylesheet */

/* ==== CSS VARIABLES (Dark Theme Default) ==== */
:root {
  /* Backgrounds */
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-2: #334155;
  --color-surface-3: #475569;   /* deepest panel: drawers, nested cards */
  
  /* Text */
  --color-text: #f1f5f9;
  --color-text-muted: #cbd5e1;
  --color-text-faint: #94a3b8;
  
  /* Brand Colors */
  --color-primary: #2563eb;
  --color-primary-dim: #1e40af;
  --color-primary-text: #93c5fd;
  --color-on-primary: #ffffff;
  --color-secondary: #64748b;
  --color-secondary-dim: #475569;
  --color-on-secondary: #ffffff;
  --color-accent: #ec4899;
  --color-on-accent: #111827;
  --color-surface-tint: rgba(37, 99, 235, 0.08);
  --color-surface-tint-2: rgba(236, 72, 153, 0.08);

  /* Status Colors */
  --color-success: #15803d;
  --color-success-dim: #14532d;
  --color-on-success: #ffffff;
  --color-warning: #d97706;
  --color-warning-dim: #92400e;
  --color-on-warning: #111827;
  --color-danger: #b91c1c;
  --color-danger-dim: #991b1b;
  --color-on-danger: #ffffff;
  --color-info: #1d4ed8;
  --color-on-info: #ffffff;

  /* Surface hover (for table rows, cards) */
  --color-surface-hover: var(--color-surface-2);

  /* Borders & Shadows */
  --color-border: transparent;            /* no ring in dark mode — depth via shadow */
  --color-border-input: rgba(255,255,255,0.12); /* barely-there input outline */
  --color-border-inner: rgba(255,255,255,0.05); /* subtle inner dividers (table rows) */
  --color-border-strong: #334155;         /* explicit strong divider when needed */
  --shadow-1: 0 1px 4px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-3: 0 10px 24px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255,255,255,0.04);

  /* Always-light surfaces (the auth signup / connect cards). These cards stay
     white in both themes on purpose, so their text colours are pinned here
     instead of following --color-text (which is near-white while the dark
     theme, the default, is active). */
  --color-light-surface: #ffffff;
  --color-light-surface-text: #0f172a;
  --color-light-surface-placeholder: #94a3b8;
}

/* Light theme override */
html[data-theme="light"] {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-2: #f1f5f9;
  --color-surface-3: #e2e8f0;   /* deepest panel: drawers, nested cards */
  --color-primary-text: var(--report-brand-text, #1e40af);
  --color-primary-dim: #1e40af;
  --color-secondary-dim: #94a3b8;
  --color-success-dim: #15803d;
  --color-warning-dim: #b45309;
  --color-danger-dim: #b91c1c;
  --color-surface-hover: #e2e8f0;
  --color-surface-tint: #f8fafc;
  --color-surface-tint-2: #f1f5f9;

  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-faint: #78909c;

  --color-border: #e2e8f0;
  --color-border-input: #cbd5e1;
  --color-border-inner: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-2: 0 4px 6px rgba(0, 0, 0, 0.12);
  --shadow-3: 0 10px 15px rgba(0, 0, 0, 0.16);
}

/* ==== RESET & BASE STYLES ==== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  /* min-height (not height) so long pages can grow, and 100dvh so mobile
     browsers with dynamic toolbars do not push content under the chrome.
     See static/css/mobile.css §1. */
  min-height: 100vh;
  min-height: 100dvh;
}

/* Custom Scrollbar Styles (Theme Aware) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-faint);
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==== TEXT & HEADINGS ==== */
h1, h2, h3, h4, h5, h6 {
  margin: 1em 0 0.5em 0;
  line-height: 1.2;
  font-weight: 600;
}

h1 { font-size: 2em; }
h2 { font-size: 1.75em; }
h3 { font-size: 1.5em; }
h4 { font-size: 1.25em; }
h5 { font-size: 1.1em; }
h6 { font-size: 1em; }

p { margin-bottom: 1em; }

a {
  color: var(--color-primary-text, var(--color-primary));
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-primary-dim);
}

/* ==== BUTTONS ==== */
.portal-btn-primary,
.portal-btn-secondary,
.portal-btn-danger,
.portal-btn-success,
.portal-btn-warning {
  padding: 0.5em 1.5em;
  border: none;
  border-radius: 0.375em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1em;
}

/* The theme toggle is a .tb-btn (see sidebar.css "TOPBAR"); the class is kept
   in the markup only because mobile.css keys the 44px phone tap target off it. */

.portal-btn-primary {
  background-color: var(--color-primary);
  color: var(--color-on-primary, #ffffff);
}

.portal-btn-primary:hover {
  background-color: var(--color-primary-dim);
  opacity: 0.95;
}

.portal-btn-secondary {
  background-color: var(--color-secondary);
  color: var(--color-on-secondary, #ffffff);
}

.portal-btn-secondary:hover {
  background-color: var(--color-secondary-dim);
  opacity: 0.95;
}

.portal-btn-accent {
  background-color: var(--color-accent);
  color: var(--color-on-accent, #111827);
}

.portal-btn-accent:hover {
  opacity: 0.92;
}

.portal-btn-danger {
  background-color: var(--color-danger);
  color: var(--color-on-danger, #ffffff);
}

.portal-btn-danger:hover {
  background-color: var(--color-danger-dim);
}

.portal-btn-success {
  background-color: var(--color-success);
  color: var(--color-on-success, #ffffff);
}

.portal-btn-success:hover {
  background-color: var(--color-success-dim);
}

.portal-btn-warning {
  background-color: var(--color-warning);
  color: var(--color-on-warning, #111827);
}

.portal-btn-warning:hover {
  background-color: var(--color-warning-dim);
}

/* Disabled state — applies to any portal button (e.g. modal confirm buttons) */
.portal-btn-primary:disabled,
.portal-btn-secondary:disabled,
.portal-btn-danger:disabled,
.portal-btn-success:disabled,
.portal-btn-warning:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ==== ICON BUTTONS (sidebar footer) ====
   Ghost buttons with semantic icon colors: danger (red) for Exit App,
   warning (amber) for Logout. Hover zooms the icon for affordance. */
.portal-icon-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, background-color 0.15s ease;
}
.portal-icon-btn:hover {
  transform: scale(1.18);
}
.portal-icon-btn.icon-danger {
  color: var(--color-danger, #ef4444);
}
.portal-icon-btn.icon-danger:hover {
  border-color: var(--color-danger, #ef4444);
  background: rgba(239, 68, 68, 0.1);
}
.portal-icon-btn.icon-warning {
  color: var(--color-warning, #f59e0b);
}
.portal-icon-btn.icon-warning:hover {
  border-color: var(--color-warning, #f59e0b);
  background: rgba(245, 158, 11, 0.1);
}

/* ==== CARDS ==== */
.portal-card {
  background-color: var(--color-surface);
  border: none;
  border-radius: 0.5em;
  padding: 1.5em;
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.2s ease;
}

.portal-card:hover {
  box-shadow: var(--shadow-2);
}

/* ==== TABLES ==== */
.table-responsive,
.portal-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table,
.table,
.portal-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-surface);
  box-shadow: var(--shadow-1);
  border-radius: 1rem;
  overflow: hidden;
  border: none;
  margin-bottom: 1.5rem;
}

table thead,
.table thead,
.portal-table thead {
  background-color: var(--color-surface-2);
}

table th,
table td,
.table th,
.table td,
.portal-table th,
.portal-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border-inner);
  vertical-align: middle;
  font-size: 0.95rem;
}

table th,
.table th,
.portal-table th {
  font-weight: 600;
}

table tbody tr:hover,
.table tbody tr:hover,
.portal-table tbody tr:hover {
  background-color: var(--color-surface-hover);
}

table tr:last-child td,
.table tr:last-child td,
.portal-table tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 768px) {
  table,
  .table,
  .portal-table {
    border-radius: 0.9rem;
    font-size: 0.92rem;
  }

  table th,
  table td,
  .table th,
  .table td,
  .portal-table th,
  .portal-table td {
    padding: 0.85rem 1rem;
  }

  /* Tables keep their table layout on small screens. Earlier revisions set
     `display: block; white-space: nowrap` here, which destroyed the table
     layout and clipped every table that was not inside an overflow container
     (the reported "content is cut off" bug). Horizontal scrolling belongs to
     .portal-table-wrapper / .portal-scroll-x, and stacked card rows to
     .portal-table--stack — both in static/css/mobile.css §6. */
  .portal-table-wrapper,
  .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ==== FORMS ==== */
.portal-input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  padding: 0.75em;
  border: 1px solid var(--color-border-input);
  border-radius: 0.375em;
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: 1em;
  transition: border-color 0.2s ease;
  /* Tells the browser to render native dropdown UI in the correct color scheme */
  color-scheme: dark;
}

html[data-theme="light"] .portal-input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  color-scheme: light;
}

/* Style native <option> elements so they match the portal theme */
select option,
.portal-input option {
  background-color: var(--color-surface);
  color: var(--color-text);
}

/* Keep dropdowns theme-aware even when a page supplies utility classes. */
.portal-input,
select {
  background-color: var(--color-surface) !important;
  color: var(--color-text) !important;
  color-scheme: dark;
}

html[data-theme="light"] .portal-input,
html[data-theme="light"] select {
  color-scheme: light;
}

/* Disabled options */
select option:disabled,
.portal-input option:disabled {
  color: var(--color-text-faint);
}

.portal-input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

label {
  display: block;
  margin-bottom: 0.5em;
  font-weight: 500;
  color: var(--color-text);
}

/* ==== ALWAYS-LIGHT SURFACES (auth signup / connect cards) ====
   Those cards are deliberately pinned to white in both themes. Tailwind's
   preflight injects `input { color: inherit }`, so a bare <input> on such a
   card inherits the active theme's near-white --color-text and the value the
   user types vanishes against the white background. Pin the text colours for
   text-entry controls on that surface (checkboxes, radios, ranges, files and
   buttons keep their native rendering). */
.portal-light-surface input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
.portal-light-surface select,
.portal-light-surface textarea {
  color: var(--color-light-surface-text) !important;
  background-color: var(--color-light-surface) !important;
  color-scheme: light;
}

.portal-light-surface input::placeholder,
.portal-light-surface textarea::placeholder {
  color: var(--color-light-surface-placeholder) !important;
}

/* ==== BADGES ==== */
.portal-badge {
  display: inline-block;
  padding: 0.25em 0.75em;
  border-radius: 9999px;
  font-size: 0.875em;
  font-weight: 500;
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.portal-badge-primary {
  background-color: var(--color-primary);
  color: var(--color-on-primary, #ffffff);
}

.portal-badge-success {
  background-color: var(--color-success);
  color: var(--color-on-success, #ffffff);
}

.portal-badge-danger {
  background-color: var(--color-danger);
  color: var(--color-on-danger, #ffffff);
}

/* Count bubble for work waiting on the user (pending payment proofs,
   unread notifications). Rendered only when the count is above zero. */
.portal-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  background-color: var(--color-danger, #ef4444);
  color: var(--color-on-danger, #ffffff);
}

/* The blink is the "this needs you now" signal, so it is applied per badge. */
.portal-badge-count--alert {
  animation: portalBadgeAlert 1.6s ease-in-out infinite;
}

@keyframes portalBadgeAlert {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .portal-badge-count--alert {
    animation: none;
  }
}

/* ==== LAYOUT ==== */
/* The sidebar SHELL only: a fixed column whose width the page beside it is
   offset by. Everything painted inside it lives in static/css/sidebar.css,
   which defines --sb-wide / --sb-rail / --sb-speed (the fallbacks below keep
   this file usable on its own). Because the column is fixed, widening it on
   hover paints over the content instead of reflowing it. */
.portal-sidebar {
  width: var(--sb-wide, 250px);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  transition: width var(--sb-speed, 180ms) ease;
}

/* Collapsed rail: --sb-rail is the in-flow width the page is offset by. */
.portal-sidebar.collapsed {
  width: var(--sb-rail, 64px);
}

.portal-layout-root {
  position: relative;
}

.portal-main-column {
  min-height: 100vh;
  transition: margin-left var(--sb-speed, 180ms) ease;
}

.portal-layout-root .portal-main-column {
  margin-left: var(--sb-wide, 250px);
}

/* Collapsed sidebar: shrink main area margin */
.portal-layout-root.sidebar-collapsed .portal-main-column {
  margin-left: var(--sb-rail, 64px);
}

.portal-main-area {
  margin-top: 60px;
  padding: 2em;
  min-height: calc(100vh - 60px);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.portal-topbar {
  position: fixed;
  top: 0;
  left: var(--sb-wide, 250px);
  right: 0;
  height: 60px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1em;
  gap: 1em;
  box-shadow: var(--shadow-1);
  z-index: 40;
  transition: left var(--sb-speed, 180ms) ease;
}

.portal-user-menu {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  color: var(--color-text);
}

.portal-user-avatar {
  width: 2.15rem;
  height: 2.15rem;
  flex: 0 0 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-primary);
  border-radius: 999px;
  object-fit: cover;
  background: var(--color-primary-dim);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.portal-user-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-sidebar-user-avatar {
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-secondary);
  border-radius: 999px;
  object-fit: cover;
  background: var(--color-secondary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Collapsed topbar shift */
.portal-layout-root.sidebar-collapsed .portal-topbar {
  left: var(--sb-rail, 64px);
}

.portal-sidebar-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 60;
  padding: 0.35rem 0.6rem;
  border-radius: 0.375rem;
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.portal-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  z-index: 45;
}

[x-cloak] {
  display: none !important;
}

/* Assignment filters use a real scroll viewport rather than an unbounded
   grid item. This keeps Alpine x-show filtering from changing card height. */
.assignment-selection-list {
  min-height: 18rem;
  max-height: 18rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  contain: layout paint;
}

.assignment-selection-list > [x-show] {
  min-width: 0;
}

.portal-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  /* Wide tables (sessions list, terms drawer) keep their columns readable and
     reachable via this horizontal scroll region instead of being clipped. */
  scroll-behavior: smooth;
}

.portal-table .sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: var(--color-surface-2);
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.08);
}

.portal-exam-take {
  width: 100%;
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.portal-exam-timer-warn {
  color: var(--color-danger);
}

@media (max-width: 640px) {
  .portal-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    position: fixed;
    z-index: 50;
    width: var(--sb-wide, 250px) !important; /* Always full width on mobile */
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-layout-root .portal-main-column {
    margin-left: 0 !important;
  }

  .portal-layout-root.sidebar-collapsed .portal-main-column {
    margin-left: 0 !important;
  }

  .portal-topbar {
    left: 0 !important;
    padding-left: 3rem;
    /* Ensure topbar items wrap gracefully, hide some low-priority ones */
  }

  /* Main content area: tighter padding + room for bottom nav */
  .portal-main-area {
    padding: 1rem !important;
    padding-bottom: 5.5rem !important; /* clear the bottom nav */
    margin-top: 56px;
  }

  /* Card padding reduction on mobile */
  .portal-card {
    padding: 1rem;
  }

  .portal-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
  }

  .portal-table-wrapper::-webkit-scrollbar {
    height: 10px;
  }

  .portal-table-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--color-primary);
    border-radius: 20px;
  }

  /* Modals: full-width on mobile */
  .portal-modal {
    width: 96% !important;
    padding: 1.25rem;
    max-height: 85vh;
    overflow-y: auto;
  }
}

/* ==== MOBILE BOTTOM NAVIGATION BAR ==== */
.portal-bottom-nav {
  display: none; /* hidden on desktop */
}

@media (max-width: 640px) {
  .portal-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4.25rem;
    z-index: 55;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
    align-items: stretch;
    justify-content: space-around;
    padding: 0 0.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0px); /* iPhone notch safe area */
    gap: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .portal-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0.2rem;
    padding: 0.4rem 0.2rem;
    color: var(--color-text-faint);
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: 0.75rem;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
    position: relative;
    min-width: 0;
    max-width: 5rem;
  }

  .portal-bottom-nav-item:hover,
  .portal-bottom-nav-item:focus {
    color: var(--color-primary);
    background-color: var(--color-surface-tint);
    text-decoration: none;
  }

  /* Active state: primary color + pill indicator */
  .portal-bottom-nav-item.active {
    color: var(--color-primary);
  }

  .portal-bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0.25rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2rem;
    height: 0.2rem;
    background-color: var(--color-primary);
    border-radius: 0 0 0.25rem 0.25rem;
  }

  .portal-bottom-nav-icon {
    font-size: 1.35rem;
    line-height: 1;
    display: block;
    transition: transform 0.15s ease;
  }

  .portal-bottom-nav-item.active .portal-bottom-nav-icon {
    transform: translateY(-1px);
  }

  .portal-bottom-nav-label {
    font-size: 0.6rem;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 4rem;
    display: block;
  }

  /* Haptic bounce on tap (for browsers that support it) */
  .portal-bottom-nav-item:active {
    transform: scale(0.92);
  }

  /* Print: always hide the bottom nav */
  @media print {
    .portal-bottom-nav {
      display: none !important;
    }
  }
}

/* ==== MODALS ==== */
.portal-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.portal-modal {
  background-color: var(--color-surface);
  border-radius: 0.5em;
  padding: 2em;
  max-width: 600px;
  width: 90%;
  box-shadow: var(--shadow-3);
}

/* ==== TOASTS ==== */
.portal-toast-container {
  position: fixed;
  top: 2em;
  right: 2em;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.portal-toast {
  background-color: var(--color-surface);
  border-left: 4px solid var(--color-info);
  border-radius: 0.375em;
  padding: 1em 1.5em;
  box-shadow: var(--shadow-2);
  animation: slideIn 0.3s ease;
}

.portal-toast.success { border-left-color: var(--color-success); }
.portal-toast.danger { border-left-color: var(--color-danger); }
.portal-toast.warning { border-left-color: var(--color-warning); }

@keyframes slideIn {
  from { transform: translateX(400px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(400px); opacity: 0; }
}

/* ==== HTMX INDICATORS ==== */
.htmx-indicator {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-primary);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* HTMX hidden by default */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

/* Explicit indicators (hx-indicator="#some-id") receive .htmx-request directly
   on themselves rather than on an ancestor, so cover that case too. */
.htmx-indicator.htmx-request {
  display: inline-block;
}

/* ==== SYNC SPINNER ANIMATION ==== */
.sync-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sync-spin 0.6s linear infinite;
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

/* Disabled state for sync button while syncing */
.sync-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==== UTILITY CLASSES ==== */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }

.mt-1 { margin-top: 0.5em; }
.mt-2 { margin-top: 1em; }
.mt-4 { margin-top: 2em; }

.mb-1 { margin-bottom: 0.5em; }
.mb-2 { margin-bottom: 1em; }
.mb-4 { margin-bottom: 2em; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5em; }
.gap-2 { gap: 1em; }
.gap-4 { gap: 2em; }

.grid { display: grid; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

/* ==== NOTIFICATION FEED (report tasks + alerts) ====
   Theme-aware status cards: the status is conveyed by a 4px left border on
   the design tokens, so light/dark themes and school branding always keep
   the text readable (never hardcoded Tailwind bg-*/text-* colors). */
.portal-card.feed-status-card {
  background-color: var(--color-surface-2);
  border-color: var(--color-border);
  border-left: 4px solid var(--color-info);
}
.portal-card.feed-status-card.is-completed { border-left-color: var(--color-success); }
.portal-card.feed-status-card.is-failed    { border-left-color: var(--color-danger); }

.feed-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s ease-in-out;
}
.feed-remove-btn:hover {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: rgba(239, 68, 68, 0.08);
}
