:root {
  --bg-main: #0b0c10;
  --bg-card: #121215;
  --bg-card-hover: #18181c;
  --bg-input: #1a1a1e;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.16);
  --text-main: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent-primary: #e11d48;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;
  
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===================================================
   LIGHT MODE DESIGN TOKENS (High-Contrast Clean Studio)
   =================================================== */
html.light {
  --bg-main: #f4f5f8;
  --bg-card: #ffffff;
  --bg-card-hover: #f9fafb;
  --bg-input: #f1f3f7;
  --border-subtle: rgba(0, 0, 0, 0.09);
  --border-highlight: rgba(0, 0, 0, 0.18);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --accent-primary: #e11d48;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-blue: #2563eb;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Light mode structural surface overrides */
html.light body {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

/* Header superior móvil en modo claro */
html.light .lg\:hidden.border-b.bg-\[\#0b0c10\] {
  background-color: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.04) !important;
}

/* Barra inferior móvil (Bottom App Bar) en modo claro */
html.light nav.lg\:hidden.fixed.bottom-0 {
  background-color: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06) !important;
}

html.light nav.lg\:hidden.fixed.bottom-0 .bg-zinc-900 {
  background-color: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
  color: #334155 !important;
}

html.light nav.lg\:hidden.fixed.bottom-0 .bg-rose-950\/80 {
  background-color: #ffe4e6 !important;
  border-color: #fecdd3 !important;
}

html.light nav.lg\:hidden.fixed.bottom-0 .text-zinc-400 {
  color: #64748b !important;
}

html.light nav.lg\:hidden.fixed.bottom-0 .text-zinc-400:hover {
  color: #0f172a !important;
}

html.light #sidebar {
  background-color: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.04) !important;
}

html.light #sidebar .bg-\[\#09090b\] {
  background-color: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

