/* ==========================================================================
   COV Onboarding — vizuální styl
   Navazuje na ČOV Podpora: DM Sans, olympijská paleta, skleněné karty.
   ========================================================================== */

:root {
  --olympic-blue: #0081c8;
  --olympic-yellow: #fcb131;
  --olympic-green: #00a651;
  --olympic-red: #ee334e;
  --olympic-black: #111827;

  --ink: #111827;
  --ink-muted: #6b7280;
  --ink-faint: #9ca3af;
  --line: #e5e7eb;

  --surface: rgba(255, 255, 255, 0.85);
  --surface-solid: #ffffff;
  --page: #eef1f5;

  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 12px;

  --shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.05);
  --shadow: 0 8px 32px rgba(17, 24, 39, 0.08), 0 0 0 1px rgba(17, 24, 39, 0.02);
  --shadow-lg: 0 20px 48px rgba(17, 24, 39, 0.12);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background: var(--page);
  color: var(--ink);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Jemné olympijské pozadí — kruhy v barvách, hodně rozostřené. */
.bg-rings {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.bg-rings span {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.28;
  animation: drift 26s ease-in-out infinite;
}
.bg-rings span:nth-child(1) { width: 460px; height: 460px; background: var(--olympic-blue);   top: -120px; left: -80px; }
.bg-rings span:nth-child(2) { width: 380px; height: 380px; background: var(--olympic-yellow); top: 12%; right: -100px; animation-delay: -6s; }
.bg-rings span:nth-child(3) { width: 420px; height: 420px; background: var(--olympic-green);  bottom: -140px; left: 22%; animation-delay: -12s; }
.bg-rings span:nth-child(4) { width: 300px; height: 300px; background: var(--olympic-red);    bottom: 8%; right: 14%; animation-delay: -18s; opacity: 0.2; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.08); }
  66%      { transform: translate(-30px, 25px) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-rings span { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Skleněné plochy ------------------------------------------------------ */

.glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.card {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.card-hover {
  transition: transform 0.4s var(--ease-spring), box-shadow 0.4s var(--ease-out);
}
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* --- Tlačítka ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--olympic-blue), #0068a3);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 129, 200, 0.32);
}
.btn-primary:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 129, 200, 0.4); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:not(:disabled):hover { background: #fff; border-color: var(--ink-faint); }

.btn-success { background: var(--olympic-green); color: #fff; }
.btn-success:not(:disabled):hover { filter: brightness(1.08); }

.btn-danger { background: #fff; color: var(--olympic-red); border-color: #fecdd3; }
.btn-danger:not(:disabled):hover { background: #fff1f2; }

.btn-sm { padding: 0.5rem 0.85rem; font-size: 0.875rem; }

/* --- Formuláře ------------------------------------------------------------ */

.field {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus {
  outline: none;
  border-color: var(--olympic-blue);
  box-shadow: 0 0 0 3px rgba(0, 129, 200, 0.14);
}
.field::placeholder { color: var(--ink-faint); }

.label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 0.4rem;
}

/* Pole na kód — velké, monospace, aby se dobře opisovalo z e-mailu. */
.field-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
  padding: 1rem;
}

/* --- Kroky onboardingu ---------------------------------------------------- */

.step {
  display: flex;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  transition: all 0.3s var(--ease-out);
}
.step:hover { background: #fff; border-color: #d1d5db; }

.step-done {
  background: rgba(0, 166, 81, 0.06);
  border-color: rgba(0, 166, 81, 0.28);
}
.step-failed {
  background: rgba(238, 51, 78, 0.05);
  border-color: rgba(238, 51, 78, 0.3);
}
.step-blocked {
  background: rgba(252, 177, 49, 0.08);
  border-color: rgba(252, 177, 49, 0.4);
}
.step-running {
  border-color: var(--olympic-blue);
  box-shadow: 0 0 0 3px rgba(0, 129, 200, 0.12);
}

.step-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(0, 129, 200, 0.1);
  color: var(--olympic-blue);
}
.step-done .step-icon    { background: rgba(0, 166, 81, 0.14);  color: var(--olympic-green); }
.step-failed .step-icon  { background: rgba(238, 51, 78, 0.12); color: var(--olympic-red); }
.step-blocked .step-icon { background: rgba(252, 177, 49, 0.18); color: #b45309; }

/* --- Ukazatel postupu ----------------------------------------------------- */

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.08);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--olympic-blue), var(--olympic-green));
  transition: width 0.7s var(--ease-out);
}

