/* CEJIZA Denní menu — vizuál odvozený z loga CEJIZA
   Barvy: Brand Blue #2B31D8 · Deep Indigo #1B2070 · Light Indigo #A6AAF0
          Ice #F1F2FB · White · Coral #E23A54 (akcent z pruhů v logu)
   Typografie: Figtree (Segoe UI fallback) */

:root {
  color-scheme: light;
  --brand: #2B31D8;
  --deep:  #1B2070;
  --blue:  #A6AAF0;
  --ice:   #F1F2FB;
  --white: #FFFFFF;
  --red:   #E23A54;
  --deep-60: rgba(27, 32, 112, .60);
  --deep-12: rgba(27, 32, 112, .12);
  --skeleton-hi: #e6ecf4;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(27,32,112,.06), 0 6px 20px rgba(27,32,112,.07);
  --font: "Figtree", "Segoe UI", system-ui, sans-serif;
}

/* Tmavý režim — role barev zůstávají (--deep = text i pozadí primárního
   tlačítka, --white = plocha karet, --ice = pozadí stránky), jen se
   překlopí hodnoty. "auto" jede podle OS, přepínač v hlavičce má přednost. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #9095F3;
    --deep:  #E7E8F2;
    --blue:  #7C82DE;
    --ice:   #14151c;
    --white: #1d1f28;
    --red:   #F26178;
    --deep-60: rgba(231, 232, 242, .60);
    --deep-12: rgba(231, 232, 242, .14);
    --skeleton-hi: #2b2e3a;
    --shadow: 0 1px 3px rgba(0,0,0,.45), 0 6px 20px rgba(0,0,0,.38);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #9095F3;
  --deep:  #E7E8F2;
  --blue:  #7C82DE;
  --ice:   #14151c;
  --white: #1d1f28;
  --red:   #F26178;
  --deep-60: rgba(231, 232, 242, .60);
  --deep-12: rgba(231, 232, 242, .14);
  --skeleton-hi: #2b2e3a;
  --shadow: 0 1px 3px rgba(0,0,0,.45), 0 6px 20px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--ice);
  color: var(--deep);
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------- Hlavička ---------- */

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--deep-12);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { height: 28px; width: auto; display: block; }
.logo-word {
  font: 700 66px/1 var(--font);
  letter-spacing: -3px;
  fill: var(--brand);
}
.logo-bar { fill: var(--red); }
.brand-divider { width: 1px; height: 18px; background: var(--deep-12); align-self: center; }
.brand-sub { font-weight: 500; font-size: 1.05rem; color: var(--deep); }

/* ---------- Dny + akce ---------- */

.day-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 28px 0 20px;
}
.day-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.day-tab {
  border: 1px solid var(--deep-12); background: var(--white);
  font: inherit; font-weight: 500; color: var(--deep-60);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  transition: all .15s;
}
.day-tab:hover { border-color: var(--blue); color: var(--deep); }
.day-tab.active {
  background: var(--red); border-color: var(--red);
  color: var(--white); font-weight: 600;
}
.day-tab.past:not(.active) { opacity: .55; }
.day-tab .tab-date { font-weight: 400; opacity: .75; margin-left: 6px; font-size: .85em; }

.day-actions { display: flex; gap: 10px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 999px; padding: 9px 20px; border: 1px solid transparent;
  transition: all .15s;
}
.btn-primary { background: var(--deep); color: var(--white); }
.btn-primary:hover { background: #0e2a4d; }
.btn-ghost {
  background: var(--white); color: var(--deep);
  border-color: var(--deep-12);
}
.btn-ghost:hover { border-color: var(--blue); }

/* ---------- Mřížka karet ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 18px 20px 12px;
}
.card-title { font-size: 1.15rem; font-weight: 600; margin: 0; line-height: 1.3; }
.card-tools { display: flex; gap: 2px; flex-shrink: 0; }
.card-tool {
  border: 0; background: transparent; cursor: pointer;
  color: var(--deep-60); font-size: 1rem; line-height: 1;
  padding: 6px 8px; border-radius: 6px;
  min-width: 32px; min-height: 32px;            /* tap target */
}
.card-tool:hover:not(:disabled) { color: var(--deep); background: var(--ice); }
.card-tool:disabled { opacity: .25; cursor: default; }
.card-remove:hover:not(:disabled) { color: var(--red); }