html.light .bg-\[\#121215\],
html.light .bg-\[\#17171c\],
html.light .bg-\[\#141418\] {
  background-color: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05) !important;
}

html.light .bg-\[\#1a1a1e\],
html.light .bg-\[\#18181c\],
html.light .bg-\[\#09090b\] {
  background-color: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

html.light input,
html.light select,
html.light textarea {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}

html.light input::placeholder,
html.light textarea::placeholder {
  color: #94a3b8 !important;
}

html.light .text-white {
  color: #0f172a !important;
}

html.light .text-zinc-100 {
  color: #0f172a !important;
}

html.light .text-zinc-200 {
  color: #1e293b !important;
}

html.light .text-zinc-300 {
  color: #334155 !important;
}

html.light .text-zinc-400 {
  color: #64748b !important;
}

html.light .text-zinc-500 {
  color: #64748b !important;
}

html.light .border-\[rgba\(255\,255\,255\,0\.08\)\],
html.light .border-\[rgba\(255\,255\,255\,0\.06\)\],
html.light .border-\[rgba\(255\,255\,255\,0\.05\)\],
html.light .border-\[rgba\(255\,255\,255\,0\.1\)\],
html.light .border-\[rgba\(255\,255\,255\,0\.12\)\] {
  border-color: rgba(0, 0, 0, 0.08) !important;
}

html.light .hover\:bg-\[rgba\(255\,255\,255\,0\.02\)\]:hover,
html.light .hover\:bg-\[rgba\(255\,255\,255\,0\.05\)\]:hover,
html.light .hover\:bg-\[rgba\(255\,255\,255\,0\.06\)\]:hover,
html.light .hover\:bg-zinc-800\/60:hover,
html.light .hover\:bg-zinc-800:hover {
  background-color: #f1f5f9 !important;
}

/* Light mode status badge tuning for crisp legibility */
html.light .bg-amber-950,
html.light .bg-amber-950\/70,
html.light .bg-amber-950\/80 {
  background-color: #fef3c7 !important;
  color: #b45309 !important;
  border-color: #fde68a !important;
}

html.light .bg-emerald-950,
html.light .bg-emerald-950\/40,
html.light .bg-emerald-950\/10 {
  background-color: #d1fae5 !important;
  color: #065f46 !important;
  border-color: #a7f3d0 !important;
}

html.light .bg-emerald-900\/60 {
  background-color: #d1fae5 !important;
  color: #065f46 !important;
  border-color: #a7f3d0 !important;
}

html.light .bg-amber-900\/60 {
  background-color: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}

html.light .bg-rose-900\/60 {
  background-color: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fca5a5 !important;
}

html.light .bg-rose-950,
html.light .bg-rose-950\/80,
html.light .bg-rose-950\/40,
html.light .bg-rose-950\/10 {
  background-color: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fca5a5 !important;
}

html.light .bg-blue-950,
html.light .bg-blue-950\/70,
html.light .bg-blue-950\/40,
html.light .bg-blue-950\/30 {
  background-color: #dbeafe !important;
  color: #1e40af !important;
  border-color: #bfdbfe !important;
}

html.light .bg-purple-950,
html.light .bg-purple-950\/40 {
  background-color: #f3e8ff !important;
  color: #6b21a8 !important;
  border-color: #e9d5ff !important;
}

/* Light mode general UI buttons & Avatars (Fix black blocks) */
html.light .bg-zinc-800,
html.light .bg-zinc-900,
html.light .bg-zinc-700 {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
}

html.light .bg-zinc-800:hover,
html.light .bg-zinc-900:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html.light .bg-zinc-800 .text-white,
html.light .bg-zinc-800 .text-zinc-200,
html.light .bg-zinc-800 .text-zinc-300 {
  color: #1e293b !important;
}

/* Fix student circular avatar contrast */
html.light .bg-zinc-800.rounded-full,
html.light .bg-zinc-800.rounded-xl,
html.light .bg-zinc-800.shrink-0 {
  background-color: #e2e8f0 !important;
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
}

/* Fix table header in light mode (High Contrast) */
html.light thead,
html.light tr.bg-\[\#17171c\]\/50,
html.light .bg-\[\#17171c\]\/50 {
  background-color: #e2e8f0 !important;
  border-bottom: 2px solid #cbd5e1 !important;
}

html.light thead th,
html.light tr.bg-\[\#17171c\]\/50 th {
  color: #1e293b !important;
  font-weight: 800 !important;
}

html.light tbody tr:hover {
  background-color: #f1f5f9 !important;
}

/* Fix Morosos row avisado highlight in Light Mode */
html.light .bg-emerald-950\/20,
html.light .bg-emerald-950\/10 {
  background-color: #ecfdf5 !important;
}

/* Fix Cronograma Cards in Light Mode */
html.light [draggable="true"].bg-rose-950\/20 {
  background-color: #fff1f2 !important;
  border-color: #fecdd3 !important;
}
html.light [draggable="true"].bg-rose-950\/20 .text-white {
  color: #9f1239 !important;
}
html.light [draggable="true"].bg-rose-950\/20 .text-zinc-300 {
  color: #881337 !important;
}

html.light [draggable="true"].bg-blue-950\/20 {
  background-color: #eff6ff !important;
  border-color: #bfdbfe !important;
}
html.light [draggable="true"].bg-blue-950\/20 .text-white {
  color: #1e40af !important;
}
html.light [draggable="true"].bg-blue-950\/20 .text-zinc-300 {
  color: #172554 !important;
}

html.light [draggable="true"].bg-emerald-950\/20 {
  background-color: #f0fdf4 !important;
  border-color: #bbf7d0 !important;
}
html.light [draggable="true"].bg-emerald-950\/20 .text-white {
  color: #166534 !important;
}
html.light [draggable="true"].bg-emerald-950\/20 .text-zinc-300 {
  color: #14532d !important;
}

/* Fix Drag & Drop placeholder border in Light Mode */
html.light .border-dashed.border-zinc-800\/60,
html.light .border-dashed.border-zinc-800 {
  border-color: #cbd5e1 !important;
  background-color: #f8fafc !important;
}
html.light .border-dashed.border-zinc-800\/60 span,
html.light .border-dashed.border-zinc-800 span {
  color: #64748b !important;
}

/* Brand logo gradient container & button overrides */
html.light .bg-gradient-to-br.from-rose-600.to-rose-700,
html.light .bg-rose-600,
html.light .bg-emerald-600,
html.light .bg-blue-600 {
  color: #ffffff !important;
}

html.light .bg-gradient-to-br.from-rose-600.to-rose-700 svg,
html.light .bg-rose-600 svg,
html.light .bg-emerald-600 svg,
html.light .bg-blue-600 svg {
  fill: #ffffff !important;
  color: #ffffff !important;
}

/* Delete / Action buttons in Light Mode */
html.light .bg-rose-950\/60,
html.light .bg-rose-900\/80 {
  background-color: #fee2e2 !important;
  color: #b91c1c !important;
  border-color: #fca5a5 !important;
}

html.light .bg-rose-950\/60:hover {
  background-color: #fecaca !important;
}

/* Smooth Global Interactive Transitions */
a, button, input, select, textarea, .branch-btn, .rango-btn {
  transition: background-color 0.2s var(--ease-smooth),
              border-color 0.2s var(--ease-smooth),
              color 0.2s var(--ease-smooth),
              box-shadow 0.2s var(--ease-smooth),
              transform 0.15s var(--ease-smooth),
              opacity 0.2s var(--ease-smooth);
}

/* Fix clickability on inner SVG icons and text nodes */
button svg, button i, button [data-lucide], a svg, a [data-lucide] {
  pointer-events: none;
}

button:active, a:active {
  transform: scale(0.97);
}

/* Custom Surface Styling & Card Transitions */
.bg-surface {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s var(--ease-smooth);
}

.bg-surface-hover:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-highlight);
  transform: translateY(-1px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.touch-target {
  min-height: 48px;
  min-width: 48px;
}

.touch-target-lg {
  min-height: 54px;
}

/* Form Input Smooth Focus Ring */
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.25) !important;
}

/* Pulse animation for alerts */
@keyframes pulse-subtle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.15); }
}

