/* ==========================================================================
   Komponenty společné pro veřejný web i portály
   ========================================================================== */

/* ---------- Tlačítka ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  background: var(--z-100); color: var(--z-900);
  border: 1px solid transparent; border-radius: var(--r);
  font-size: 0.875rem; font-weight: 500; line-height: 1; white-space: nowrap; text-align: center;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--z-200); }
.btn .ti { width: 1.1em; height: 1.1em; vertical-align: 0; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-hover); }
.btn-outline { background: #fff; border-color: var(--z-300); }
.btn-outline:hover { background: var(--z-100); }
.btn-ghost { background: transparent; color: var(--z-600); }
.btn-ghost:hover { background: var(--z-100); color: var(--z-900); }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-danger:hover { background: #f9d7dd; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #8e0f25; }

/* ---------- Skupiny tlačítek: záporné vlevo, neutrální uprostřed, kladné vpravo ----------
   Záporné (.btn-neg: zamítnout, odmítnout, zrušit, smazat) jdou první a drží se vlevo. Neutrální (outline, ghost) následují;
   když záporné není, drží se taky vlevo. Kladné (.btn-primary, .btn-danger-solid, nebo .btn-pos) se tlačí doprava.
   Je-li ve skupině záporné i neutrální i kladné, neutrální se vycentruje mezi ně. Pořadí v HTML nehraje roli. */
