/* =====================================================================
   components.css – komponenty portálu (kp-controls + kp-menu)
   Čte tokeny z tokens.css. Načítat po base.css.
   ===================================================================== */

/* ---- Tlačítka --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-4);
  font: var(--fw-medium) var(--fs-sm)/1 var(--font-sans);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn--sm { height: var(--control-h-sm); padding: 0 var(--sp-3); }
.btn--block { width: 100%; }
.btn--primary { background: var(--color-brand); color: var(--color-brand-contrast); }
.btn--primary:hover { background: var(--color-brand-hover); }
.btn--primary:active { background: var(--color-brand-active); }
.btn--secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }
.btn--secondary:hover { background: var(--color-surface-2); }
.btn--ghost { background: transparent; color: var(--color-brand); }
.btn--ghost:hover { background: var(--color-brand-soft); }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--idp { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }
.btn--idp:hover { background: var(--color-surface-2); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---- Ikonové tlačítko / pill ----------------------------------- */
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; background: none;
  color: var(--color-text-muted); border-radius: var(--radius-sm); cursor: pointer;
}
.iconbtn:hover { background: var(--color-surface-2); }
.iconbtn svg { width: 20px; height: 20px; }
.pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-3);
  border: 1px solid var(--color-border); background: none; color: var(--color-text-muted);
  border-radius: var(--radius-pill); cursor: pointer; font: inherit; font-size: var(--fs-sm);
}
.pill:hover { background: var(--color-surface-2); }
.pill svg { width: 16px; height: 16px; }

/* ---- Definition list (read-only key/value bloky) ---------------
   Vzdušný 2-sloupcový info layout (kontaktní karta), bez čar.
   Štítek nad hodnotou, sloupce se přizpůsobí šířce. */
.dl {
  margin: 0; display: grid; gap: var(--sp-4) var(--sp-5);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.dl-row { display: block; min-width: 0; }
.dl-row dt {
  color: var(--color-text-muted);
  font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .04em; margin: 0 0 2px;
}
.dl-row dd { margin: 0; font-weight: var(--fw-medium); word-break: break-word; }
.dl-row--wide { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .dl { grid-template-columns: 1fr; gap: var(--sp-3); }
}

/* ---- Avatar ----------------------------------------------------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semibold); font-size: 13px; cursor: pointer; border: none;
  overflow: hidden; padding: 0;
}
.avatar--img { background: var(--color-surface-2); }
.avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 50%;
}

/* ---- Co-branding (logo + název partnera v záhlaví) ------------- */
.brand { display: flex; align-items: center; gap: var(--sp-2); text-decoration: none; color: var(--color-text); }
/* Definite height (not auto) so SVG logos with a viewBox but no intrinsic
   width/height don't collapse to 0 in <img>; raster logos keep their ratio
   via width:auto + object-fit. */
.brand__logo { height: calc(var(--topbar-h) - var(--sp-5)); max-width: 200px; width: auto; object-fit: contain; }
.brand__logo--ph {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-light));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-bold); font-size: 14px;
}
.brand__name { font-weight: var(--fw-semibold); }
@media (max-width: 639px) { .brand__name { display: none; } }

/* ---- Drobečky --------------------------------------------------- */
.crumbs { font-size: var(--fs-sm); color: var(--color-text-muted); display: flex; gap: var(--sp-2); align-items: center; }
.crumbs a { color: var(--color-text-muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--color-text); font-weight: var(--fw-medium); }

/* ---- Navigace v sidebaru --------------------------------------- */
.navitem {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--tap-min); padding: 0 var(--sp-4);
  color: var(--color-text-muted); text-decoration: none;
  border-left: 3px solid transparent; font-size: var(--fs-sm);
}
.navitem:hover { background: var(--color-brand-soft); color: var(--color-text); }
.navitem.is-active {
  background: var(--color-brand-soft); color: var(--color-brand);
  border-left-color: var(--color-brand); font-weight: var(--fw-semibold);
}
.navitem svg { width: 20px; height: 20px; flex: none; }
.navitem__label { flex: 1; }
.navitem__badge {
  font-size: var(--fs-xs); background: var(--color-surface-2); color: var(--color-text-muted);
  padding: 0 var(--sp-2); border-radius: var(--radius-pill);
}
.navitem__badge--danger { background: var(--color-danger-soft); color: var(--color-danger); }
.nav-sep { height: 1px; background: var(--color-border); margin: var(--sp-3) var(--sp-4); }
.app.is-collapsed .navitem__label,
.app.is-collapsed .navitem__badge { display: none; }