.animate-pulse-subtle {
  animation: pulse-subtle 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Smooth Modal & Backdrop Glassmorphism */
#modal-alta:not(.hidden), #modal-whatsapp:not(.hidden),
#modal-cierre-caja:not(.hidden), #modal-movimiento-caja:not(.hidden) {
  animation: backdropFadeIn 0.25s var(--ease-smooth) forwards;
}

#modal-alta:not(.hidden) > div, #modal-whatsapp:not(.hidden) > div,
#modal-cierre-caja:not(.hidden) > div, #modal-movimiento-caja:not(.hidden) > div {
  animation: modalScaleUp 0.3s var(--ease-out-quint) forwards;
}

#drawer-ficha:not(.hidden) > div {
  animation: drawerSlideIn 0.35s var(--ease-out-quint) forwards;
}

#toast:not(.hidden) {
  animation: toastSlideDown 0.3s var(--ease-out-quint) forwards;
}

/* ===================================================
   FLATPICKR CUSTOM LUXURY DARK/LIGHT DESIGN (CORE THEME)
   =================================================== */
.flatpickr-calendar {
  background: #141418 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 1rem !important;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  padding: 0.75rem !important;
  width: 310px !important;
}

.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after,
.flatpickr-calendar.arrowBottom:before,
.flatpickr-calendar.arrowBottom:after {
  display: none !important;
}

.flatpickr-months {
  margin-bottom: 0.5rem !important;
  align-items: center !important;
}

.flatpickr-months .flatpickr-month {
  color: #ffffff !important;
  fill: #ffffff !important;
  height: 38px !important;
}

.flatpickr-current-month {
  font-size: 0.875rem !important;
  font-weight: 700 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.25rem !important;
}

.flatpickr-current-month .cur-month {
  font-weight: 800 !important;
  color: #fafafa !important;
}

.flatpickr-current-month .cur-year {
  font-family: 'JetBrains Mono', monospace !important;
  font-weight: 800 !important;
  color: #fb7185 !important;
}

.flatpickr-months .flatpickr-prev-month, 
.flatpickr-months .flatpickr-next-month {
  color: #a1a1aa !important;
  fill: #a1a1aa !important;
  padding: 0.4rem !important;
  border-radius: 0.5rem !important;
  transition: all 0.15s ease !important;
}

.flatpickr-months .flatpickr-prev-month:hover, 
.flatpickr-months .flatpickr-next-month:hover {
  color: #ffffff !important;
  fill: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

span.flatpickr-weekday {
  color: #71717a !important;
  font-size: 0.6875rem !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
}

.flatpickr-day {
  border-radius: 0.625rem !important;
  color: #e4e4e7 !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  height: 36px !important;
  line-height: 36px !important;
  border: 1px solid transparent !important;
  margin: 1px !important;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
}

.flatpickr-day.today {
  border-color: rgba(225, 29, 72, 0.5) !important;
  color: #fda4af !important;
  background: rgba(225, 29, 72, 0.1) !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: linear-gradient(135deg, #e11d48, #be123c) !important;
  color: #ffffff !important;
  border-color: #f43f5e !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4) !important;
}

.flatpickr-day.prevMonthDay, 
.flatpickr-day.nextMonthDay {
  color: #3f3f46 !important;
}

/* Light mode overrides for Flatpickr */
html.light .flatpickr-calendar {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.15) !important;
}

html.light .flatpickr-current-month .cur-month {
  color: #0f172a !important;
}

html.light .flatpickr-day {
  color: #1e293b !important;
}

html.light .flatpickr-day:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

html.light .flatpickr-day.prevMonthDay, 
html.light .flatpickr-day.nextMonthDay {
  color: #cbd5e1 !important;
}

/* Universal Staggered Block Entry Animation across all views (Ultra-Smooth) */
main > section,
.caja-block-enter,
.view-block-enter {
  animation: viewBlockSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

@keyframes backdropFadeIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to { opacity: 1; backdrop-filter: blur(8px); }
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

@keyframes toastSlideDown {
  from { opacity: 0; transform: translateY(-16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Custom Scrollbar Refined */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #27272a transparent;
  scroll-behavior: smooth;
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