.soup {
  background: var(--ice);
  margin: 0 20px 10px;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .92rem;
  display: flex; gap: 10px; align-items: baseline; justify-content: space-between;
}
.soup-label {
  font-weight: 600; color: var(--deep-60);
  text-transform: uppercase; font-size: .7rem; letter-spacing: .06em;
  flex-shrink: 0;
}
.soup-name { flex: 1; }

.meals { list-style: none; margin: 0; padding: 4px 20px 14px; flex: 1; }
.meal {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--ice);
  font-size: .95rem; line-height: 1.4;
}
.meal:last-child { border-bottom: 0; }
.meal-num {
  flex-shrink: 0; width: 1.4em; text-align: center;
  font-weight: 600; color: var(--blue); font-size: .9em;
}
.meal-name { flex: 1; }
.allergens {
  color: var(--deep-60); font-size: .78em; white-space: nowrap;
  cursor: help; text-decoration: underline dotted; text-underline-offset: 2px;
}
.al-code { padding: 0 1px; }
.al-code.al-hit {
  color: var(--red); font-weight: 700;
  text-decoration: underline solid; text-underline-offset: 2px;
}
/* jídlo s hlídaným alergenem — přeškrtnuté, ne skryté */
.meal.flagged .meal-name, .soup.flagged .soup-name { text-decoration: line-through; }
.meal.flagged, .soup.flagged { opacity: .5; }
.meal.flagged .allergens, .soup.flagged .allergens { text-decoration: none; }
.meal-price {
  flex-shrink: 0; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--deep);
}

.card-foot {
  padding: 10px 20px 16px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; color: var(--deep-60);
}
.card-foot a { color: var(--deep-60); }
.card-foot a:hover { color: var(--deep); }

.card-note { padding: 6px 20px 20px; color: var(--deep-60); font-size: .92rem; }
.card-error { padding: 6px 20px 20px; color: var(--red); font-size: .92rem; }
.card-allergen-warn {
  margin: 0 20px 12px; padding: 8px 12px;
  background: var(--ice); border: 1px dashed var(--deep-12);
  border-radius: 10px;
  color: var(--deep-60); font-size: .82rem; line-height: 1.4;
}

/* řádek adresa · telefon · rozvoz pod názvem */
.card-meta {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 5px 12px;
  padding: 0 20px 14px;
  margin-top: -2px;
  font-size: .8rem; line-height: 1.35; color: var(--deep-60);
}
.cm-item { display: inline-flex; align-items: center; gap: 4px; }
.cm-tel { color: var(--deep); font-weight: 600; text-decoration: none; }
.cm-tel:hover { text-decoration: underline; }
.cm-serve.is-over { color: var(--red); }
.cm-serve .cm-over { font-weight: 600; }
.cm-rozvoz {
  background: var(--ice); border: 1px solid var(--deep-12);
  color: var(--deep); font-weight: 600; font-size: .72rem;
  padding: 2px 9px; border-radius: 999px;
}

