/* =====================================================================
   common.css — stilet e përbashkëta për login, index (punonjësi) dhe admin.
   Struktura:
     1. Ngjyrat e temës (variablat --c-…), e çelët / e errët
     2. Rregullat e përbashkëta (butonat, kartat, fushat)
     3. Login (body.page-login)
     4. Index — radha e objekteve (body.page-index)
     5. Admin (body.page-admin)
   Tema e errët: sipas sistemit, ose e zgjedhur me butonin (localStorage "stair.theme")
   ===================================================================== */

/* ===== 1. NGJYRAT E TEMËS ===== */
:root {
  --c-bg: #f4f6f8;
  --c-surface: #fff;
  --c-surface-2: #f9fafb;
  --c-input-bg: #fff;
  --c-heading: #111827;
  --c-text: #1f2937;
  --c-label: #4b5563;
  --c-label-strong: #374151;
  --c-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-border-light: #f3f4f6;
  --c-input-border: #ccc;
  --c-th-bg: #f3f4f6;
  --c-primary: #0b6bcb;
  --c-primary-hover: #084e96;
  --c-msg: #1a8a3a;
  --c-err: #c0392b;
  --c-danger: #dc2626;
  --c-chip-bg: #e5e7eb;
  --c-backdrop: rgba(0,0,0,0.4);
  --c-ok-bg: #F0FDF4;
  --c-ok-border: #86efac;
  --c-ok-accent: #16a34a;
  --c-ok-text: #047857;
  --c-run-bg: #F0F7FC;
  --c-run-border: #93c5fd;
  --c-run-accent: #0b6bcb;
  --c-run-text: #0369a1;
  --c-line: #d1d5db;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg: #11161c;
    --c-surface: #1a2029;
    --c-surface-2: #202733;
    --c-input-bg: #151a22;
    --c-heading: #f3f4f6;
    --c-text: #e5e7eb;
    --c-label: #b8bfca;
    --c-label-strong: #d1d5db;
    --c-muted: #9ca3af;
    --c-border: #333c48;
    --c-border-light: #262e39;
    --c-input-border: #424c5a;
    --c-th-bg: #232a34;
    --c-primary: #0b6bcb;
    --c-primary-hover: #1a7fe0;
    --c-msg: #4ade80;
    --c-err: #f87171;
    --c-danger: #e04848;
    --c-chip-bg: #2b333f;
    --c-backdrop: rgba(0,0,0,0.6);
    --c-ok-bg: #14261c;
    --c-ok-border: #1f6b3a;
    --c-ok-accent: #22a355;
    --c-ok-text: #6ee7a0;
    --c-run-bg: #142231;
    --c-run-border: #2b5a85;
    --c-run-accent: #3b9ad9;
    --c-run-text: #7cc0ef;
    --c-line: #3a4452;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --c-bg: #11161c;
  --c-surface: #1a2029;
  --c-surface-2: #202733;
  --c-input-bg: #151a22;
  --c-heading: #f3f4f6;
  --c-text: #e5e7eb;
  --c-label: #b8bfca;
  --c-label-strong: #d1d5db;
  --c-muted: #9ca3af;
  --c-border: #333c48;
  --c-border-light: #262e39;
  --c-input-border: #424c5a;
  --c-th-bg: #232a34;
  --c-primary: #0b6bcb;
  --c-primary-hover: #1a7fe0;
  --c-msg: #4ade80;
  --c-err: #f87171;
  --c-danger: #e04848;
  --c-chip-bg: #2b333f;
  --c-backdrop: rgba(0,0,0,0.6);
  --c-ok-bg: #14261c;
  --c-ok-border: #1f6b3a;
  --c-ok-accent: #22a355;
  --c-ok-text: #6ee7a0;
  --c-run-bg: #142231;
  --c-run-border: #2b5a85;
  --c-run-accent: #3b9ad9;
  --c-run-text: #7cc0ef;
  --c-line: #3a4452;
  color-scheme: dark;
}

