@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* Basic fonts and Tailwind base layer rules are loaded from CDN in Jaspr */
/* Neutral ScholarFee defaults — replaced at runtime with the active
   school's primary (--brand-*) and secondary (--brand-2-*) colors by
   lib/theme/brand_theme.dart. */
:root {
  --brand-rgb: 10 10 10;
  --brand-light: #F4F4F4;
  --brand-dark: #1A1A1A;
  --brand-contrast: #FFFFFF;
  --brand-2-rgb: 64 64 64;
  --brand-2-light: #F0F0F0;
  --brand-2-dark: #303030;
  --brand-2-contrast: #FFFFFF;
}

body {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
}

/* ═══════════════════════════════════════════════════════════
   Mobile-first foundation
   ═══════════════════════════════════════════════════════════ */

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Momentum scrolling + contained overscroll for scroll regions */
.overflow-x-auto,
.overflow-y-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* iOS Safari zooms the page when a focused control's font-size is below
   16px. Force 16px on touch-sized screens so focus never triggers zoom. */
@media (max-width: 1023px) {
  input:not([type='checkbox']):not([type='radio']),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Comfortable touch targets on coarse-pointer (touch) devices.
   Applied via .tap-target so tiny decorative controls (e.g. the theme
   toggle) keep their compact size. */
@media (pointer: coarse) {
  .tap-target {
    min-height: 44px;
    min-width: 44px;
  }
  button:not(.no-tap),
  a[href],
  select,
  input:not([type='checkbox']):not([type='radio']) {
    min-height: 44px;
  }
  input[type='checkbox'],
  input[type='radio'] {
    min-width: 20px;
    min-height: 20px;
  }
}

/* Safe-area helpers for notched phones */
.pb-safe {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-safe {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.25rem);
}

/* ═══════════════════════════════════════════════════════════
   Toast notifications (see lib/services/toast_service.dart)
   ═══════════════════════════════════════════════════════════ */

#sfee-toasts {
  position: fixed;
  z-index: 100;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: min(92vw, 24rem);
  pointer-events: none;
}
@media (min-width: 1024px) {
  #sfee-toasts {
    bottom: 1.5rem;
    left: auto;
    right: 1.5rem;
    transform: none;
    align-items: flex-end;
  }
}
.sfee-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 1rem;
  background: #171717;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
  animation: toastIn 0.25s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
  cursor: pointer;
}
.sfee-toast.leaving {
  animation: toastOut 0.2s ease-in forwards;
}
.sfee-toast .sfee-toast-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  margin-top: 0.0625rem;
}
.sfee-toast-success .sfee-toast-icon { background: #10b981; color: #fff; }
.sfee-toast-error .sfee-toast-icon { background: #ef4444; color: #fff; }
.sfee-toast-info .sfee-toast-icon { background: #6366f1; color: #fff; }
.sfee-toast-loading .sfee-toast-icon {
  background: transparent;
  border: 2px solid rgb(255 255 255 / 0.3);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

/* Skeleton shimmer for loading placeholders */
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.skeleton {
  border-radius: 0.75rem;
  background: linear-gradient(90deg, #f0f0ef 25%, #e6e6e4 50%, #f0f0ef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.serif {
  font-family: "Libre Baskerville", serif;
}

.font-mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

/* ═══════════════════════════════════════════════════════════
   Animation Keyframes (replaces motion/react from React app)
   ═══════════════════════════════════════════════════════════ */

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

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slideOutLeft {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-slideUp {
  animation: slideUp 0.3s ease-out forwards;
}

.animate-slideDown {
  animation: slideDown 0.3s ease-out forwards;
}

.animate-slideInLeft {
  animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.animate-slideInRight {
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-scaleIn {
  animation: scaleIn 0.2s ease-out forwards;
}

/* Hide scrollbar utility (used in tab headers) */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Slow spin animation for refresh icon */
.animate-spin-slow {
  animation: spin 2s linear infinite;
}

/* Report-card print target — populated only at print time, hidden on screen. */
#print-root {
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   Print Styles (matching React legacy index.css exactly)
   ═══════════════════════════════════════════════════════════ */

@media print {
  /* Hide the sidebar and any print-hide elements on all pages */
  aside,
  .print-hide,
  .print\:hidden {
    display: none !important;
  }

  /* Reset layout constraints to allow flow printing */
  html, body {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    background: white !important;
    color: black !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Basic Jaspr app root resetting */
  #jaspr-app,
  #jaspr-app > div,
  main,
  main > div {
    display: block !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  /* Special receipt mode behavior */
  body.printing-receipt main > div > *:not(#receipt-portal-container) {
    display: none !important;
  }

  #receipt-portal-container {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    border: none !important;
  }

  #receipt-portal-container * {
    visibility: visible !important;
  }

  /* Special report card mode behavior */
  @page {
    size: A4;
    margin: 10mm;
  }

  /* Report-card printing clones the card(s) into #print-root, a direct child
     of <body>. Hiding every other body child isolates it cleanly no matter how
     deeply nested the source was (single preview or bulk-print modal). */
  body.printing-report-card > *:not(#print-root) {
    display: none !important;
  }

  body.printing-report-card #print-root {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
  }

  #print-root .report-page-break-after {
    page-break-after: always !important;
    break-after: page !important;
  }
  /* Avoid a trailing blank page after the final card. */
  #print-root .report-page-break-after:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .report-page-break {
    page-break-before: always !important;
    break-before: page !important;
  }

  .report-page-break-after {
    page-break-after: always !important;
    break-after: page !important;
  }

  .pos-thermal-print {
    max-width: 320px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    font-family: monospace !important;
    padding: 10px !important;
    margin: 0 auto !important;
  }

  .pos-thermal-print * {
    font-family: monospace !important;
    background: transparent !important;
    color: black !important;
    border-color: black !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Dark Mode (CSS filter inversion — matches React exactly)
   ═══════════════════════════════════════════════════════════ */

html.dark {
  filter: invert(1) hue-rotate(180deg);
  background-color: #0A0A0A;
}

html.dark body {
  background-color: #0A0A0A;
}

html.dark img, 
html.dark video, 
html.dark .no-invert {
  filter: invert(1) hue-rotate(180deg);
}

html.dark text, html.dark span, html.dark p, html.dark h1, html.dark h2, html.dark h3, html.dark h4, html.dark h5, html.dark h6 {
  -webkit-font-smoothing: antialiased;
}