.action-row, .drawer-footer, .confirm-box .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.action-row > .btn, .drawer-footer > .btn, .confirm-box .row > .btn { order: 2; }
.action-row > .btn-neg, .drawer-footer > .btn-neg, .confirm-box .row > .btn-neg { order: 1; }
.action-row > :is(.btn-primary, .btn-danger-solid, .btn-pos):not(.btn-neg),
.drawer-footer > :is(.btn-primary, .btn-danger-solid, .btn-pos):not(.btn-neg),
.confirm-box .row > :is(.btn-primary, .btn-danger-solid, .btn-pos):not(.btn-neg) { order: 3; margin-left: auto; }
:is(.action-row, .drawer-footer, .confirm-box .row):has(> .btn-neg):has(> .btn:not(.btn-neg, .btn-primary, .btn-danger-solid, .btn-pos)) > .btn:not(.btn-neg, .btn-primary, .btn-danger-solid, .btn-pos) { margin-inline: auto; }
:is(.action-row, .drawer-footer, .confirm-box .row):has(> .btn-neg):has(> .btn:not(.btn-neg, .btn-primary, .btn-danger-solid, .btn-pos)) > :is(.btn-primary, .btn-danger-solid, .btn-pos):not(.btn-neg) { margin-left: 0; }
.btn-neg { color: var(--danger); }
.btn-neg:hover { color: var(--danger); background: var(--danger-tint); }
@media (max-width: 480px) {
  .action-row, .drawer-footer, .confirm-box .row { gap: 8px; }
  .action-row > .btn:not(.btn-sm), .drawer-footer > .btn, .confirm-box .row > .btn { flex: 1 1 auto; justify-content: center; }
}
.btn-sm { height: 32px; padding: 0 10px; font-size: 0.82rem; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-full { display: flex; width: 100%; }
.btn:disabled, .btn[disabled], .btn-next:disabled { opacity: .5; cursor: not-allowed; }
.btn-cta {
  height: 52px; padding: 0 28px; font-size: 1.0625rem; font-weight: 600;
  background: var(--cta); color: #fff; border-radius: var(--r-lg);
}
.btn-cta:hover { background: var(--cta-hover); }

/* ---------- Formuláře ---------- */
.form-group { margin-bottom: 16px; }
.form-group > label, .form-group > .label {
  display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; color: var(--z-900);
}
.form-group input.error, .form-group select.error, .form-group textarea.error { border-color: #c4283f; }
.error-msg { display: block; margin-top: 4px; color: var(--danger); font-size: 0.8125rem; }
.hint { font-size: 0.8125rem; color: var(--z-600); }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }
.form-row > .form-group[style*="flex"] { grid-column: auto; }
@media (max-width: 540px) { .form-row { grid-template-columns: minmax(0, 1fr); } }
.form-section-head {
  margin: 32px 0 16px; padding-top: 24px; border-top: 1px solid var(--z-200);
  font-size: 1.0625rem; font-weight: 600; color: var(--z-900); letter-spacing: -0.005em;
}
.form-panel > .form-section-head:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.check-row, label.wrap-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 400; }
.check-row { align-items: flex-start; line-height: 1.45; }
.check-row > input[type=checkbox], .check-row > input[type=radio] { flex: none; margin-top: 0.2em; }
label.wrap-label span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
label.wrap-label input[type="checkbox"] { margin-top: 3px; }
.info-banner {
  padding: 12px 16px; margin-bottom: 16px; font-size: 0.88rem;
  background: var(--ink-tint); border-left: 3px solid var(--ink); border-radius: var(--r);
}
.info-banner.warn { background: var(--warn-bg); border-left-color: #f9a825; }
.loading-screen { padding: 56px 16px; text-align: center; color: var(--z-600); }
.loading-screen .ti { display: block; width: 36px; height: 36px; margin: 0 auto 14px; }

/* ---------- Štítky stavů ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 0.78rem; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--z-100); color: var(--z-600); vertical-align: middle;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-verified, .badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-pending, .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-sent, .badge-info { background: var(--info-bg); color: var(--info); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Karty a tabulky ---------- */
.card { background: #fff; border: 1px solid var(--z-200); border-radius: var(--r-lg); overflow: hidden; }
.data-table-card { background: #fff; border: 1px solid var(--z-200); border-radius: var(--r-lg); overflow: hidden; }
.data-table-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--z-200);
}
.data-table-head h3 { font-size: 1rem; font-weight: 600; }
.data-table-wrap { overflow-x: auto; }
table.data-table { width: 100%; font-size: 0.9rem; }
.data-table th {
  padding: 10px 16px; text-align: left; white-space: nowrap;
  background: var(--z-50); border-bottom: 1px solid var(--z-200);
  font-size: 0.78rem; font-weight: 600; color: var(--z-600);
}
.data-table td { padding: 12px 16px; border-top: 1px solid var(--z-200); vertical-align: middle; }
.data-table tr:hover td { background: var(--z-50); }
.search-input { min-width: 220px; max-width: 100%; height: 36px; font-size: 0.9rem; }

/* ---------- Filtry a štítky ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  background: var(--ink-tint); color: var(--ink); border-radius: 999px; font-size: 0.78rem; font-weight: 500;
}
.chip button { background: none; border: 0; color: var(--ink); padding: 0; font-size: 0.9rem; line-height: 1; }

/* ---------- Panel (drawer) — formuláře a detaily v administraci ---------- */
.drawer-overlay { display: none; position: fixed; inset: 0; z-index: 1400; background: rgba(24, 24, 27, .45); }
.drawer-overlay.active { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 100%);
  display: flex; flex-direction: column; background: #fff; box-shadow: var(--shadow-pop);
  animation: drawer-in .22s var(--ease);
}
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-header { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--z-200); }
.drawer-header h3 { flex: 1; min-width: 0; font-size: 1.125rem; font-weight: 700; overflow-wrap: anywhere; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer { padding: 14px 20px; border-top: 1px solid var(--z-200); background: var(--z-50); }

/* ---------- Dialogy (modální okna) ---------- */
.modal-overlay, .org-detail-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000; padding: 16px;
  align-items: center; justify-content: center; background: rgba(24, 24, 27, .5); overflow-y: auto;
}
.modal-overlay.open, .modal-overlay.active, .org-detail-overlay.open, .org-detail-overlay.active { display: flex; }
.modal-box, .org-detail-box {
  display: flex; flex-direction: column; width: 100%; max-width: 620px; max-height: calc(100vh - 32px);
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow-y: auto;
}
.modal-head, .org-detail-header { display: flex; align-items: flex-start; gap: 14px; padding: 20px 24px 14px; border-bottom: 1px solid var(--z-200); }
.modal-head h2, .modal-head h3, .org-detail-header h3 { margin: 0 0 2px; font-size: 1.125rem; font-weight: 700; }
.modal-head p, .org-detail-header p { font-size: 0.82rem; color: var(--z-600); }
.org-detail-header > .ti { width: 32px; height: 32px; color: var(--ink); flex-shrink: 0; }
.modal-body { padding: 20px 24px; }
.modal-foot, .org-detail-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--z-200); background: var(--z-50); }
.org-detail-footer .btn-ghost, .modal-foot .btn-ghost { background: #fff; border: 1px solid var(--z-300); color: var(--z-900); }
.org-detail-footer .btn-primary { background: var(--ink); color: #fff; }
.od-details { margin: 0; padding: 4px 24px; border-bottom: 1px solid var(--z-200); }
.od-detail-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--z-100); }
.od-detail-row:last-child { border-bottom: 0; }
.od-detail-row dt { font-size: 0.84rem; color: var(--z-600); }
.od-detail-row dd { font-size: 0.9rem; font-weight: 500; overflow-wrap: anywhere; }
.od-detail-row a { color: var(--sky-text); }
#od-map { height: 260px; flex-shrink: 0; }
.redirect-modal-body { padding: 20px 24px; font-size: 0.9rem; color: var(--z-600); border-bottom: 1px solid var(--z-200); }
.redirect-modal-body p + p { margin-top: 12px; }
.redirect-modal-url { padding: 10px 12px; background: var(--z-100); border-radius: var(--r); font-family: ui-monospace, monospace; font-size: 0.85rem; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Hlášky ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 3000; display: flex; align-items: center; gap: 10px;
  max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px;
  background: var(--z-900); color: #fff; border-radius: var(--r); box-shadow: var(--shadow-pop);
  font-size: 0.9rem; font-weight: 500;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }
.toast.success { background: #14532d; }

/* ---------- Přepínač ---------- */
.toggle-switch { position: relative; display: inline-block; flex-shrink: 0; width: 44px; height: 24px; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-slider { position: absolute; inset: 0; background: var(--z-300); border-radius: 24px; transition: background .15s; pointer-events: none; }
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s var(--ease);
}
.toggle-switch input:checked + .toggle-slider { background: var(--ink); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Záložky šablon e-mailů ---------- */
.tpl-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px;
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  font-size: 0.84rem; font-weight: 500; color: var(--z-600); white-space: nowrap;
}
.tpl-tab:hover { color: var(--z-900); }
.tpl-tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Podpis (signature_pad) ---------- */
.sig-canvas-wrap { position: relative; background: #fff; border: 2px dashed var(--z-300); border-radius: var(--r-lg); overflow: hidden; }
.sig-canvas-wrap canvas { display: block; width: 100%; height: 160px; touch-action: none; }
.sig-controls { display: flex; gap: 8px; margin-top: 8px; }
.sig-controls button {
  height: 32px; padding: 0 14px; background: #fff; border: 1px solid var(--z-300); border-radius: var(--r);
  font-size: 0.85rem; color: var(--z-900);
}
.sig-controls button:hover { background: var(--z-100); }
.sig-label { margin-bottom: 8px; font-size: 0.875rem; font-weight: 500; }
.sig-block { padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--z-200); }
.sig-block:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.sig-agreement-text {
  padding: 14px 16px; margin-bottom: 12px; font-size: 0.84rem; line-height: 1.7;
  background: #fff; border: 1px solid var(--z-200); border-radius: var(--r-lg);
}
.sig-agreement-text p + p { margin-top: 10px; }
.sig-confirm-check {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 10px 14px; cursor: pointer;
  font-size: 0.88rem; background: var(--ink-tint); border-left: 3px solid var(--ink); border-radius: var(--r);
}
.sig-confirm-check input { margin-top: 3px; }

/* ---------- Tlačítko zpět nahoru ---------- */
.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  background: var(--ink); color: #fff; border: 2px solid #fff; border-radius: 50%; box-shadow: var(--shadow-pop), 0 0 0 1px rgba(1, 0, 102, .25);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s var(--ease), transform .2s var(--ease), visibility .2s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: #0a0a8a; }
.to-top .ti { width: 20px; height: 20px; }
@media (max-width: 900px) { body:has(.register-nav) .to-top { bottom: 84px; } }

/* ---------- Kontrola adresy v registru ---------- */
.addr-check { margin: -4px 0 18px; padding: 10px 14px; border-radius: var(--r); font-size: 0.875rem; line-height: 1.45; border: 1px solid transparent; }
.addr-check.info { background: var(--z-100); color: var(--z-700); }
.addr-check.ok   { background: var(--ok-bg); color: var(--ok); }
.addr-check.warn { background: var(--warn-bg); color: var(--warn); }
.addr-check-line { display: flex; align-items: flex-start; gap: 8px; }
.addr-check-line i { margin-top: 3px; flex-shrink: 0; }
.addr-check.info .ti-loader-2 { animation: addr-spin 1s linear infinite; }
@keyframes addr-spin { to { transform: rotate(360deg); } }
.addr-check-note { margin-top: 6px; padding-left: 26px; color: var(--warn); }
.addr-check-opts { display: grid; gap: 6px; margin-top: 8px; }
.addr-check-opt {
  padding: 9px 12px; text-align: left; background: #fff; color: var(--z-900);
  border: 1px solid var(--z-300); border-radius: var(--r); font-size: 0.875rem;
}
.addr-check-opt:hover { border-color: var(--ink); }
.addr-check-confirm { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; cursor: pointer; }
.addr-check-confirm input { margin-top: 3px; }

/* ---------- Stavové obrazovky ---------- */
.success-screen { padding: 56px 24px; text-align: center; }
.success-screen .success-icon {
  display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 22px;
  border-radius: 50%; background: var(--ok-bg); color: var(--ok);
}
.success-screen .success-icon .ti { width: 34px; height: 34px; }
.success-screen h2 { margin-bottom: 12px; font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.success-screen p { margin-bottom: 8px; color: var(--z-600); }

/* ---------- Mapa (Leaflet) ---------- */
.map { height: 380px; background: #f7f9fc; border: 1px solid var(--z-300); border-radius: var(--r-lg); overflow: hidden; }
.map .leaflet-container, .map.leaflet-container { background: #f7f9fc; font-family: inherit; }
.map-loading { display: flex; align-items: center; justify-content: center; gap: 8px; height: 100%; color: var(--z-600); font-size: 0.9rem; }
.leaflet-tooltip { font-family: inherit; font-size: 0.8125rem; font-weight: 500; border: 0; border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }

/* ---------- Pruhy: testovací režim a údržba ---------- */
.test-mode-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 950; height: 36px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #b45309; color: #fff; font-size: 0.84rem; font-weight: 600;
}
.test-mode-banner .ti { width: 16px; height: 16px; }
.tmb-short { display: none; }
@media (max-width: 600px) { .tmb-full { display: none; } .tmb-short { display: inline; } .test-mode-banner { font-size: 0.78rem; } }
body.test-mode-active { padding-top: 36px; }
body.test-mode-active .pub-head, body.test-mode-active .topbar { top: 36px; }
body.test-mode-active .sidebar { top: calc(var(--topbar-h) + 36px); height: calc(100vh - var(--topbar-h) - 36px); }

.maintenance-overlay { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--paper); }
.maint-box { width: 100%; max-width: 480px; padding: 44px 36px; text-align: center; background: #fff; border: 1px solid var(--z-200); border-radius: var(--r-lg); }
.maint-box h1 { margin-bottom: 12px; font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.maint-box p { margin-bottom: 8px; color: var(--z-600); }
.maint-until { margin-top: 20px; }
.maint-until strong { color: var(--z-900); }

/* ---------- Souhlas se zpracováním osobních údajů ---------- */
.consent-text {
  max-height: 320px; overflow-y: auto; margin-bottom: 16px; padding: 14px 16px;
  background: var(--z-50); border: 1px solid var(--z-200); border-radius: var(--r); font-size: 0.88rem; line-height: 1.75;
}
.consent-text-tall { max-height: 60vh; margin-bottom: 0; background: #fff; border: 0; padding: 0; font-size: 0.9rem; }
.consent-text p + p { margin-top: 8px; }
.consent-check { padding: 12px 14px; background: var(--ink-tint); border-radius: var(--r); font-size: 0.88rem; }
.modal-head > .ti { width: 24px; height: 24px; margin-top: 2px; color: var(--ink); flex-shrink: 0; }
.maint-logo { display: block; max-width: 220px; max-height: 80px; margin: 0 auto 28px; object-fit: contain; }
#od-map, #od-map.leaflet-container { background: #f7f9fc; }
.sig-block > .form-section-head:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
