:root {
  /* Dark theme base */
  --bg-deep: #090d16;
  --bg-surface: #0f172a;
  --card-bg: rgba(22, 31, 50, 0.88);
  --card-border: rgba(255, 255, 255, 0.1);
  --card-hover: rgba(30, 41, 69, 0.95);
  
  /* Text */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Antonio Theme (ESO - Cyan & Indigo Neon) */
  --antonio-accent: #38bdf8;
  --antonio-glow: rgba(56, 189, 248, 0.4);
  --antonio-dark: #0369a1;

  /* Eduardo Theme (Primaria - Emerald & Gold Neon) */
  --eduardo-accent: #10b981;
  --eduardo-glow: rgba(16, 185, 129, 0.4);
  --eduardo-dark: #047857;

  /* Subject Color Palette */
  --c-mates: #0284c7;        /* Matemáticas / STEAM */
  --c-lengua: #059669;       /* Lengua */
  --c-sociales: #d97706;     /* CC. Sociales */
  --c-naturales: #65a30d;    /* CC. Naturales / Cono Medio */
  --c-ingles: #4f46e5;       /* Inglés */
  --c-frances: #0284c7;      /* Francés */
  --c-edfisica: #e11d48;     /* Educación Física */
  --c-robotica: #9333ea;     /* Robótica */
  --c-plastica: #db2777;     /* Plástica / Arte */
  --c-musica: #ca8a04;       /* Música */
  --c-religion: #0d9488;     /* Religión */
  --c-tutoria: #475569;      /* Tutoría */
  --c-recreo: #334155;       /* Recreo */

  /* Base root font size (will be overridden by media queries for 1080p TV and 4K) */
  font-size: 16px;
}

/* ==========================================================================
   SCALING FOR FULL HD TV, 2K & 4K SCREENS (70" LG webOS)
   ========================================================================== */

/* Full HD Screens / Standard 1080p TV */
@media (min-width: 1600px) and (min-height: 850px) {
  :root {
    font-size: 20px;
  }
}

/* Big Full HD 1080p / 2K TV (e.g. 1920x1080 native webOS full screen) */
@media (min-width: 1850px) and (min-height: 980px) {
  :root {
    font-size: 23px;
  }
}

/* 2K / Quad HD / 1440p */
@media (min-width: 2500px) and (min-height: 1300px) {
  :root {
    font-size: 30px;
  }
}

/* True 4K / UHD TV (3840x2160 on 70" screen) */
@media (min-width: 3200px) or (min-height: 1800px) {
  :root {
    font-size: 40px;
  }
}

/* User Zoom Override Levels (via Magic Remote button) */
body.zoom-125 {
  font-size: 125% !important;
}
body.zoom-150 {
  font-size: 150% !important;
}
body.zoom-175 {
  font-size: 175% !important;
}

/* ==========================================================================
   BASE RESET & LAYOUT
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 1.2vh 1.2vw;
}

/* Ambient Backdrops */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}
.glow-1 {
  width: 50vw;
  height: 40vh;
  top: -10vh;
  left: 20vw;
  background: radial-gradient(circle, #38bdf8, transparent 70%);
}
.glow-2 {
  width: 45vw;
  height: 45vh;
  bottom: -15vh;
  right: 10vw;
  background: radial-gradient(circle, #818cf8, transparent 70%);
}

/* ==========================================================================
   TOP BAR (HEADER)
   ========================================================================== */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  height: 9vh;
  min-height: 58px;
  margin-bottom: 0.8vh;
  padding: 0 0.4vw;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.brand-logo {
  width: 2.2rem;
  height: 2.2rem;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4));
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

/* Student Tabs */
.student-tabs {
  display: flex;
  gap: 0.8rem;
  background: rgba(15, 23, 42, 0.85);
  padding: 0.3rem;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 1.2rem;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted);
}
.tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}
.tab-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  transition: transform 0.25s ease;
}
.tab-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}
.tab-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
}
.tab-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  margin-top: 0.15rem;
}
.badge-eso {
  background: rgba(56, 189, 248, 0.15);
  color: var(--antonio-accent);
}
.badge-pri {
  background: rgba(16, 185, 129, 0.15);
  color: var(--eduardo-accent);
}

/* Active tab states with glowing neons */
.tab-btn.active.tab-antonio {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--antonio-accent);
  box-shadow: 0 0 20px var(--antonio-glow);
  color: #ffffff;
}
.tab-btn.active.tab-antonio .tab-avatar {
  transform: scale(1.08);
}