/* ===== 2. RREGULLAT E PËRBASHKËTA ===== */
* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0 auto; padding: 16px; background: var(--c-bg); color: var(--c-text); max-width: 1100px; overflow-wrap: anywhere; }
h1 { font-size: 1.4rem; color: var(--c-heading); margin: 0; }
h2 { font-size: 1.1rem; color: var(--c-text); margin: 0; }
[hidden] { display: none !important; }
svg.ico { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Shiriti i sipërm: titulli majtas, butonat djathtas */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title .who { font-size: 0.85rem; color: var(--c-muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Butonat dytësorë (stili i "Teilen"/"PDF"/"Zurück"): gri e lehtë me kornizë, blu me maus */
.btn-soft { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: auto; margin: 0; padding: 8px 14px; border-radius: 8px; background: var(--c-surface-2); color: var(--c-label-strong); border: 1px solid var(--c-border); font-family: inherit; font-weight: 600; font-size: 0.9rem; line-height: 1.2; text-decoration: none; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.btn-soft.btn-sm { padding: 6px 10px; font-size: 0.85rem; }
@media (hover: hover) { .btn-soft:hover:not(:disabled) { background: var(--c-primary); border-color: var(--c-primary); color: #fff; } }
.btn-soft:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.btn-soft:disabled { opacity: 0.5; cursor: default; }

/* Butonat kryesorë (me ngjyrë) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 11px 16px; border: 0; border-radius: 8px; background: var(--c-primary); color: #fff; font-family: inherit; font-size: 1rem; font-weight: 600; line-height: 1.2; cursor: pointer; transition: background 0.12s, opacity 0.12s; }
@media (hover: hover) { .btn:hover:not(:disabled) { background: var(--c-primary-hover); } }
.btn.success { background: var(--c-ok-accent); }
@media (hover: hover) { .btn.success:hover:not(:disabled) { background: #15803d; } }
.btn.danger { background: var(--c-danger); }
@media (hover: hover) { .btn.danger:hover:not(:disabled) { background: #b91c1c; } }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Butonat e vegjël me ikonë SVG (lart/poshtë, ndrysho, fshi): gri e lehtë me kornizë, blu me maus */
.icon-btn { width: 32px; height: 30px; min-width: 0; padding: 0; margin: 0; border-radius: 7px; border: 1px solid var(--c-border); background: var(--c-surface-2); color: var(--c-label-strong); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.icon-btn svg.ico { width: 16px; height: 16px; }
@media (hover: hover) { .icon-btn:hover:not(:disabled) { background: var(--c-primary); border-color: var(--c-primary); color: #fff; } }
.icon-btn.danger { color: var(--c-err); }
@media (hover: hover) { .icon-btn.danger:hover:not(:disabled) { background: var(--c-danger); border-color: var(--c-danger); color: #fff; } }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

/* Fushat */
label { display: block; font-size: 0.85rem; color: var(--c-label); margin: 10px 0 4px; font-weight: 600; }
input, select, textarea { width: 100%; font-size: 1rem; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--c-input-border); background: var(--c-input-bg); color: var(--c-text); font-family: inherit; margin: 0; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--c-primary); }
.check-line { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--c-text); cursor: pointer; }
/* Fushat e tekstit: gjithmonë textarea që mbështillet dhe rritet me tekstin (asnjëherë tekst i prerë).
   field-sizing: content e bën vetë (Chrome/Edge); te shfletuesit e tjerë lartësinë e llogarit JS (autosize) */
textarea.autosize { display: block; resize: none; overflow: hidden; field-sizing: content; min-height: 2.6em; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }

.card { background: var(--c-surface); border-radius: 10px; padding: 16px; margin: 16px 0; border: 1px solid var(--c-border); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.msg { color: var(--c-msg); font-weight: 600; min-height: 1.2em; margin-top: 8px; }
.err { color: var(--c-err); font-weight: 600; min-height: 1.2em; margin-top: 8px; }
.muted { color: var(--c-muted); }
.small { font-size: 0.82rem; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Kartat me palosje (<details>): të dhënat ngarkohen vetëm kur hapen */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; user-select: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ""; width: 9px; height: 9px; margin: 0 6px 4px auto; border-right: 2px solid var(--c-muted); border-bottom: 2px solid var(--c-muted); transform: rotate(45deg); transition: transform 0.25s ease; flex-shrink: 0; }
details.fold[open] > summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
details.fold > .fold-body { padding-top: 12px; }
@media (prefers-reduced-motion: reduce) { details.fold > summary::after { transition: none; } }

/* Dritarja modale */
.modal-bg { position: fixed; inset: 0; background: var(--c-backdrop); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-bg.show { display: flex; }
.modal-box { background: var(--c-surface); border-radius: 10px; padding: 20px; max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto; }
/* Dritarja e konfirmimit (confirmDialog): mbi modalet e tjera */
.confirm-bg { z-index: 1100; }
.confirm-box { max-width: 400px; border: 1px solid var(--c-border); box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.confirm-box p { margin: 10px 0 0; color: var(--c-label-strong); line-height: 1.45; }
.confirm-actions { justify-content: flex-end; margin-top: 18px; }

/* ===== 3. LOGIN ===== */
body.page-login { max-width: 400px; padding-top: 48px; }
.login-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 12px; padding: 22px; }
.login-card h1 { margin-bottom: 4px; }
.login-card .btn { width: 100%; margin-top: 16px; }
.login-notice { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--c-run-bg); border: 1px solid var(--c-run-border); color: var(--c-run-text); font-size: 0.9rem; }
.turnstile-wrap { margin-top: 14px; min-height: 65px; }
.login-theme { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* ===== 4. INDEX — radha e objekteve ("forma e linjës") ===== */
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.day-head .date { font-weight: 600; color: var(--c-label-strong); }
.progress-pill { font-size: 0.85rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--c-chip-bg); color: var(--c-label-strong); }
.progress-pill.all-done { background: var(--c-ok-accent); color: #fff; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--c-run-bg); border: 1px solid var(--c-run-border); color: var(--c-run-text); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Linja: rrethi me numër majtas, vija vertikale që i lidh, karta djathtas */
.route { list-style: none; margin: 0; padding: 0; }
.stop { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; padding-bottom: 14px; }
.stop::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: 0; border-left: 2px solid var(--c-line); }
.stop:last-child::before { display: none; }
.stop-num { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--c-surface); border: 2px solid var(--c-line); color: var(--c-label-strong); position: relative; z-index: 1; }
.stop-num svg.ico { width: 18px; height: 18px; stroke-width: 3; }
.stop-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.stop-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-muted); }
.stop-name { font-size: 1.05rem; font-weight: 700; color: var(--c-heading); margin: 2px 0; }
.stop-addr { white-space: pre-line; color: var(--c-label-strong); }
.stop-status { margin-top: 6px; font-size: 0.9rem; font-weight: 600; }
.stop-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.stop-actions .btn { flex: 1 1 180px; }
.stop-actions .btn-soft { flex: 0 1 auto; padding: 11px 14px; font-size: 1rem; }
/* E pastruar: jeshile */
.stop.done .stop-card { background: var(--c-ok-bg); border-color: var(--c-ok-border); border-left: 4px solid var(--c-ok-accent); }
.stop.done .stop-num { background: var(--c-ok-accent); border-color: var(--c-ok-accent); color: #fff; }
.stop.done::before { border-left-color: var(--c-ok-accent); }
.stop.done .stop-status { color: var(--c-ok-text); }
/* Në pastrim: blu */
.stop.running .stop-card { background: var(--c-run-bg); border-color: var(--c-run-border); border-left: 4px solid var(--c-run-accent); }
.stop.running .stop-num { background: var(--c-run-accent); border-color: var(--c-run-accent); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.stop.running .stop-status { color: var(--c-run-text); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(59,154,217,0.55); } 50% { box-shadow: 0 0 0 8px rgba(59,154,217,0); } }
@media (prefers-reduced-motion: reduce) { .stop.running .stop-num { animation: none; } }
.empty { text-align: center; padding: 28px 12px; color: var(--c-muted); }
/* Stopp: një kartë me disa adresa (secila me navigimin e vet) */
.stopp-list { list-style: none; margin: 8px 0 0; padding: 0; }
.stopp-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--c-border); }
.stopp-obj { min-width: 0; flex: 1; }
.stopp-obj strong { font-size: 0.92rem; color: var(--c-heading); }
.stopp-obj .stop-addr { font-size: 0.88rem; }
.stopp-list .btn-soft { flex-shrink: 0; }
.stop.is-stopp .stop-num { border-radius: 10px; }
/* Fahrzeit mes dy objekteve: rresht i vogël me vijë të ndërprerë në linjë; live = blu */
.travel-row { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; padding: 0 0 14px; }
.travel-row::before { content: ""; position: absolute; left: 17px; top: -14px; bottom: 0; border-left: 2px dashed var(--c-line); }
.travel-row:last-child::before { bottom: 14px; }
.travel-text { grid-column: 2; display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--c-muted); }
.travel-text svg.ico { width: 15px; height: 15px; }
.travel-row.live .travel-text { color: var(--c-run-text); }

/* ===== 5. ADMIN ===== */
.page-admin details.card > summary h2 { flex: 1; }
.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--c-chip-bg); color: var(--c-label-strong); white-space: nowrap; }
.badge.off { color: var(--c-muted); }
.badge:empty { display: none; }
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter-row > div { flex: 1 1 140px; }
.filter-row label { margin-top: 0; }

/* Tabela e pastrimeve; në celular rreshtat bëhen blloqe (pa scroll horizontal) */
.day-group { margin-top: 16px; }
.day-group h3 { font-size: 0.95rem; margin: 0 0 6px; padding-bottom: 6px; border-bottom: 2px solid var(--c-border); color: var(--c-text); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.day-group h3 span { font-weight: 500; color: var(--c-muted); font-size: 0.85rem; }
table.list { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--c-border-light); vertical-align: top; }
table.list th { background: var(--c-th-bg); color: var(--c-label-strong); font-weight: 600; white-space: nowrap; }
table.list td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list td.act { width: 1%; text-align: right; }
.visit-objs { display: block; font-size: 0.8rem; color: var(--c-muted); font-weight: 500; margin-top: 2px; white-space: normal; }
/* Objekte: blloku i një Stopp-i (njësi në radhën e grupit) me objektet e tij */
.stopp-block { border: 1px dashed var(--c-run-border); border-left: 4px solid var(--c-run-accent); border-radius: 10px; padding: 8px; background: var(--c-surface); display: flex; flex-direction: column; gap: 6px; }
.stopp-head { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.stopp-num { border-radius: 8px; border-color: var(--c-run-accent); }
/* Gruppen: lista e Stopp-eve dhe forma për Stopp të ri */
.stop-admin-list { display: flex; flex-direction: column; gap: 6px; }
.stop-edit, .stop-add { display: flex; align-items: center; gap: 6px; }
.stop-edit textarea, .stop-add textarea { flex: 1; min-width: 0; padding: 7px 10px; min-height: 0; }
.stop-add { margin-top: 8px; }
.stop-add .btn-soft { white-space: nowrap; }
.worker-head { font-size: 0.85rem; font-weight: 700; color: var(--c-label-strong); margin: 12px 0 4px; }
/* Rreshti ndarës Fahrzeit mes dy pastrimeve (admin) */
table.list tr.travel-tr td { padding: 3px 10px; border-bottom: 1px solid var(--c-border-light); font-size: 0.8rem; font-weight: 600; color: var(--c-run-text); background: var(--c-surface-2); }
table.list tr.travel-tr td svg.ico { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
.running-txt { color: var(--c-run-text); font-weight: 600; }
@media (max-width: 640px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border: 1px solid var(--c-border); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; position: relative; }
  table.list td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; }
  table.list td::before { content: attr(data-label); color: var(--c-muted); font-size: 0.8rem; font-weight: 600; }
  table.list td.act { position: absolute; top: 6px; right: 8px; width: auto; display: block; padding: 0; }
  table.list td.act::before { content: none; }
  table.list td:first-child { padding-right: 40px; }
  /* Fahrzeit në celular: rresht i vogël mes dy kartave, jo kartë më vete */
  table.list tr.travel-tr { border: 0; padding: 0 0 8px 12px; margin: -2px 0 6px; }
  table.list tr.travel-tr td { display: block; padding: 0 0 0 10px; background: none; border-bottom: 0; border-left: 2px dashed var(--c-line); }
  table.list tr.travel-tr td::before { content: none; }
}

/* Objektet / përdoruesit: lista me palosje të brendshme */
.item-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
details.item { border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-surface-2); }
details.item > summary { padding: 10px 12px; }
details.item > .fold-body { padding: 0 12px 12px; }
details.item.inactive > summary { opacity: 0.6; }
.item-num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; background: var(--c-surface); border: 2px solid var(--c-line); flex-shrink: 0; }
.item-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-title strong { color: var(--c-text); }
.item-title .sub { font-size: 0.82rem; color: var(--c-muted); white-space: pre-line; }
.item-move { display: flex; gap: 4px; }
.sub-head { font-size: 0.9rem; font-weight: 700; color: var(--c-label-strong); margin: 16px 0 6px; }
.add-box { border-top: 1px solid var(--c-border); margin-top: 14px; padding-top: 4px; }
@media (max-width: 480px) {
  .item-title .sub { display: none; }
}

/* ===== 6. DELETED — objektet e fshira (body.page-deleted) ===== */
.del-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border: 1px dashed var(--c-input-border); border-radius: 10px; background: var(--c-surface-2); }
.del-main { flex: 1 1 240px; min-width: 0; }
.del-main strong { color: var(--c-heading); }
.del-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 8px 0 0; font-size: 0.85rem; }
.del-facts dt { color: var(--c-muted); }
.del-facts dd { margin: 0; color: var(--c-text); }
.err-text { color: var(--c-err); font-weight: 600; }
.del-item .btn { flex: 0 0 auto; }
@media (max-width: 480px) { .del-item .btn { flex: 1 1 100%; } }
