/* =========================
 *  FORMATITA PRISKRIBO - NUR BAZA
 *  ========================= */

.desc {
  margin-top: 8px;
  /*   font-size: 1em; */
  line-height: 1.4;
}

.desc strong,
.desc b {
  font-weight: bold;
}

.desc em,
.desc i {
  font-style: italic;
}

.desc u {
  text-decoration: underline;
}

/* =========================
   ĜENERALA STILO
   ========================= */

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: #dadcde;
  color: #1e1e1e;
  /*   line-height: 1.5; */
  margin: 20px;
}

h1 {
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: -0.5px;
}

/* Tabeloj */
table {
  border-collapse: separate;
  border-spacing: 5px;
  width: 100%;
  margin-bottom: 60px;
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
}

th {
  background: #f3f4f6;
  font-weight: 600;
  padding: 12px;
}

td {
  vertical-align: top;
  border: none;
  padding: 10px;
}

tbody tr:not(:last-child) td {
  /*   border-bottom: 1px solid #eee; */
}

.hora {
  background: #f9fafb;
  font-weight: 600;
  color: #6b7280;
  width: 80px;
}

/* Eventoj */
.evento {
  vertical-align: top;
  padding: 5px;
  margin-bottom: 6px;
  font-size: 0.9em;
  height: 100%;
}

.evento strong {
  font-size: 1em;
}

.evento em {
  /*   color: #333; */
}

/* Lanes / grid de eventoj (opcia se grid estas uzata) */
.eventos-row {
  display: grid;
  gap: 6px;
}

/* =========================
   SUPRA BRETO
   ========================= */

.top-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* Komuna stilo por butonoj kaj abonligilo */
/* Unuigi ĉiujn butonojn kaj ligilojn de la supra breto */
.top-bar a,
.top-bar button {
  all: unset; /* Forigas ĉiujn defaŭltajn stilojn de la retumilo */
  display: inline-block; /* Kondutas sin kiel butono */
  padding: 8px 16px;
  border-radius: 999px; /* rondigitaj randoj */
  background: #374151;
  color: white;
  font-size: 0.9em; /* uniforma grandeco */
  font-weight: 500;
  text-align: center;
  cursor: default; /* normala kursoro por butonoj */
  text-decoration: none; /* forigi substrekojn de ligiloj */
  transition: all 0.2s ease;
  line-height: 1.2;
  box-sizing: border-box;
}

.top-bar a:hover,
.top-bar button:hover {
  background: #4b5a6f;
  /*   transform: translateY(-1px); */
}

/* =========================
 * Koloroj                   *
 * ========================= */

.cat-e {
  background-color: #f6bf26;
}

.cat-mangho {
  background-color: #feeeff;
  /*   background-color: #d50000; */
  color: green;
}

.cat-ml {
  background-color: #e67c73;
}

.cat-p {
  background-color: #d50000;
  color: white;
}

.cat-k {
  background-color: #33b679;
}

.cat-d {
  background-color: #f4511e;
  color: white;
}

.cat-m {
  background-color: #039be5;
  color: white;
}

.cat-matena {
  background-color: #ffd685;
}
.cat-s {
  background-color: #8e24aa;
  color: white;
}

.cat-vp {
  background-color: #3f51b5;
  color: white;
}

.cat-ludo {
  background-color: #8e24aa;
  color: white;
}

/* =========================
   MALHELA REĜIMO
   ========================= */

[data-theme="dark"] body {
  /*   background: #001c23; */
  background: linear-gradient(to right, #0b0216, #19061f);
  color: #e5e7eb;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(
      circle at 20% 30%,
      rgba(99, 102, 241, 0.15),
      transparent 60%
    ),
    radial-gradient(circle at 80% 70%, rgba(236, 72, 153, 0.1), transparent 60%);
}

[data-theme="dark"] body table {
  background: #334155;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] body th {
  background: #283343;
}

[data-theme="dark"] body .hora {
  background: #283343;
  color: #94a3b8;
}

/* Supra breto malhela (butono toggle + abonligilo) */
[data-theme="dark"] body .top-bar a,
[data-theme="dark"] body .top-bar button {
  background-color: #2a2a2a;
  color: #e0e0e0;
  border-color: #555;
}

[data-theme="dark"] body .top-bar a:hover,
[data-theme="dark"] body .top-bar button:hover {
  background-color: #3a3a3a;
}

tbody {
  border: 1px solid #333;
}

[data-theme="dark"] body tbody {
  outline: 1px solid #555;
}
.solo-evento {
  /*   border-right: none; */
}
.malplena-dekstra {
  border: none;
}

.malplena {
  /*  border-right: none;
  border-left: none;
  border-top: none;*/
  border: none;
}

/* =========================
 * KOLOROJ Malhela reĝimo
 *  ========================= */

[data-theme="dark"] body .cat-e {
  background-color: #a37c1a;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-mangho {
  background-color: #5a505a;
  color: #ffffff;
}

[data-theme="dark"] body .cat-ml {
  background-color: #a0514a;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-p {
  background-color: #7a0000;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-k {
  background-color: #1f6d48;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-d {
  background-color: #993010;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-m {
  background-color: #02608f;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-matena {
  background-color: #a37d45;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-s {
  background-color: #5b176f;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-vp {
  background-color: #2a3675;
  color: #d0d0d0;
}

