*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:    #1a2a4a;
  --navy2:   #22386a;
  --blue:    #2e5faa;
  --blue-lt: #e8eef8;
  --gold:    #b8892a;
  --gold-lt: #fdf5e4;
  --text:    #1c1c1e;
  --muted:   #6b7280;
  --border:  #dde3ed;
  --bg:      #f7f8fb;
  --white:   #ffffff;
  --radius:  10px;
  --shadow:  0 2px 16px rgba(30, 50, 100, .08);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
}

/* ─── MAIN LAYOUT ─── */
.page-body {
  max-width: 1500px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ─── HEADER CONTROLS ─── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ─── MODE TABS ─── */
.mode-tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .38rem .85rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.mode-tab i { width: 14px; height: 14px; }

.mode-tab:hover {
  background: var(--white);
  color: var(--navy);
}

.mode-tab.active {
  background: var(--navy);
  color: #fff;
}

/* ─── CLASS SWITCHER ─── */
.plan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.sec-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: .4rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.sec-title {
  font-family: 'Lora', serif;
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
}

.class-selector {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.class-selector label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.class-select {
  appearance: none;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem 2rem .5rem .85rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  transition: border-color .15s;
}

.class-select:focus { outline: none; border-color: var(--blue); }

/* ─── LEGEND ─── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: 12px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .2rem .7rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── TIMETABLE TABLE ─── */
.timetable-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
  position: relative;
  display: block;
}

/* Linia obecnego czasu */
#time-line {
  position: absolute;
  left: 0;
  height: 2px;
  background: #ff4757; /* Czerwony kolor linii */
  z-index: 10;
  pointer-events: none;
  display: none; /* Ukryta domyślnie (np. w nocy) */
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.5);
}

#time-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: -4px;
  width: 10px;
  height: 10px;
  background: #ff4757;
  border-radius: 50%;
}

/* Podświetlenie aktywnej lekcji */
.lesson.active-now {
  border-left-color: #ff4757 !important;
  box-shadow: inset 0 0 0 2px rgba(255, 71, 87, 0.2);
  transform: scale(1.02);
  transition: all 0.3s ease;
}

/* Podświetlenie aktywnej godziny w pierwszej kolumnie */
.hour-cell.active-hour {
  background: rgba(255, 71, 87, 0.05) !important;
  border-right-color: #ff4757 !important;
}

table.timetable {
  width: 100%;
  border-collapse: collapse;
  min-width: 1000px;
}

.timetable thead th {
  background: var(--navy);
  color: rgba(255,255,255,.9);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .85rem 1rem;
  text-align: center;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.08);
}

.timetable thead th:last-child { border-right: none; }

.timetable thead th:first-child {
  text-align: left;
  padding-left: 1.25rem;
  min-width: 100px;
}

.timetable tbody tr:nth-child(odd) td { background: #fafbfd; }
.timetable tbody tr:nth-child(even) td { background: var(--white); }
.timetable tbody tr:hover td { background: var(--blue-lt) !important; }

.timetable td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}

.timetable td:last-child { border-right: none; }

.timetable td:first-child {
  padding-left: 1.25rem;
  min-width: 100px;
  border-right: 2px solid var(--border);
  background: var(--white) !important;
  vertical-align: middle;
}

.hour-num {
  font-family: 'Lora', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  display: block;
  line-height: 1;
}

.hour-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: .15rem;
}

/* ─── SPLIT GRUPOWY ─── */
.lesson-split-wrap {
  display: flex;
  gap: 4px;
  min-height: 52px;
}

.lesson-half {
  flex: 1;
  min-width: 0;
  background: var(--blue-lt);
  border-left: 3px solid var(--blue);
  border-radius: 0 6px 6px 0;
  padding: .45rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.lesson-half.empty {
  background: transparent;
  border-left-color: var(--border);
  border-left-style: dashed;
  justify-content: center;
  align-items: center;
}

.split-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--blue);
  background: rgba(46,95,170,.1);
  border-radius: 3px;
  padding: 1px 4px;
  width: fit-content;
  margin-bottom: 2px;
}

.lesson-half .lesson-name { font-size: 12px; }
.lesson-half .lesson-info { font-size: 10px; }

.no-lesson {
  font-size: 12px;
  color: var(--border);
}

/* ─── LESSON CELL ─── */
.lesson {
  background: var(--blue-lt);
  border-left: 3px solid var(--blue);
  border-radius: 0 6px 6px 0;
  padding: .6rem;
  min-height: 30px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: .25rem;
}

.lesson-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
  line-height: 1.2;
}

.lesson-info {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: rgba(0,0,0,.05);
  border-radius: 4px;
  padding: 1px 5px;
  width: fit-content;
}

.lesson-info i { width: 10px; height: 10px; flex-shrink: 0; }

