/* Designový systém aplikace. Hodnoty odpovídají CLAUDE.md — barvy, velikosti
   písma i rozestupy měň tady, ne v jednotlivých pravidlech. */

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --surface: #ffffff;
  --border: #e6e8ec;
  --text: #1d1f25;
  --text-muted: #6b7280;
  --accent: #2f6fed;
  --accent-hover: #2559c4;
  --accent-soft: #eaf0fe;
  --success: #22a06b;
  --warning: #e5a100;
  --danger: #e5484d;
  --danger-soft: #fdeced;

  /* Barvy kategorií — sytý tón pro proužek, jemný pro podklad záhlaví.
     Pořadí odpovídá seznamu v src/colors.js (barevný kruh, na konci neutrální). */
  --cat-blue: #2f6fed;      --cat-blue-soft: #eaf0fe;
  --cat-indigo: #3f51b5;    --cat-indigo-soft: #ebedf8;
  --cat-sky: #0288d1;       --cat-sky-soft: #e3f2fb;
  --cat-teal: #0f9b9b;      --cat-teal-soft: #e2f4f4;
  --cat-green: #22a06b;     --cat-green-soft: #e6f5ee;
  --cat-lime: #689f38;      --cat-lime-soft: #eff5e7;
  --cat-olive: #827717;     --cat-olive-soft: #f4f2e2;
  --cat-amber: #b07800;     --cat-amber-soft: #fbf1dd;
  --cat-orange: #e5820b;    --cat-orange-soft: #fdf1e0;
  --cat-coral: #e2603f;     --cat-coral-soft: #fdece7;
  --cat-red: #e5484d;       --cat-red-soft: #fdeced;
  --cat-crimson: #b3123c;   --cat-crimson-soft: #fbe6eb;
  --cat-pink: #d9469b;      --cat-pink-soft: #fceaf4;
  --cat-purple: #7c5cf0;    --cat-purple-soft: #f0ecfe;
  --cat-amethyst: #9333ea;  --cat-amethyst-soft: #f4e8fd;
  --cat-brown: #795548;     --cat-brown-soft: #f1ece9;
  --cat-slate: #455a64;     --cat-slate-soft: #eceff1;
  --cat-gray: #6b7280;      --cat-gray-soft: #f0f1f3;

  --radius-card: 8px;
  --radius-button: 6px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  --transition: 150ms ease-out;
}

* {
  box-sizing: border-box;
}

/* Vlastní hodnota display u tlačítek a polí by jinak atribut hidden přebila. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 600;
}

h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Rozvržení ---------- */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar__brand {
  font-size: 16px;
  font-weight: 600;
  padding: 0 8px;
}

.sidebar__top {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  column-gap: 8px;
}

/* Ikony odhlášení a nabídky patří jen na úzký displej. */
.sidebar__actions { display: none; }

.sidebar__collapse { flex-shrink: 0; }

.sidebar__collapse svg { transition: transform var(--transition); }

.sidebar__footer .btn svg {
  width: 16px;
  height: 16px;
}

/* Sbalená nabídka: zůstanou jen ikony. Na úzkém displeji se neuplatní,
   tam nabídku ovládá hamburger. */
@media (min-width: 761px) {
  .app.is-collapsed { grid-template-columns: 64px 1fr; }

  .app.is-collapsed .sidebar { padding: 24px 8px; }

  .app.is-collapsed .sidebar__brand,
  .app.is-collapsed .sidebar__tagline,
  .app.is-collapsed .sidebar__user,
  .app.is-collapsed .sidebar__label {
    display: none;
  }

  .app.is-collapsed .sidebar__top {
    grid-template-columns: auto;
    justify-items: center;
  }

  .app.is-collapsed .sidebar__link,
  .app.is-collapsed .sidebar__footer .btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .app.is-collapsed .sidebar__collapse svg { transform: rotate(180deg); }
}