/* ---- Dropdown (sdílený: jazyk, uživatel) ----------------------- */
[data-dropdown] { position: relative; }
.dropdown__menu {
  position: absolute; top: calc(100% + var(--sp-2)); right: 0;
  min-width: 200px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--sp-1); z-index: var(--z-dropdown);
  list-style: none; margin: 0;
}
.dropdown__menu[hidden] { display: none; }
.dropdown__item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2) var(--sp-3); border: none; background: none;
  color: var(--color-text); font: inherit; font-size: var(--fs-sm);
  text-align: left; cursor: pointer; border-radius: var(--radius-sm); text-decoration: none;
}
.dropdown__item:hover { background: var(--color-brand-soft); }
.dropdown__item[aria-checked="true"] { font-weight: var(--fw-semibold); color: var(--color-brand); }
.dropdown__check { margin-left: auto; opacity: 0; }
.dropdown__item[aria-checked="true"] .dropdown__check { opacity: 1; }
.dropdown__sep { height: 1px; background: var(--color-border); margin: var(--sp-1) var(--sp-2); }

/* ---- Přepínač jazyků (vlaječka + dropdown) --------------------- */
.flag {
  width: 22px; height: 15px; border-radius: 2px; object-fit: cover;
  border: 1px solid rgba(0,0,0,.08); flex: none; display: block;
}
.langswitch__cur { font-size: var(--fs-sm); }
@media (max-width: 639px) { .langswitch__cur { display: none; } }

/* ---- Pole / formuláře ------------------------------------------ */
.field { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.req { color: var(--color-danger); }
.input, .select, .textarea {
  height: var(--control-h); width: 100%; padding: 0 var(--sp-3);
  font-size: var(--fs-base); color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
}
.textarea { height: auto; min-height: calc(var(--control-h) * 2.5); padding: var(--sp-3); }
.input::placeholder { color: var(--color-text-subtle); }
.input:disabled { background: var(--color-surface-2); color: var(--color-text-subtle); }
.field__hint { font-size: var(--fs-xs); color: var(--color-text-muted); margin: 0; }
.field__error { font-size: var(--fs-xs); color: var(--color-danger); margin: 0; }
.field.is-invalid .input { border-color: var(--color-danger); }

/* ---- Karty ------------------------------------------------------ */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm); margin-bottom: var(--sp-5);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--color-border);
}
.card__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.card__body { padding: var(--sp-5); }

/* ---- KPI dlaždice ----------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-6); }
@media (max-width: 899px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: var(--sp-5); }
.kpi__label { font-size: var(--fs-sm); color: var(--color-text-muted); display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.kpi__val { font-size: 2rem; font-weight: var(--fw-semibold); line-height: 1; }
.kpi__sub { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: var(--sp-2); }
.kpi__icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.kpi__icon svg { width: 18px; height: 18px; }

/* ---- Nadpis stránky -------------------------------------------- */
.page-h { font-size: var(--fs-xl); font-weight: var(--fw-semibold); margin-bottom: var(--sp-1); }
.page-sub { color: var(--color-text-muted); margin-bottom: var(--sp-6); }

/* ---- Tabulky ---------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-3) var(--sp-5); text-align: left; }
.table thead th { background: var(--color-surface-2); color: var(--color-text-muted); font-weight: var(--fw-semibold); border-bottom: 1px solid var(--color-border); }
.table tbody tr { border-bottom: 1px solid var(--color-border); }
.table tbody tr:hover { background: var(--color-brand-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

@media (max-width: 639px) {
  .table.table--stack thead { display: none; }
  .table.table--stack, .table.table--stack tbody, .table.table--stack tr, .table.table--stack td { display: block; width: 100%; }
  .table.table--stack tr { border: 1px solid var(--color-border); border-radius: var(--radius-md); margin-bottom: var(--sp-3); padding: var(--sp-2); }
  .table.table--stack td { display: flex; justify-content: space-between; gap: var(--sp-3); border: 0; }
  .table.table--stack td::before { content: attr(data-label); font-weight: var(--fw-medium); color: var(--color-text-muted); }
}

/* ---- Badge ------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-xs); font-weight: var(--fw-medium); padding: 2px var(--sp-2); border-radius: var(--radius-pill); }
.badge--success { background: var(--color-success-soft); color: var(--color-success); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge--neutral { background: var(--color-surface-2);    color: var(--color-text-muted); }

/* ---- Banner (info pruh nad sekcí) ------------------------------- */
.banner { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); font-size: var(--fs-sm); margin-bottom: var(--sp-4); border: 1px solid var(--color-border); background: var(--color-surface); }
.banner--muted { background: var(--color-surface-2); color: var(--color-text-muted); }
.banner__icon { display: inline-flex; align-items: center; }