/* Warianty kolorystyczne lekcji */
.lesson.gold { background: var(--gold-lt); border-color: var(--gold); }
.lesson.gold .lesson-name { color: #7a5a10; }
.lesson.navy { background: #e6eaf4; border-color: var(--navy2); }
.lesson.green { background: #eaf5ec; border-color: #3b8f52; }
.lesson.green .lesson-name { color: #2a6640; }
.lesson.red { background: #fbeaea; border-color: #c84040; }
.lesson.red .lesson-name { color: #8f2020; }
.lesson.empty { background: transparent; border-left: none; padding: 0; min-height: 52px; }

/* Przerwy */
.break-row td {
  background: #f3f5fa !important;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  padding: .3rem 1rem;
}
.break-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #9ca3af;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
}

/* ─── WEEK VIEW PANEL ─── */
.week-panel { display: none; }
.week-panel.active { display: block; }

/* ─── INFO BOX ─── */
.info-box {
  background: var(--gold-lt);
  border: 1px solid #e2c97a;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin-bottom: 1.75rem;
  font-size: 13.5px;
  color: #7a5a10;
  line-height: 1.6;
}

.info-box i { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }

/* ─── FOOTER ─── */
footer {
  background: var(--navy);
  color: rgba(255,255,255,.5);
  text-align: center;
  font-size: 12.5px;
  padding: 2rem 1rem;
  line-height: 1.8;
}

footer a { color: rgba(255,255,255,.6); text-decoration: none; }
footer a:hover { color: #fff; }
.footer-divider { margin: 0 .5rem; opacity: .4; }

/* ─── ICONS GLOBAL ─── */
[data-lucide] {
  width: 16px;
  height: 16px;
  stroke-width: 2px;
  vertical-align: middle;
}

/* ─── ANIMATIONS ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .4s ease both; }
.delay-1 { animation-delay: .06s; }
.delay-2 { animation-delay: .12s; }

/* ─── DAY NAV (hidden on desktop, shown on mobile via media query) ─── */
.day-nav { display: none; }

/* ─── RESPONSIVE ─── */
@media (max-width: 700px) {
  .page-body { padding: 1rem .75rem 3rem; }
  .plan-header { flex-direction: column; gap: .75rem; margin-bottom: 1.25rem; }
  .header-controls { flex-direction: column; align-items: flex-start; gap: .6rem; width: 100%; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; justify-content: center; }
  .class-selector { width: 100%; }
  .class-select { width: 100%; }
  .sec-title { font-size: 1.1rem; }
  .legend { gap: .35rem; }
  .legend-item { font-size: 11px; padding: .15rem .55rem; }

  /* ─── NAWIGACJA DNI (mobile) ─── */
  .day-nav {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .4rem .5rem;
    margin-bottom: 1rem;
    gap: .5rem;
  }

  .day-nav-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--navy);
    flex-shrink: 0;
    transition: background .15s;
  }
  .day-nav-btn:hover { background: var(--blue-lt); }
  .day-nav-btn:disabled { opacity: .3; cursor: default; }

  .day-nav-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--navy);
    text-align: center;
    flex: 1;
  }
  .day-nav-label small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--muted);
    margin-top: 1px;
  }

  /* ─── TABELA: tryb dzienny ─── */
  .timetable-wrap { overflow-x: visible; }

  table.timetable {
    min-width: 0;
    width: 100%;
    table-layout: auto;
  }

  /* Ukryj wszystkie kolumny dni, pokaż tylko aktywną */
  .timetable thead th { display: none; }
  .timetable thead th:first-child,
  .timetable thead th.mobile-visible { display: table-cell; }

  .timetable tbody td { display: none; }
  .timetable tbody td:first-child,
  .timetable tbody td.mobile-visible { display: table-cell; }

  /* Kolumna godzin: sztywna szerokość */
  .timetable thead th:first-child,
  .timetable tbody td:first-child {
    width: 68px;
    min-width: 68px;
    max-width: 68px;
    padding-left: .75rem;
  }

  /* Kolumna lekcji: zajmuje całą resztę */
  .timetable thead th.mobile-visible,
  .timetable tbody td.mobile-visible {
    width: 100%;
  }

  /* Komórka godziny */
  .hour-num { font-size: 14px; }
  .hour-time { font-size: 10px; }

  /* Komórki lekcji */
  .timetable td { padding: .45rem .5rem; font-size: 12px; }

  .lesson { min-width: 0; padding: .5rem .6rem; }
  .lesson-name { font-size: 12.5px; }
  .lesson-info { font-size: 10.5px; }

  .lesson-split-wrap { flex-direction: column; gap: 3px; min-height: 0; }
  .lesson-half { padding: .4rem .5rem; }
  .lesson-half .lesson-name { font-size: 11.5px; }
  .lesson-half .lesson-info { font-size: 10px; }

  .break-row td { padding: .2rem .5rem; }
  .break-label { font-size: 10px; }

  /* Ukryj time-line na mobile (zbyt skomplikowane z jedną kolumną) */
  #time-line { display: none !important; }
}