.tab-btn.active.tab-eduardo {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--eduardo-accent);
  box-shadow: 0 0 20px var(--eduardo-glow);
  color: #ffffff;
}
.tab-btn.active.tab-eduardo .tab-avatar {
  transform: scale(1.08);
}

/* Header Right: Clock, Zoom & Kiosk */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.kiosk-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.btn-icon-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  transition: all 0.2s ease;
}
.btn-icon-label:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}
.kiosk-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.3s ease;
}
.kiosk-on .kiosk-indicator {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}
.carousel-bar-container {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.kiosk-on + .carousel-bar-container {
  opacity: 1;
}
.carousel-progress {
  height: 100%;
  width: 0%;
  background: var(--antonio-accent);
  transition: width 0.1s linear;
}

.btn-icon {
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-icon:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.clock-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.35rem 0.9rem;
  text-align: right;
  min-width: 140px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
.live-time {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #ffffff;
  line-height: 1.1;
}
.live-date {
  font-size: 0.72rem;
  color: var(--antonio-accent);
  font-weight: 700;
  text-transform: capitalize;
}

/* Mobile Day Selector (Hidden on Desktop & TV) */
.mobile-day-selector {
  display: none;
}

/* ==========================================================================
   DASHBOARD BODY & SCHEDULE GRID
   ========================================================================== */

.dashboard-body {
  flex: 1;
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 0.8vh;
  min-height: 0;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab-panel.active {
  display: flex;
}

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

/* 5 Days Schedule Grid */
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.7vw;
  flex: 1;
  min-height: 0;
}

.day-column {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.6vh 0.5vw;
  display: flex;
  flex-direction: column;
  gap: 0.4vh;
  backdrop-filter: blur(12px);
  position: relative;
  transition: all 0.25s ease;
  min-height: 0;
}

/* Today highlight */
.day-column.is-today {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--antonio-accent);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.2);
}
#panel-eduardo .day-column.is-today {
  border-color: var(--eduardo-accent);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.2);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3vh 0.4vw 0.5vh 0.4vw;
  border-bottom: 1px solid var(--card-border);
}
.day-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
}
.today-badge {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--antonio-accent);
  color: #041226;
  letter-spacing: 0.05em;
  box-shadow: 0 0 8px var(--antonio-glow);
  display: none;
}
#panel-eduardo .today-badge {
  background: var(--eduardo-accent);
  color: #022013;
}
.is-today .today-badge {
  display: inline-block;
}

/* Slots Container */
.slots-container {
  display: flex;
  flex-direction: column;
  gap: 0.4vh;
  flex: 1;
  min-height: 0;
}

/* Individual Slot Card */
.slot-card {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3vh 0.6vw;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.75);
  border-left: 5px solid var(--slot-color, var(--card-border));
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.slot-card:hover {
  background: rgba(51, 65, 85, 0.9);
  transform: translateY(-1px);
}

.slot-left {
  display: flex;
  align-items: center;
  gap: 0.5vw;
  min-width: 0;
}

.slot-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.slot-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.slot-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.slot-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Status Indicator Pill inside slot */
.slot-status {
  display: none;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  text-transform: uppercase;
}

/* Break / Recreo Special Style */
.slot-card.is-break {
  flex: 0.65;
  background: rgba(30, 41, 59, 0.45);
  border-left: 5px solid var(--c-recreo);
  opacity: 0.9;
}
.slot-card.is-break .slot-name {
  font-size: 0.88rem;
  color: #cbd5e1;
  font-style: italic;
}

/* Current active class ("EN CURSO") */
.slot-card.is-current {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.3) 0%, rgba(30, 41, 59, 0.95) 100%);
  border-left-width: 6px;
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
  animation: pulseSlot 2.5s infinite;
}
#panel-eduardo .slot-card.is-current {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.3) 0%, rgba(30, 41, 59, 0.95) 100%);
  border-color: #10b981;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.45);
}
.slot-card.is-current .slot-status {
  display: block;
  background: #ef4444;
  color: #ffffff;
  animation: blink 1.2s infinite;
}

@keyframes pulseSlot {
  0% { transform: scale(1); }
  50% { transform: scale(1.012); }
  100% { transform: scale(1); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================================================
   EXTRAESCOLARES STRIP (BOTTOM SECTION)
   ========================================================================== */

.extra-strip {
  height: 16vh;
  min-height: 95px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.6vh 0.8vw;
  display: flex;
  flex-direction: column;
  gap: 0.4vh;
  backdrop-filter: blur(12px);
}

.extra-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.extra-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
}
.extra-icon {
  font-size: 1.05rem;
}
.extra-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}
.tag-antonio {
  background: rgba(56, 189, 248, 0.15);
  color: var(--antonio-accent);
}
.tag-eduardo {
  background: rgba(16, 185, 129, 0.15);
  color: var(--eduardo-accent);
}