/* ---- Empty state ------------------------------------------------ */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--color-text-muted); }
.empty__icon { display: inline-flex; padding: var(--sp-3); border-radius: 999px; background: var(--color-surface-2); margin-bottom: var(--sp-3); }
.empty__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--color-text); margin: 0 0 var(--sp-1); }
.empty__text { font-size: var(--fs-sm); margin: 0; }

/* ---- Tabulka: sortovací záhlaví, nowrap, pager ------------------ */
.table th.nowrap, .table td.nowrap { white-space: nowrap; }
.table th.center, .table td.center { text-align: center; }

.th-sort {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  color: inherit; text-decoration: none; font-weight: inherit;
}
.th-sort:hover { color: var(--color-brand); }
.th-sort__i { font-size: var(--fs-xs); color: var(--color-text-subtle); }
.th-sort.is-active { color: var(--color-brand); }
.th-sort.is-active .th-sort__i { color: var(--color-brand); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--color-border);
}
.pager__info { color: var(--color-text-muted); font-size: var(--fs-sm); }
@media (max-width: 639px) {
  .pager { flex-direction: column; }
  .pager__info { order: -1; }
}

/* ---- Card head actions (right-aligned buttons/filters) ---------- */
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--color-border); }
.card__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: 0; display: flex; align-items: center; gap: var(--sp-2); }
.card__actions { display: flex; align-items: center; gap: var(--sp-2); }
.card__body { padding: var(--sp-5); }

/* ---- Segmented control (filter toggle) -------------------------- */
.seg { display: inline-flex; background: var(--color-surface-2); padding: 2px; border-radius: var(--radius-pill); gap: 2px; }
.seg__btn {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 4px var(--sp-3); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  color: var(--color-text-muted); text-decoration: none;
  border-radius: var(--radius-pill); white-space: nowrap;
}
.seg__btn:hover { color: var(--color-text); }
.seg__btn.is-active { background: var(--color-brand); color: var(--color-brand-contrast); }
.seg__btn.is-active:hover { color: var(--color-brand-contrast); }

/* ---- Login karta ------------------------------------------------ */
.login { width: 100%; max-width: 420px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--sp-6); }
.login__brand { display: flex; justify-content: center; margin-bottom: var(--sp-4); }
.login__brand .cp-logo { height: 34px; width: auto; max-width: 240px; object-fit: contain; }
.login__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); text-align: center; margin-bottom: var(--sp-1); }
.login__sub { font-size: var(--fs-sm); color: var(--color-text-muted); text-align: center; margin-bottom: var(--sp-5); }
.login .btn--idp { margin-bottom: var(--sp-3); }
.divider { display: flex; align-items: center; gap: var(--sp-3); color: var(--color-text-subtle); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; margin: var(--sp-5) 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }
.row-between { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-3); }
.link { color: var(--color-brand); font-size: var(--fs-sm); text-decoration: none; }
.link:hover { text-decoration: underline; }
.mfa-note { font-size: var(--fs-xs); color: var(--color-text-muted); background: var(--color-brand-soft); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); }

/* ── Naše síť (IPAM, F6) ───────────────────────────────────────────────────
   Jen tokeny, žádná hex barva ani px rozměr tam, kde token existuje.
   Prefix `.net-` drží sekci oddělenou od zbytku portálu. */
.net-cols {
  display: grid; gap: var(--sp-4);
  grid-template-columns: 1fr 1fr;
  margin-bottom: var(--sp-4);
}
/* Na užších obrazovkách nemá smysl mačkat lokality a VLAN vedle sebe —
   adresa lokality se do poloviny šířky nevejde a láme se po slovech. */
@media (max-width: 899px) { .net-cols { grid-template-columns: 1fr; } }

.net-list { list-style: none; margin: 0; padding: 0; }
.net-list li {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.net-list li:last-child { border-bottom: 0; }
.net-list__sub { color: var(--color-text-muted); font-size: var(--fs-xs); }