/* skeleton při načítání */
.skeleton-line {
  height: 13px; border-radius: 6px; margin: 13px 20px;
  background: linear-gradient(90deg, var(--ice) 25%, var(--skeleton-hi) 50%, var(--ice) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton-line { animation: none; }
}

/* ---------- Prázdný stav, patička ---------- */

.empty {
  text-align: center; padding: 64px 24px; color: var(--deep-60);
}
.empty-title { font-size: 1.3rem; font-weight: 600; color: var(--deep); margin: 0 0 8px; }
.empty .btn { margin-top: 16px; }

/* ---------- Seznam alergenů ---------- */

.allergens-legend {
  background: var(--white);
  border: 1px solid var(--deep-12);
  border-radius: var(--radius);
  padding: 4px 18px;
  margin: 0 0 48px;
  font-size: .88rem;
}
.allergens-legend summary {
  cursor: pointer; padding: 12px 0;
  font-weight: 600; color: var(--deep);
  list-style-position: inside;
}
.allergens-legend summary::-webkit-details-marker { color: var(--deep-60); }
.al-hint { font-weight: 400; color: var(--deep-60); }
.al-intro {
  margin: 2px 0 12px; color: var(--deep-60);
  font-size: .84rem; line-height: 1.45;
}
.al-list {
  margin: 4px 0 8px; padding: 0 0 0 26px;
  columns: 2; column-gap: 32px;
}
.al-list li {
  margin: 5px 0; padding-left: 4px;
  break-inside: avoid;
  color: var(--deep); line-height: 1.4;
}
.al-list li::marker { font-weight: 700; color: var(--red); }
.al-list label {
  display: inline; cursor: pointer;
  font-weight: 400; font-size: inherit; margin: 0;
}
.al-list input[type="checkbox"] {
  margin-right: 8px; vertical-align: -1px;
  accent-color: var(--red); cursor: pointer;
}
.al-list li:has(input:checked) { color: var(--red); font-weight: 600; }
.al-note {
  margin: 6px 0 12px; padding-top: 8px;
  border-top: 1px solid var(--deep-12);
  color: var(--deep-60); font-size: .84rem;
}
.allergens-legend.flash { outline: 2px solid var(--red); outline-offset: 2px; }
@media (max-width: 720px) {
  .al-list { columns: 1; }
  .allergens-legend { margin-bottom: 32px; }
}

.footer { border-top: 1px solid var(--deep-12); background: var(--white); }
.footer-inner {
  padding-top: 16px; padding-bottom: 16px;
  font-size: .82rem; color: var(--deep-60);
}
.footer-tagline {
  margin: 0 0 6px; font-weight: 500; color: var(--deep);
}
.footer-row {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.footer a { color: inherit; }
.linklike {
  border: 0; background: none; font: inherit; color: var(--deep-60);
  text-decoration: underline; cursor: pointer; padding: 0;
}
.linklike:hover { color: var(--deep); }

/* ---------- Dialog ---------- */

dialog {
  border: 0; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(20,55,99,.25);
  padding: 28px; width: min(440px, calc(100vw - 48px));
  font-family: var(--font); color: var(--deep);
}
dialog::backdrop { background: rgba(20,55,99,.45); }
dialog h2 { margin: 0 0 6px; font-size: 1.3rem; }
.dialog-hint { margin: 0 0 18px; font-size: .88rem; color: var(--deep-60); }
.dialog-hint a { color: var(--deep); }
dialog label {
  display: block; font-weight: 600; font-size: .85rem; margin-bottom: 14px;
}
dialog input {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--deep-12); background: var(--ice);
  color: var(--deep);
}
dialog input:focus { outline: 2px solid var(--blue); border-color: transparent; }
.dialog-error { color: var(--red); font-size: .85rem; }
.label-opt { font-weight: 400; color: var(--deep-60); font-size: .82em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* fokus pro klávesnici */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- Mobil ---------- */

@media (max-width: 720px) {
  .container { padding: 0 14px; }

  .topbar-inner { justify-content: center; gap: 10px; }
  .logo { height: 23px; }
  .nick-chip, .icon-chip { padding: 7px 10px; font-size: .85rem; }

  /* taby na dny: jeden řádek s horizontálním scrollem */
  .day-row { margin: 18px 0 14px; }
  .day-tabs {
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%; padding-bottom: 4px;
    scrollbar-width: none;
  }
  .day-tabs::-webkit-scrollbar { display: none; }
  .day-tab { white-space: nowrap; flex-shrink: 0; }

  .day-actions { width: 100%; flex-wrap: wrap; }
  .day-actions .btn { flex: 1 1 40%; padding: 11px 8px; font-size: .9rem; white-space: nowrap; }

  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card-head { padding: 14px 14px 10px; }
  .soup { margin: 0 14px 8px; }
  .meals { padding: 4px 14px 12px; }
  .card-foot, .card-note, .card-error, .card-meta { padding-left: 14px; padding-right: 14px; }
  .card-allergen-warn { margin-left: 14px; margin-right: 14px; }

  dialog { padding: 20px; }
}

/* ---------- Chipy v hlavičce ---------- */

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nick-chip, .icon-chip {
  border: 1px solid var(--deep-12); background: var(--white);
  font: inherit; font-weight: 500; font-size: .9rem; color: var(--deep-60);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: all .15s; line-height: 1;
}
.nick-chip:hover, .icon-chip:hover { border-color: var(--blue); color: var(--deep); }
.nick-chip.has-nick { color: var(--deep); font-weight: 600; }
.icon-chip { padding: 8px 12px; }
.icon-chip.active { color: var(--deep); font-weight: 600; border-color: var(--red); }

/* ---------- Souhrnná lišta "kdo kam jde" ---------- */

.summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--white);
  border: 1px solid var(--deep-12);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
}
.summary-label {
  font-size: .72rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--deep-60); margin-right: 4px;
}
.summary-pill {
  display: inline-flex; align-items: baseline; gap: 7px;
  border: 1px solid var(--deep-12); background: var(--ice);
  font: inherit; font-size: .85rem; color: var(--deep);
  padding: 5px 11px; border-radius: 14px; cursor: pointer;
  transition: all .15s; text-align: left; white-space: normal;
}
.summary-pill:hover { border-color: var(--blue); }
.summary-pill.mine { border-color: var(--red); }
.sp-time { font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.sp-name {
  font-weight: 600;
  max-width: 180px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0;
}
.sp-people { font-weight: 400; color: var(--deep-60); }
.sp-count {
  background: var(--deep); color: var(--white);
  font-size: .72rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.summary-pill.mine .sp-count { background: var(--red); }

/* zvýraznění karty po kliku na pilulku */
.card.flash { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- Check-in pruh na kartě ---------- */

.checkin-strip {
  border-top: 1px solid var(--ice);
  margin: 4px 20px 0;
  padding: 12px 0 4px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.ci-groups { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.ci-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ci-time {
  font-weight: 700; font-size: .8rem; font-variant-numeric: tabular-nums;
  color: var(--deep); flex-shrink: 0;
}
.ci-empty { font-size: .82rem; color: var(--deep-60); }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--ice); color: var(--deep);
  font-size: .8rem; font-weight: 500;
  padding: 3px 9px; border-radius: 999px;
}
.chip.mine { background: var(--deep); color: var(--white); }
.chip-x {
  border: 0; background: transparent; cursor: pointer;
  color: inherit; font-size: .75rem; line-height: 1;
  padding: 2px; opacity: .7;
}
.chip-x:hover { opacity: 1; }

.btn-checkin {
  border: 1px solid var(--deep-12); background: var(--white);
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--deep);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  flex-shrink: 0; transition: all .15s;
}
.btn-checkin:hover { border-color: var(--red); color: var(--red); }
.btn-checkin.checked { border-color: var(--deep); }

/* ---------- Dialog: výběr času ---------- */

.slot-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.slot-btn {
  border: 1px solid var(--deep-12); background: var(--ice);
  font: inherit; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--deep); padding: 12px 8px; border-radius: 10px; cursor: pointer;
  transition: all .15s;
}
.slot-btn:hover { border-color: var(--blue); background: var(--white); }
.slot-btn.active { background: var(--deep); border-color: var(--deep); color: var(--white); }

.dialog-actions-split { justify-content: space-between; }
.dialog-actions-right { display: flex; gap: 10px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { padding: 7px 14px; font-size: .85rem; }

/* ---------- Plánovač (panel z boku) ---------- */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20,55,99,.45);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(420px, 100vw);
  background: var(--white);
  box-shadow: -8px 0 40px rgba(20,55,99,.18);
  padding: 22px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .2s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 1.3rem; }
.drawer-hint { font-size: .85rem; color: var(--deep-60); margin: 8px 0 18px; }

.plan-day {
  border: 1px solid var(--deep-12);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.plan-day.planned { border-color: var(--blue); background: var(--ice); }
.plan-day.past { opacity: .55; }
.plan-head {
  font-weight: 600; font-size: .92rem; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.plan-badge {
  font-size: .72rem; font-weight: 600; color: var(--deep);
  background: var(--blue); padding: 2px 9px; border-radius: 999px;
}
.plan-body { font-size: .9rem; }
.plan-muted { color: var(--deep-60); }
.plan-controls { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.plan-controls select {
  font: inherit; font-size: .85rem; color: var(--deep);
  border: 1px solid var(--deep-12); border-radius: 8px;
  background: var(--white); padding: 7px 8px;
}
.plan-restaurant { flex: 1; min-width: 0; max-width: 100%; }

@media (max-width: 720px) {
  .summary { padding: 8px 10px; }
  .checkin-strip { margin: 4px 14px 0; }
  .drawer { padding: 16px; }
}
