/* ==========================================================================
   Horario Universitario Personalizado - Modern, Fluid & Color-Coded UI
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-main: #070a12;
  --bg-card: rgba(15, 23, 42, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);

  /* User requested: Theory = Blue, Practice = Green */
  --color-theory: #3b82f6;
  --color-theory-bg: rgba(30, 58, 138, 0.35);
  --color-theory-border: rgba(59, 130, 246, 0.6);
  --color-theory-glow: rgba(59, 130, 246, 0.2);

  --color-lab: #10b981;
  --color-lab-bg: rgba(6, 78, 59, 0.35);
  --color-lab-border: rgba(16, 185, 129, 0.6);
  --color-lab-glow: rgba(16, 185, 129, 0.2);

  --color-mixed: #06b6d4;
  --color-mixed-bg: rgba(12, 74, 110, 0.35);
  --color-mixed-border: rgba(6, 182, 212, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: #f8fafc;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Background Atmosphere */
.bg-glow-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.18;
  pointer-events: none;
}

.glow-orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #3b82f6, #6366f1);
  top: -150px;
  left: -100px;
}

.glow-orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #10b981, #06b6d4);
  bottom: -150px;
  right: -100px;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

.font-heading { font-family: var(--font-heading); }
.font-mono { font-family: var(--font-mono); }

/* Glass Panels */
.glass-panel {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

.glass-card {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

/* ==========================================================================
   WEEKLY TIMETABLE GRID (Full Width & Proportional)
   ========================================================================== */
.schedule-grid-container {
  width: 100%;
  overflow-x: auto;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 90px repeat(5, minmax(180px, 1fr));
  gap: 8px;
  width: 100%;
}

.time-header-cell {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  text-align: center;
  min-height: 80px;
}

.day-header-cell {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  position: relative;
  transition: all 0.2s ease;
}

.day-header-cell.is-today {
  border-color: rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.15);
}

.day-header-cell.is-today::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 10px 10px 0 0;
}

/* Schedule Cell */
.schedule-cell {
  min-height: 84px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px dashed rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.18s ease;
  position: relative;
}

.schedule-cell.has-classes {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(15, 23, 42, 0.5);
}

.schedule-cell:hover {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   CLASS CARDS - BLUE FOR THEORY, GREEN FOR LAB / PRACTICE
   ========================================================================== */
.class-card {
  position: relative;
  border-radius: 9px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  overflow: hidden;
  height: 100%;
}

/* Theory: Blue */
.class-card.card-theory {
  background: var(--color-theory-bg);
  border: 1px solid var(--color-theory-border);
  border-left-width: 4px;
  border-left-color: var(--color-theory);
  box-shadow: 0 4px 14px -3px var(--color-theory-glow);
}

/* Lab: Green */
.class-card.card-lab {
  background: var(--color-lab-bg);
  border: 1px solid var(--color-lab-border);
  border-left-width: 4px;
  border-left-color: var(--color-lab);
  box-shadow: 0 4px 14px -3px var(--color-lab-glow);
}

/* Mixed: Cyan */
.class-card.card-mixed {
  background: var(--color-mixed-bg);
  border: 1px solid var(--color-mixed-border);
  border-left-width: 4px;
  border-left-color: var(--color-mixed);
}

/* Custom Tasks / Work / Study / Sport */
.class-card.card-task {
  background: rgba(30, 27, 75, 0.45);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-left-width: 4px;
  border-left-color: #8b5cf6;
}

.class-card.card-task-study {
  background: rgba(46, 16, 101, 0.45);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-left-color: #a855f7;
}

.class-card.card-task-work {
  background: rgba(69, 26, 3, 0.45);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-left-color: #f59e0b;
}

.class-card.card-task-sport {
  background: rgba(80, 7, 36, 0.45);
  border: 1px solid rgba(236, 72, 153, 0.4);
  border-left-color: #ec4899;
}

.class-card.card-task-leisure {
  background: rgba(8, 51, 68, 0.45);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-left-color: #06b6d4;
}

.class-card.card-task-other {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-left-color: #94a3b8;
}

/* Exam Mode: Reddish alert style for specific exam dates */
.class-card.card-exam {
  background: rgba(136, 19, 55, 0.55) !important;
  border: 1.5px solid #f43f5e !important;
  border-left-width: 5px !important;
  border-left-color: #e11d48 !important;
  box-shadow: 0 4px 18px -2px rgba(225, 29, 72, 0.45) !important;
}

.class-card.card-exam:hover {
  filter: brightness(1.2);
  box-shadow: 0 8px 24px -2px rgba(225, 29, 72, 0.65) !important;
}

.badge-exam {
  background: rgba(225, 29, 72, 0.25);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.5);
  font-weight: 800;
  letter-spacing: 0.05em;
  animation: pulseExam 2s infinite ease-in-out;
}

@keyframes pulseExam {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; transform: scale(1.03); }
}

.class-card:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.6);
}

/* Current Live Class Glow */
.class-card.is-current-active {
  animation: pulseGlow 2.2s infinite;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 16px 2px rgba(56, 189, 248, 0.6) !important;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 8px 1px rgba(56, 189, 248, 0.4); }
  50% { box-shadow: 0 0 20px 4px rgba(56, 189, 248, 0.8); }
  100% { box-shadow: 0 0 8px 1px rgba(56, 189, 248, 0.4); }
}

/* Conflict Tabs */
.conflict-tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 2px;
}