/* --- Odznaky -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-active   { background: #dbeafe; color: #1e40af; }
.badge-done     { background: #d1fae5; color: #065f46; }
.badge-auto     { background: rgba(0, 129, 200, 0.1); color: var(--olympic-blue); }

/* --- Záložky -------------------------------------------------------------- */

.tab {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-muted);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, 0.7); color: var(--ink); }
.tab-active { background: #fff; color: var(--olympic-blue); box-shadow: var(--shadow-sm); }

/* --- Obsah článku --------------------------------------------------------- */

.prose { color: #374151; line-height: 1.75; font-size: 1rem; }
.prose h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.9rem 0 0.6rem;
}
.prose h3:first-child { margin-top: 0; }
.prose p { margin: 0 0 1rem; }
.prose ul { margin: 0 0 1.15rem; padding-left: 1.3rem; list-style: disc; }
.prose ol { margin: 0 0 1.15rem; padding-left: 1.3rem; list-style: decimal; }
.prose li { margin-bottom: 0.45rem; }
.prose a { color: var(--olympic-blue); text-decoration: underline; text-underline-offset: 2px; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.9rem 1.15rem;
  border-left: 4px solid var(--olympic-yellow);
  background: rgba(252, 177, 49, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #78350f;
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #f3f4f6;
  padding: 0.12em 0.4em;
  border-radius: 5px;
}

/* --- Animace -------------------------------------------------------------- */

.fade-in { animation: fadeInUp 0.5s var(--ease-out) forwards; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger > * { opacity: 0; animation: fadeInUp 0.5s var(--ease-out) forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.04s; }
.stagger > *:nth-child(2) { animation-delay: 0.08s; }
.stagger > *:nth-child(3) { animation-delay: 0.12s; }
.stagger > *:nth-child(4) { animation-delay: 0.16s; }
.stagger > *:nth-child(5) { animation-delay: 0.20s; }
.stagger > *:nth-child(6) { animation-delay: 0.24s; }
.stagger > *:nth-child(7) { animation-delay: 0.28s; }
.stagger > *:nth-child(8) { animation-delay: 0.32s; }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Oznámení ------------------------------------------------------------- */

#toasts {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--olympic-blue);
  font-size: 0.9rem;
  animation: slideIn 0.35s var(--ease-out);
}
.toast-success { border-left-color: var(--olympic-green); }
.toast-error   { border-left-color: var(--olympic-red); }
.toast-warn    { border-left-color: var(--olympic-yellow); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* --- Modální okno --------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.3s var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Různé ---------------------------------------------------------------- */

.hidden { display: none !important; }

.scroll-area { overflow-y: auto; overscroll-behavior: contain; }
.scroll-area::-webkit-scrollbar { width: 10px; }
.scroll-area::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
.scroll-area::-webkit-scrollbar-thumb:hover { background: #9ca3af; background-clip: content-box; }

.table-wrap { overflow-x: auto; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: #f3f4f6;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0.1em 0.4em;
}

/* --- Editor článků -------------------------------------------------------- */

.editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: #f9fafb;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-wrap: wrap;
}

.editor-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--ink-muted);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.editor-btn:hover { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.editor-btn-active { background: var(--olympic-blue); color: #fff; }
.editor-btn-active:hover { background: var(--olympic-blue); color: #fff; }

.editor-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}

.editor-body {
  padding: 1.25rem 1.4rem;
  min-height: 340px;
  max-height: 56vh;
  overflow-y: auto;
  outline: none;
}
.editor-body:focus { box-shadow: inset 0 0 0 2px rgba(0, 129, 200, 0.12); }

/* Prázdný editor napoví, čím začít. */
.editor-body:empty::before,
.editor-body > p:only-child:empty::before {
  content: "Začněte psát… Nadpis uděláte tlačítkem vlevo nahoře.";
  color: var(--ink-faint);
}

.editor-source {
  border: none;
  border-radius: 0;
  min-height: 340px;
  max-height: 56vh;
  resize: vertical;
}
.editor-source:focus { box-shadow: none; }

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 8px 14px;
  background: #f9fafb;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Značka [DOPLNIT] musí být v editoru vidět na první pohled. */
.editor-body mark {
  cursor: text;
}

/* --- Vysvětlující panel --------------------------------------------------- */

.explain {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: rgba(0, 129, 200, 0.06);
  border: 1px solid rgba(0, 129, 200, 0.2);
  font-size: 0.875rem;
  line-height: 1.6;
  color: #1e3a5f;
}
.explain-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(0, 129, 200, 0.14);
  color: var(--olympic-blue);
}
.explain strong { color: #0f2942; }
.explain code {
  background: rgba(255, 255, 255, 0.8);
  padding: 0.1em 0.35em;
  border-radius: 5px;
  font-size: 0.9em;
}

/* --- Výběrové karty (místo holých zaškrtávátek) ---------------------------- */

.pick {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out), transform 0.15s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.pick:hover { border-color: #b9c2cd; background: #fff; }
.pick:active { transform: scale(0.99); }

/* Nativní pole schováme, ale necháme ho ovladatelné klávesnicí. */
.pick input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.pick:focus-within {
  border-color: var(--olympic-blue);
  box-shadow: 0 0 0 3px rgba(0, 129, 200, 0.16);
}

.pick-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 7px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  display: grid;
  place-items: center;
  color: #fff;
  transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.pick-check svg {
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-spring);
}

.pick-on,
.pick:has(input:checked) {
  border-color: var(--olympic-blue);
  background: rgba(0, 129, 200, 0.06);
  box-shadow: 0 2px 12px rgba(0, 129, 200, 0.12);
}
.pick-on .pick-check,
.pick:has(input:checked) .pick-check {
  background: var(--olympic-blue);
  border-color: var(--olympic-blue);
}
.pick-on .pick-check svg,
.pick:has(input:checked) .pick-check svg {
  opacity: 1;
  transform: scale(1);
}

.pick-title {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.35;
}
.pick-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.45;
  margin-top: 0.15rem;
}

/* Skupina kroků v žádosti */
.pick-group-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
  flex-wrap: wrap;
}
.pick-group-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  color: var(--ink-muted);
  flex-shrink: 0;
}

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

@media (max-width: 640px) {
  .card { border-radius: 18px; }
  .step { padding: 0.9rem 0.95rem; gap: 0.75rem; }
  .step-icon { width: 38px; height: 38px; border-radius: 12px; }
  .field-code { font-size: 1.15rem; letter-spacing: 0.12em; padding: 0.85rem; }

  .modal {
    max-height: 92vh;
    border-radius: 18px;
  }
  .editor-body,
  .editor-source { min-height: 240px; max-height: 46vh; }
  .editor-toolbar { padding: 5px 6px; }
  .editor-btn { min-width: 34px; height: 34px; }

  .explain { padding: 0.85rem 0.9rem; gap: 0.7rem; font-size: 0.82rem; }
  .explain-icon { width: 28px; height: 28px; }

  /* Tlačítka v patičce modálu se na úzkém displeji nemají mačkat. */
  .modal > div:last-child { flex-wrap: wrap; }
  .modal > div:last-child .btn { flex: 1 1 auto; }
}

/* --- Vložená videa v článcích ---------------------------------------------- */

.prose iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: 14px;
  background: #000;
  margin: 1.25rem 0;
  box-shadow: var(--shadow-sm);
}

/* V editoru se do videa nedá psát — ať se autor nesnaží. */
.editor-body iframe { pointer-events: none; }
.editor-body p:has(> iframe) { position: relative; }

/* --- Tabulky v článcích ---------------------------------------------------- */

.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92em;
}
.prose table thead,
.prose table tbody {
  display: table;
  width: 100%;
  min-width: 420px;
}
.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.prose th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--ink);
}
.prose tbody tr:nth-child(even) td { background: rgba(248, 250, 252, 0.6); }

/* V editoru ať je poznat, kam se dá psát. */
.editor-body table { cursor: text; }