/* Podtitulek má vlastní řádek přes celou šířku, ať ho tlačítka nezalamují. */
.sidebar__tagline {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  padding: 0 8px;
  margin-top: 4px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-button);
  color: var(--text);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.sidebar__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar__label { white-space: nowrap; }

.sidebar__link:hover {
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}

.sidebar__link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar__footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar__user {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 8px;
  overflow-wrap: anywhere;
}

/* Bez horní meze šířky — na širokém monitoru se kontejnery roztáhnou
   přes celé okno, místo aby vpravo zůstávalo prázdno. */
.main {
  padding: 32px 32px 48px;
  width: 100%;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header__text { max-width: 60ch; }

/* Na úvodní stránce stojí vedle nadpisu ikonky oblíbených odkazů. */
.page-header--home { align-items: center; }

.favorites {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.favorites__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-card);
  transition: background var(--transition);
}

.favorites__link:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

/* Velikost ikonky odpovídá výšce nadpisu stránky. */
.favorites__icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: contain;
}

.favorites__fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.page-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btn:hover { background: var(--bg-subtle); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--danger {
  color: var(--danger);
  border-color: var(--border);
}

.btn--danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
}

.btn--ghost:hover { background: rgba(0, 0, 0, 0.04); }

.btn--full { width: 100%; justify-content: center; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-button);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-icon svg { width: 16px; height: 16px; }

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

.field { margin-bottom: 16px; }

.field > label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
}

.field__hint {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:hover, select:hover { border-color: #d3d7de; }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Výběr barvy kategorie */

/* Osmnáct barev se do řádků nevejde přehledně — mřížka je drží zarovnané. */
.color-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.color-option { position: relative; }

.color-option input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.color-option span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  transition: border-color var(--transition), background var(--transition);
}

/* Počet odsazujeme doprava, ať jsou čísla ve sloupci pod sebou. */
.color-option__count { margin-left: auto; }

.color-option span::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--swatch, var(--cat-gray));
}

.color-option input:checked + span {
  border-color: var(--swatch);
  background: var(--swatch-soft);
  font-weight: 500;
}

.color-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Kolik kategorií barvu už používá. */
.color-option__count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.color-option input:checked + span .color-option__count { color: inherit; }

/* ---------- Karty kategorií na úvodní stránce ---------- */

/* Kontejnery se rozprostřou podle šířky okna. Nastavení uživatele udává
   nejvyšší počet sloupců, užší okno jich zobrazí méně — bez skokových
   zlomů, mřížka se přizpůsobuje plynule. */
.board {
  --board-min: 260px;  /* pod tuhle šířku se kontejner nesmrskne */
  --board-gap: 24px;
  --board-track: max(
    var(--board-min),
    (100% - (var(--columns, 3) - 1) * var(--board-gap)) / var(--columns, 3)
  );

  display: grid;
  gap: var(--board-gap);
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--board-track)), 1fr));
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent-color, var(--cat-gray));
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.category-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: var(--accent-soft-color, var(--bg-subtle));
  border-bottom: 1px solid var(--border);
}

.category-card__title { font-size: 16px; }

.category-card__count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.category-card__list {
  list-style: none;
  margin: 0;
  padding: 4px;
}

.category-card__footer {
  border-top: 1px solid var(--border);
  padding: 4px;
}

/* Řádek s odkazem */

.bookmark {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-button);
  transition: background var(--transition);
}

.bookmark:hover { background: var(--bg-subtle); }

.bookmark__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
  object-fit: contain;
}