.extra-cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.7vw;
  flex: 1;
  min-height: 0;
}

.extra-card {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  padding: 0.3vh 0.5vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 0.25vh;
  transition: all 0.2s ease;
  min-height: 0;
}

.extra-card.has-activity {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.35);
}
#panel-eduardo .extra-card.has-activity {
  border-color: rgba(16, 185, 129, 0.35);
}

.extra-card.is-today-extra {
  border-width: 2px;
  border-color: var(--antonio-accent);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
}
#panel-eduardo .extra-card.is-today-extra {
  border-color: var(--eduardo-accent);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
}

.extra-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1vh;
  width: 100%;
}

.extra-divider {
  width: 55%;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0.15vh 0;
}

.extra-time {
  font-size: 0.68rem;
  color: var(--antonio-accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
#panel-eduardo .extra-time {
  color: var(--eduardo-accent);
}

.extra-desc {
  font-size: 0.82rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3vw;
  line-height: 1.2;
}

.extra-empty {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-style: italic;
  font-weight: 600;
}

/* ==========================================================================
   RESPONSIVE DESIGN FOR SMARTPHONES & TABLETS (MOBILE UX)
   ========================================================================== */

@media (max-width: 850px) {
  :root {
    font-size: 16px;
  }

  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
  }

  .ambient-glow {
    display: none; /* Mejor rendimiento en móviles */
  }

  /* Header en Móvil */
  .top-bar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
    padding: 0;
  }

  .top-bar > div:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .brand-title {
    font-size: 1.1rem;
  }
  .brand-sub {
    font-size: 0.68rem;
  }

  /* Tabs de alumnos a 2 columnas completas */
  .student-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 6px;
  }

  .tab-btn {
    padding: 8px 10px;
    justify-content: center;
  }
  .tab-name {
    font-size: 1rem;
  }
  .tab-badge {
    font-size: 0.58rem;
  }
  .tab-avatar {
    width: 1.8rem;
    height: 1.8rem;
  }

  .header-right {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }

  .kiosk-control {
    display: none; /* No necesario en móvil */
  }

  .clock-card {
    min-width: auto;
    flex: 1;
    text-align: center;
    padding: 6px 12px;
  }
  .live-time {
    font-size: 1.1rem;
  }
  .live-date {
    font-size: 0.65rem;
  }

  /* Selector de día para móvil */
  .mobile-day-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding: 4px 2px;
    -webkit-overflow-scrolling: touch;
  }

  .day-chip {
    flex: 1;
    min-width: 48px;
    padding: 8px 6px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
  }

  .day-chip.active {
    background: var(--antonio-accent);
    color: #041226;
    border-color: var(--antonio-accent);
    box-shadow: 0 0 10px var(--antonio-glow);
  }
  #panel-eduardo-active .day-chip.active,
  body.theme-eduardo .day-chip.active {
    background: var(--eduardo-accent);
    border-color: var(--eduardo-accent);
  }

  .day-chip.is-today-chip {
    border-color: var(--antonio-accent);
  }

  /* Grid en móvil: Una columna por día seleccionado o lista completa */
  .schedule-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .day-column {
    padding: 10px;
    border-radius: 12px;
  }

  /* Ocultar columnas que no son el día activo (salvo modo 'all') */
  body:not(.show-all-days) .day-column:not(.mobile-selected-day) {
    display: none !important;
  }

  .slot-card {
    padding: 10px 14px;
    min-height: 48px;
    border-radius: 10px;
  }
  .slot-name {
    font-size: 1rem;
    white-space: normal; /* Permitir 2 líneas en móvil si es largo */
  }
  .slot-time {
    font-size: 0.78rem;
  }
  .slot-icon {
    font-size: 1.3rem;
  }

  /* Extraescolares en móvil */
  .extra-strip {
    height: auto;
    min-height: auto;
    padding: 12px;
    margin-top: 12px;
    gap: 10px;
  }

  .extra-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* Ocultar tarjeta de extraescolar que no coincide con el día móvil */
  body:not(.show-all-days) .extra-card:not(.mobile-selected-extra) {
    display: none !important;
  }

  .extra-card {
    padding: 10px;
    min-height: 52px;
  }
  .extra-desc {
    font-size: 0.95rem;
  }
  .extra-time {
    font-size: 0.8rem;
  }
}
