:root {
  --bg: #14171c;
  --panel: #1c2129;
  --panel-2: #232a34;
  --line: #2c343f;
  --text: #e7ecf3;
  --muted: #8b96a8;
  --primary: #4f8cff;
  --primary-2: #2f6fe0;
  --danger: #ff5c6c;
  --ok: #2ecc71;
  --warn: #f5a623;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  background: var(--primary);
  color: white;
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  touch-action: manipulation;
}
button:hover { background: var(--primary-2); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.warn { background: var(--warn); color: #111; }
button.ok { background: var(--ok); color: #0e1a12; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 16px; /* 16px prevents iOS zoom-on-focus */
  font-family: inherit;
  width: 100%;
  max-width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 10px; min-width: 0; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

/* Kompakten row brez flex:1 — vsak otrok zavzame svojo naravno širino. */
.compact-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.compact-row .grow { flex: 1; min-width: 0; }
.compact-row > button { flex: 0 0 auto; }

/* Gumb-povezava (za <a> ki izgleda kot gumb) */
.btn-link {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.btn-link:hover { background: var(--panel-2); text-decoration: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
h1, h2, h3 { margin: 0 0 10px 0; overflow-wrap: anywhere; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
small { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 12px; }
.badge.role-zaposlen { background: #1d3a5a; color: #b3d4ff; }
.badge.role-sp       { background: #2e3a1d; color: #d8e9ad; }
.badge.role-polovicni_sp { background: #2e3a1d; color: #d8e9ad; }
.badge.role-student  { background: #3a1d3a; color: #e9adde; }
.badge.role-admin    { background: #3a2a1d; color: #f0c97a; }

/* ----- Layout ----- */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-weight: 500;
}
.nav button.active { background: var(--panel-2); }
.nav button:hover { background: var(--panel-2); }
.main {
  padding: 22px;
  padding-left: max(22px, env(safe-area-inset-left));
  padding-right: max(22px, env(safe-area-inset-right));
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  max-width: 1200px;
  min-width: 0;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav button { flex: 1 1 calc(50% - 4px); font-size: 13px; padding: 10px 8px; }
}

@media (max-width: 600px) {
  body { font-size: 14px; }
  .main { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .card { padding: 12px; margin-bottom: 10px; border-radius: 8px; }
  h2 { font-size: 17px; }
  h3 { font-size: 13px; }
  .nav button { flex: 1 1 calc(50% - 4px); font-size: 13px; }
  .row { gap: 8px; }
  .row > * { flex: 1 1 100%; }
  .compact-row { gap: 8px; }
  .compact-row > button { flex: 1 1 auto; }
  button, .btn-link { padding: 10px 12px; font-size: 14px; }
}

@media (max-width: 400px) {
  .nav button { flex: 1 1 100%; }
  .main { padding: 10px; }
  .card { padding: 10px; }
}

/* ----- Login ----- */
.login-wrap {
  max-width: 380px;
  width: calc(100% - 24px);
  margin: 12vh auto;
  padding: 28px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.login-wrap h1 { text-align: center; margin-bottom: 18px; }

@media (max-width: 600px) {
  .login-wrap { margin: 6vh auto; padding: 20px; }
}

/* ----- Push gate ----- */
.push-gate {
  max-width: 520px;
  width: calc(100% - 24px);
  margin: 8vh auto;
  padding: 28px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  text-align: center;
}

@media (max-width: 600px) {
  .push-gate { margin: 4vh auto; padding: 18px; }
}

/* ----- Schedule table ----- */
.sched-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
.sched-side { min-width: 0; }
@media (max-width: 1100px) {
  .sched-layout { grid-template-columns: 1fr; }
}

.sched-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
  padding-bottom: 6px;
}
.sched-grid {
  display: grid;
  grid-template-columns: 110px repeat(7, minmax(90px, 1fr));
  gap: 4px;
  font-size: 13px;
  min-width: 760px;
}
.sched-cell {
  background: var(--panel-2);
  border-radius: 6px;
  padding: 8px;
  min-height: 56px;
  overflow-wrap: anywhere;
}
.sched-cell.head { background: transparent; color: var(--muted); padding: 4px 6px; }
.sched-cell .shift-time { font-weight: 700; }
.sched-cell .who { color: var(--muted); font-size: 12px; }
.sched-cell.empty { background: #2a1d1d; }
.sched-cell.editing { outline: 2px solid var(--primary); }

@media (max-width: 600px) {
  .sched-grid {
    grid-template-columns: 80px repeat(7, minmax(80px, 1fr));
    min-width: 660px;
    font-size: 12px;
    gap: 3px;
  }
  .sched-cell { padding: 6px; min-height: 48px; }
  .sched-cell .who { font-size: 11px; }
}

/* ----- Avail panel (kdo je na voljo, ob urniku za admina) ----- */
.avail-panel { position: sticky; top: 8px; padding: 12px; margin: 0; max-height: calc(100vh - 24px); overflow-y: auto; }
.avail-panel h3 { margin: 0 0 4px 0; }
.avail-panel-meta { font-size: 12px; margin-bottom: 8px; }
.avail-panel-list { display: flex; flex-direction: column; gap: 8px; }
.avail-person {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 10px;
}
.avail-person-head { margin-bottom: 6px; }
.avail-person-days { display: flex; flex-direction: column; gap: 2px; }
.avail-day-row { display: flex; gap: 8px; font-size: 12px; line-height: 1.4; }
.avail-day-label { color: var(--muted); width: 36px; flex-shrink: 0; text-transform: capitalize; }
.avail-day-times { flex: 1; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .avail-panel { position: static; max-height: none; }
}

/* ----- Avail picker ----- */
.avail-day { background: var(--panel-2); padding: 10px; border-radius: var(--radius); margin-bottom: 8px; }
.avail-day h4 { margin: 0 0 6px 0; }
.avail-options { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  touch-action: manipulation;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.chip.any { border-color: var(--warn); color: var(--warn); }
.chip.any.active { background: var(--warn); color: #111; }

@media (max-width: 600px) {
  .chip { padding: 8px 12px; font-size: 13px; }
}

/* ----- Lists ----- */
.list-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.list-item.done { opacity: .6; text-decoration: line-through; }
.list-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ----- Notices ----- */
.notice {
  border-left: 4px solid var(--line);
  background: var(--panel-2);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.notice.urgent { border-left-color: var(--danger); background: #2a1d22; }

/* ----- Recipes ----- */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.recipe-card {
  background: var(--panel-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.recipe-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.recipe-card .pad { padding: 10px; }

@media (max-width: 400px) {
  .recipes-grid { grid-template-columns: 1fr; }
}

/* ----- Howto ----- */
.howto-list .item {
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.howto-list .item:hover { background: var(--line); }
.howto-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.howto-imgs img { max-width: 200px; max-height: 140px; border-radius: 6px; }

@media (max-width: 600px) {
  .howto-imgs img { max-width: 100%; }
}

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 0; }

@media (max-width: 600px) {
  .toolbar { gap: 6px; }
  .toolbar > button, .toolbar > .btn-link { flex: 1 1 auto; }
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
.modal h2 { margin-top: 0; }
.modal .row.actions { justify-content: flex-end; margin-top: 12px; }
.modal .row.actions > * { flex: 0; }

@media (max-width: 600px) {
  .modal { padding: 14px; border-radius: 8px; }
  .modal .row.actions { justify-content: stretch; }
  .modal .row.actions > * { flex: 1 1 auto; }
}

.muted { color: var(--muted); }
.spacer { height: 8px; }
.error { color: var(--danger); margin-top: 6px; font-size: 13px; overflow-wrap: anywhere; }
.ok-msg { color: var(--ok); margin-top: 6px; font-size: 13px; }

/* ----- Timeline (grafični pregled urnika) ----- */
.timeline-modal { max-width: 1100px; width: 100%; }
.timeline-body { overflow: auto; -webkit-overflow-scrolling: touch; }
.timeline-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(110px, 1fr));
  gap: 0;
  min-width: 820px;
}
.timeline-corner, .timeline-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 6px 4px;
  text-align: center;
}
.timeline-head { border-left: 1px solid var(--line); }
.timeline-hours {
  position: relative;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.timeline-hour-label {
  position: absolute;
  left: 0; right: 4px;
  transform: translateY(-50%);
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}
.timeline-col {
  position: relative;
  background: var(--panel-2);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.timeline-hline {
  position: absolute;
  left: 0; right: 0; height: 1px;
  background: var(--line);
  opacity: .5;
}
.timeline-block {
  position: absolute;
  /* `left` se nastavi inline (zaradi globine prekrivanja); right stalno 3px. */
  right: 3px;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  border: 2px solid transparent;
}
.timeline-block.continuation { opacity: .85; border-style: dashed; border-color: rgba(255,255,255,.5); }
/* Bloku, ki ga prekrije kasneje začet blok, narišemo prekinjeno obrobo, da se vidi
   kako daleč seže pod naslednjim. */
.timeline-block.covered-by-later {
  border-style: dashed;
  border-color: rgba(255,255,255,.85);
}
.timeline-block-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-block-time { font-size: 10px; opacity: .85; }
.timeline-block.role-zaposlen     { background: #2a6fd0; }
.timeline-block.role-sp           { background: #5a8e2a; }
.timeline-block.role-polovicni_sp { background: #4d7d24; }
.timeline-block.role-student      { background: #8b3aa0; }
.timeline-block.role-admin        { background: #b07a2a; }

/* ----- Urnik po osebah (matrika oseba × dan) ----- */
.by-person-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}
.by-person-table th, .by-person-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
  background: var(--panel-2);
}
.by-person-table thead th {
  position: sticky; top: 0;
  background: var(--panel);
  z-index: 1;
}
.by-person-table .bp-name-head {
  text-align: left;
}
.by-person-table .bp-name {
  text-align: left;
  background: var(--panel);
  white-space: nowrap;
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 1;
}
.by-person-table .bp-on { font-weight: 700; }
.by-person-table .bp-off { color: var(--muted); opacity: .6; }

@media (max-width: 600px) {
  .by-person-table { font-size: 12px; min-width: 560px; }
  .by-person-table th, .by-person-table td { padding: 4px 6px; }
}