.conflict-tab-btn {
  font-size: 10px;
  padding: 1.5px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  line-height: 1.2;
}

.conflict-tab-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.conflict-tab-btn.active {
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
}

/* Type Badges */
.badge-theory {
  background: rgba(37, 99, 235, 0.25);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.4);
}

.badge-lab {
  background: rgba(5, 150, 105, 0.25);
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.badge-mixed {
  background: rgba(8, 145, 178, 0.25);
  color: #a5f3fc;
  border: 1px solid rgba(34, 211, 238, 0.4);
}

.badge-task-study {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
  border: 1px solid rgba(192, 132, 252, 0.4);
}

.badge-task-work {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.badge-task-sport {
  background: rgba(236, 72, 153, 0.25);
  color: #fbcfe8;
  border: 1px solid rgba(244, 114, 182, 0.4);
}

.badge-task-leisure {
  background: rgba(6, 182, 212, 0.25);
  color: #a5f3fc;
  border: 1px solid rgba(34, 211, 238, 0.4);
}

.badge-task-other {
  background: rgba(100, 116, 139, 0.25);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* Toggle Switches */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #334155;
  transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: #10b981;
}

input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

.toggle-october input:checked + .toggle-slider {
  background: linear-gradient(135deg, #f59e0b, #eab308);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* Modals */
.modal-backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.is-open .modal-content {
  transform: scale(1) translateY(0);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

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

/* No-scrollbar utility for smooth mobile swiping */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ==========================================================================
   MOBILE RESPONSIVE STYLES (Screen width <= 768px)
   Does NOT alter PC / Desktop layout (> 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .schedule-container {
    padding: 8px !important;
    border-radius: 14px !important;
  }

  .schedule-grid {
    gap: 5px !important;
  }

  /* Time Column Optimization */
  .time-header-cell {
    min-width: 48px !important;
    max-width: 54px !important;
    min-height: 68px !important;
    padding: 4px 2px !important;
    border-radius: 8px !important;
  }

  .time-header-cell .time-duration {
    display: none !important;
  }

  .time-header-cell .time-slot-main {
    font-size: 11px !important;
    letter-spacing: -0.02em;
  }

  /* Day Header Cell */
  .day-header-cell {
    padding: 6px 4px !important;
    min-height: 42px !important;
    border-radius: 8px !important;
  }

  .day-header-cell .day-label-text {
    font-size: 11px !important;
  }

  .day-header-cell .day-date-text {
    font-size: 10px !important;
  }

  /* Schedule Cell */
  .schedule-cell {
    min-height: 70px !important;
    padding: 4px !important;
    border-radius: 8px !important;
  }

  /* Single Day View on Mobile: Sleek & Compact */
  .is-single-day-grid .schedule-cell {
    min-height: 62px !important;
  }
  .is-single-day-grid .time-header-cell {
    min-height: 62px !important;
  }

  /* Class Cards on Mobile: Full readability without overflow */
  .class-card {
    padding: 5px 6px !important;
    border-radius: 7px !important;
    gap: 2px !important;
  }

  .class-card .subject-code {
    font-size: 11px !important;
    letter-spacing: -0.02em;
  }

  .class-card .badge-type {
    font-size: 8.5px !important;
    padding: 1px 4px !important;
    line-height: 1.1;
  }

  .class-card .course-badge {
    font-size: 9px !important;
  }

  .class-card .subject-fullname {
    font-size: 10px !important;
    line-height: 1.25 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal !important;
    margin-top: 1px;
    margin-bottom: 1px;
  }

  .class-card .room-pill {
    font-size: 9.5px !important;
    padding: 1px 4px !important;
  }

  .add-task-btn {
    opacity: 0.85 !important;
    transform: scale(1) !important;
    padding: 2px 6px !important;
    font-size: 9px !important;
  }

  /* Mobile Stepper Header: Compact */
  #dayStepperHeader {
    padding-bottom: 6px !important;
    margin-bottom: 6px !important;
  }
  #dayStepperHeader button {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
  #currentDayTitle {
    font-size: 14px !important;
  }
  #currentDaySubtitle {
    font-size: 10px !important;
  }
}

/* ==========================================================================
   PRINT STYLESHEET
   ========================================================================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 6mm;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 10px;
    padding: 0;
  }

  .bg-glow-container,
  .bg-grid,
  .no-print,
  #topBar,
  #statsRibbon,
  #subjectModal,
  #groupsModal,
  #detailsModal,
  #toast {
    display: none !important;
  }

  .print-only-header {
    display: block !important;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #0f172a;
  }

  .schedule-container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .schedule-grid {
    display: grid !important;
    grid-template-columns: 70px repeat(5, 1fr) !important;
    gap: 3px !important;
    width: 100% !important;
  }

  .time-header-cell,
  .day-header-cell {
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    padding: 4px 2px !important;
    font-weight: bold;
    min-height: auto !important;
  }

  .schedule-cell {
    min-height: 55px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 4px !important;
    padding: 3px !important;
  }

  .class-card {
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    padding: 4px 6px !important;
    page-break-inside: avoid;
  }

  .class-card.card-theory {
    border-left: 4px solid #2563eb !important;
    background: #eff6ff !important;
  }

  .class-card.card-lab {
    border-left: 4px solid #059669 !important;
    background: #ecfdf5 !important;
  }

  .class-card .subject-code {
    color: #0f172a !important;
    font-weight: 800 !important;
  }
}