.bookmark__fallback {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.bookmark__link {
  flex: 1;
  min-width: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark__link:hover { color: var(--accent); }

.bookmark__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

/* Ovládání se ukáže při najetí i při pohybu klávesnicí. */
.bookmark:hover .bookmark__actions,
.bookmark:focus-within .bookmark__actions {
  opacity: 1;
}

@media (hover: none) {
  .bookmark__actions { opacity: 1; }
}

/* ---------- Seznam kategorií (stránka správy) ---------- */

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child { border-bottom: none; }

.list-row__main {
  flex: 1;
  min-width: 0;
}

.list-row__title {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Názvy kategorií nesou stránku, proto o stupeň větší písmo. */
.list-row__title--large { font-size: 16px; }

.list-row__meta {
  font-size: 13px;
  color: var(--text-muted);
}

.list-row__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Přetahování pořadí */

.list-row[draggable="true"] { cursor: grab; }

.list-row__handle {
  display: flex;
  align-items: center;
  color: var(--border);
  flex-shrink: 0;
  transition: color var(--transition);
}

.list-row__handle svg {
  width: 16px;
  height: 16px;
}

.list-row:hover .list-row__handle { color: var(--text-muted); }

.list-row.is-dragging {
  opacity: 0.4;
  cursor: grabbing;
  background: var(--bg-subtle);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-color, var(--cat-gray));
  flex-shrink: 0;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tag--admin {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.card-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 560px;
}

/* ---------- Prázdné stavy ---------- */

.empty {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.empty h2 { margin-bottom: 4px; }

.empty p {
  color: var(--text-muted);
  margin: 0 auto 16px;
  max-width: 44ch;
}

/* ---------- Dialogy ---------- */

dialog {
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  color: var(--text);
}

dialog::backdrop {
  background: rgba(29, 31, 37, 0.35);
}

.dialog__header {
  padding: 24px 24px 0;
}

.dialog__body { padding: 16px 24px 0; }

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 24px;
}

.dialog__footer--split { justify-content: space-between; }

.dialog__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

fieldset.field {
  border: none;
  padding: 0;
  margin: 0 0 16px;
}

fieldset.field legend {
  padding: 0;
  font-weight: 500;
  margin-bottom: 8px;
}

/* ---------- Hlášení ---------- */

.message {
  padding: 8px 12px;
  border-radius: var(--radius-button);
  font-size: 13px;
  margin-bottom: 16px;
}

.message--error {
  background: var(--danger-soft);
  color: #a3282c;
}

.message--success {
  background: #e6f5ee;
  color: #14764c;
}

/* ---------- Přihlašovací stránka ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  padding: 24px;
}

.login__card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login__title { margin-bottom: 4px; }

.login__subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
}

.login__note {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Drobnosti ---------- */

.stack { display: grid; gap: 16px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  /* Záhlaví má výšku svého obsahu, zbytek stránky patří obsahu —
     bez určení řádků by mřížka volné místo rozdělila mezi obě části. */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .main { padding: 24px 16px 32px; }

  /* Na řádku s nadpisem zůstane jen nadpis a tlačítko Přidat odkaz.
     Oblíbené odkazy se zalomí na vlastní řádek pod ně. */
  .favorites {
    order: 1;
    flex: 0 0 100%;
  }

  /* Záhlaví zůstává vidět pořád: značka vlevo, odhlášení a hamburger vpravo.
     Odkazy nabídky se ukážou až po rozbalení. */
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 8px;
    gap: 12px;
  }

  .sidebar__top { column-gap: 12px; }

  .sidebar__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }

  /* Sbalování na ikony je věc širokého displeje. */
  .sidebar__collapse { display: none; }

  /* Ikonky ovládání jsou na dotyk větší než na myš. */
  .sidebar__actions .btn-icon {
    width: 40px;
    height: 40px;
  }

  .sidebar__actions .btn-icon svg {
    width: 20px;
    height: 20px;
  }

  .sidebar__nav,
  .sidebar__footer {
    display: none;
  }

  .sidebar.is-open .sidebar__nav { display: flex; }

  .sidebar.is-open .sidebar__footer {
    display: flex;
    margin-top: 0;
    padding-top: 12px;
  }

  .sidebar__link { padding: 12px; }

  /* Odhlášení má vlastní ikonu v záhlaví, tlačítko v patičce by ho zdvojovalo. */
  .sidebar__footer .btn { display: none; }
}