[data-theme="dark"] body .cat-ludo {
  background-color: #5b176f;
  color: #d0d0d0;
}

/* --- Butono por ŝanĝi temon (luno + suno) --- */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  padding: 6px 10px;
  border: none;
  border-radius: 24px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s ease;
  box-shadow: none;
}

#theme-toggle .ikono {
  display: inline-flex;
  transition:
    color 0.25s ease,
    opacity 0.25s ease;
}

#theme-toggle .ikono svg {
  width: 24px;
  height: 24px;
  display: block;
}

[data-theme="light"] #theme-toggle .ikono-suno {
  color: #fbbf24;
  opacity: 1;
}
[data-theme="light"] #theme-toggle .ikono-luno {
  color: #6b7280;
  opacity: 0.5;
}

[data-theme="dark"] #theme-toggle .ikono-luno {
  color: #f59e0b;
  opacity: 1;
}
[data-theme="dark"] #theme-toggle .ikono-suno {
  color: #9ca3af;
  opacity: 0.5;
}

#theme-toggle:hover .ikono {
  opacity: 0.85;
}

#theme-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* =========================
 * FALDADO DE TAGOJ
 * ========================= */

.day-toggle {
  all: unset;
  display: block;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 0 24px;
  text-align: center;
  cursor: pointer;
}

/* Indikilo de la falda stato */
.day-toggle::before {
  content: "▾";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.faldita .day-toggle::before {
  content: "▸";
}

.day-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 4px;
}

/* Falditaj tagoj nur sur la ekrano */
@media screen {
  table.day-table.faldita tbody {
    display: none;
  }

  table.day-table.faldita {
    margin-bottom: 8px;
  }

  .day-toggle:hover {
    opacity: 0.8;
  }
}

/* =========================
 *   REGULOJ POR PRESADO (A4, 1 tago je folio)
 *   ========================= */
@media print {
  /* Devigi A4 landscape */
  @page {
    size: A4 landscape;
    margin: 5mm;
  }

  /* Kaŝi kontrolojn kaj elementojn ne necesajn dum presado */
  .top-bar,
  #icsFile,
  #theme-toggle,
  #subscribeICS,
  h1 {
    display: none !important;
  }

  /* Devigi kolorojn de "hela reĝimo" dum presado */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 13px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Tabeloj - baza stilo */
  table {
    /* border-collapse: collapse !important; */
    border: 1px solid #333 !important;
    width: 100% !important;
    /* page-break-after: always !important; */ /* FORIGITA - tio kaŭzis la problemon */
  }

  th,
  td {
    border: 1px solid #333 !important;
    padding: 2px !important;
    vertical-align: top !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  th {
    background-color: #e0e0e0 !important;
    color: #000 !important;
    font-size: 13px !important;
  }

  /* Kolono de horo */
  .hora {
    background-color: #f7f7f7 !important;
    color: #000 !important;
    font-size: 13px !important;
    padding: 2px !important;
  }

  /* Eventoj */
  .evento {
    vertical-align: top !important;
    padding: 2px !important;
    margin: 0 !important;
    font-size: 12px !important; /* más compacta */
    line-height: 1.2 !important;
  }

  .evento strong {
    font-size: 12px !important;
  }

  .evento em {
    font-size: 11px !important;
    color: #333 !important;
  }

  /* kaŝi priskribojn */
  .evento .desc {
    display: none !important;
  }

  /* Por ke la vicoj okupu la tutan alton,
   oni simple lasas la retumilon distribui
   la spacon aŭtomate */
  table.day-table {
    height: 180mm !important;
    max-height: 180mm !important;
    display: table !important;
    page-break-after: always;
    page-break-before: auto;
    margin-bottom: 0 !important;
    box-shadow: none !important;
  }

  /* La vicoj aŭtomate streĉiĝos por plenigi la alton */
  table.day-table tbody {
    height: auto !important;
    display: table-row-group !important;
  }

  table.day-table tbody tr {
    height: auto !important;
  }

  /* Tio ĉi estas kio igas la vicojn okupi la disponeblan spacon */
  table.day-table tbody:after {
    content: "" !important;
    display: none !important; /* Ni ne bezonas trukojn */
  }

  /* Eviti ke vicoj disiĝu inter paĝoj */
  table,
  thead,
  tbody,
  tr,
  td,
  .evento {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* ALDONITA - Devigi ke la thead montriĝu kompleta en ĉiu paĝo */
  thead {
    display: table-header-group !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* ALDONITA - Certigi ke la unua vico de thead ĉiam estu videbla */
  table.day-table thead tr {
    height: 1px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* Ĉiu tabelo (ĉiu tago) en sia propra paĝo */
  table.day-table {
    /* page-break-after: always; */ /* Ĝi jam estas supre */
    /* break-after: page; */
    width: 100% !important;
    border-spacing: 5px 1px !important;
  }

  .malplena,
  .malplena-dekstra {
    padding: 0 !important;
  }

  .malplena-dekstra,
  .malplena {
    border: none !important;
  }

  /* Forigi la internan kadron de la tabelo */
  table.day-table thead,
  table.day-table tbody {
    border: none !important;
    outline: none !important;
  }

  /* Presi ĉiujn tagojn sen faldindikiloj */
  .day-toggle::before {
    display: none !important;
  }

  .day-toggle {
    padding: 0 !important;
  }
}
