/* Dodatki specyficzne dla panelu Dashboard (poza bazowym design systemem). */

/* [hidden] musi wygrywać z komponentami o własnym display (np. .modal-backdrop:grid) */
[hidden] { display: none !important; }

/* Karta wejściowa (logowanie, 2FA, reset hasła) — odstępy między polami/akcjami.
   Scoped do .entrance-card, żeby NIE ruszać formularzy w panelu. */
.entrance-card h1 { margin: 0 0 var(--s-4); font-size: 26px; }
.entrance-card > p { margin: 0 0 var(--s-4); color: var(--c-ink-600); }
.entrance-card .field { margin-bottom: var(--s-4); }
.entrance-card .field:last-child { margin-bottom: 0; }
.entrance-card .field__label { display: block; margin-bottom: 6px; }
.entrance-card form .alert { margin-bottom: var(--s-4); }
.entrance-card .btn { margin-top: var(--s-2); }
.entrance-card hr { margin: var(--s-5) 0; border: 0; border-top: 1px solid var(--c-ink-200); }
.entrance-card .button-group, .entrance-card [class*="button_group"] { display: grid; gap: var(--s-3); }

/* Panele zarządzania 2FA (aplikacja, kody odzyskiwania) — bez punktorów. */
.auth-panel {
  border: 1px solid var(--c-ink-200); border-radius: var(--r-md);
  padding: var(--s-4); margin-top: var(--s-4);
}
.auth-panel__title { font-size: 16px; margin: 0 0 var(--s-2); }
.auth-panel__body { color: var(--c-ink-600); font-size: 14px; }
.auth-panel__body p { margin: 0 0 var(--s-2); }
.auth-panel__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.auth-panel__actions .btn { width: auto; }

.page-head { margin-bottom: var(--s-6); }
.page-head .t-h2 { margin-bottom: 4px; }
.panel-main { padding: var(--s-8) var(--s-8) var(--s-9); min-width: 0; }
@media (max-width: 880px) { .panel-main { padding: var(--s-6) var(--s-5); } }

/* Sidebar — drzewo struktury (rozwijane, delikatna animacja) */
.nav-tree, .nav-tree__children { list-style: none; margin: 0; padding: 0; }
.nav-tree__row { display: flex; align-items: center; gap: 4px; }
.nav-tree__toggle {
  flex-shrink: 0; width: 22px; height: 30px; padding: 0;
  background: none; border: 0; color: rgba(255,255,255,.7); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs);
}
.nav-tree__toggle:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-tree__toggle svg { transition: transform .22s ease; }
.nav-tree__toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.nav-tree__spacer { width: 22px; flex-shrink: 0; }
.nav-tree__link {
  flex: 1; min-width: 0;
  display: block; padding: 6px 8px; border-radius: var(--r-sm);
  color: rgba(255,255,255,.86); text-decoration: none; font-size: 13px; font-weight: 500;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.28;
  transition: background .15s, color .15s;
}
.nav-tree__link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-tree__link.is-active { background: rgba(255,255,255,.14); color: #fff; }
.nav-tree__link--muted { color: rgba(255,255,255,.5); cursor: default; }
.nav-tree__children { margin-left: 14px; border-left: 1px solid rgba(255,255,255,.14); padding-left: 4px; }
/* animacja rozwijania: grid-template-rows 0fr→1fr (płynna, bez znanej wysokości) */
.nav-tree__wrap {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .24s ease;
}
.nav-tree__wrap.is-open { grid-template-rows: 1fr; }
.nav-tree__wrap > .nav-tree__children { overflow: hidden; min-height: 0; }
@media (prefers-reduced-motion: reduce) {
  .nav-tree__wrap { transition: none; }
  .nav-tree__toggle svg { transition: none; }
}
/* Pierwszy render: gałąź aktywnej witryny otwarta natychmiast, bez animacji */
.nav-preload .nav-tree__wrap,
.nav-preload .nav-tree__toggle svg { transition: none !important; }

/* Sidebar — licznik zgłoszeń */
.sidebar a .count {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--c-red); color: #fff;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar__site-switch {
  margin: var(--s-3) 0 var(--s-5);
  width: 100%; height: 40px; padding: 0 12px;
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.25); border-radius: var(--r-sm);
  font: inherit; font-size: 14px;
}
.sidebar__site-switch option { color: var(--c-ink-900); }

/* Toaster — komunikaty Django jako toasty */
/* (klasy .toast* z bazowego design systemu) */

/* Wizard — bez JS wszystkie panele widoczne; z JS tylko aktywny (wizard-js) */
.wizard__nav { margin-bottom: var(--s-6); }
.wizard__pane { margin-bottom: var(--s-4); }
.wizard-js .wizard__pane { display: none; }
.wizard-js .wizard__pane.is-active { display: block; }
.media-tile__doc svg { color: var(--c-blue); }
.wizard__foot {
  display: flex; justify-content: space-between; gap: var(--s-3);
  margin-top: var(--s-6); padding-top: var(--s-5);
  border-top: 1px solid var(--c-ink-200);
}
.kind-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 640px) { .kind-cards { grid-template-columns: 1fr; } }
.kind-card {
  display: block; cursor: pointer;
  border: 2px solid var(--c-ink-200); border-radius: var(--r-md);
  padding: var(--s-5); background: #fff;
  transition: border-color .15s, background .15s;
}
.kind-card:hover { border-color: var(--c-blue-300); }
.kind-card input { position: absolute; opacity: 0; }
.kind-card input:checked + .kind-card__in { color: var(--c-blue-700); }
.kind-card:has(input:checked) { border-color: var(--c-blue); background: var(--c-blue-50); }
.kind-card__in strong { display: block; font-size: 16px; margin-bottom: 4px; }
.kind-card__in span { font-size: 13px; color: var(--c-ink-600); }

/* Lang tabs w wizardzie */
.langfields { border: 1px solid var(--c-ink-200); border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md); padding: var(--s-5); background: #fff; }

/* Media modal */
.media-modal { max-width: 1040px; }
.media-modal__body { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: var(--s-5); }
@media (max-width: 720px) { .media-modal__body { grid-template-columns: 1fr; } }
.media-main { min-width: 0; }

/* Rail folderów */
.media-rail {
  display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--c-ink-200); padding-right: var(--s-4);
}
@media (max-width: 720px) {
  .media-rail { border-right: 0; border-bottom: 1px solid var(--c-ink-200);
    padding-right: 0; padding-bottom: var(--s-3); }
}
.media-rail__list { display: flex; flex-direction: column; gap: 2px; }
.media-rail__item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: var(--r-sm); background: none;
  font: inherit; font-size: 13px; color: var(--c-ink-700); text-align: left; cursor: pointer;
}
.media-rail__item:hover { background: var(--c-ink-50); }
.media-rail__item.is-active { background: var(--c-blue-50); color: var(--c-blue-700); font-weight: 600; }
.media-rail__item > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.media-rail__count {
  flex-shrink: 0; min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--c-ink-100); color: var(--c-ink-600);
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.media-rail__add { justify-content: flex-start; margin-top: 4px; }
.media-rail__new { display: flex; gap: 4px; margin-top: 4px; }
.media-rail__new .input { height: 32px; font-size: 12px; }

.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--s-3); max-height: 52vh; overflow-y: auto; padding: 2px;
}
.media-tile {
  position: relative; border: 2px solid var(--c-ink-200); border-radius: var(--r-sm);
  overflow: hidden; cursor: pointer; background: var(--c-ink-50); aspect-ratio: 4/3;
  padding: 0;
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; }
.media-tile__doc {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; height: 100%; color: var(--c-blue); padding: 8px; text-align: center;
}
.media-tile__doc span { font-size: 11px; color: var(--c-ink-700); word-break: break-word; }
.media-tile.is-selected { border-color: var(--c-blue); box-shadow: var(--sh-focus); }
.media-tile__check {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-blue); color: #fff; display: none;
  align-items: center; justify-content: center;
}
.media-tile.is-selected .media-tile__check { display: flex; }
.media-tile__cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 6px; font-size: 10.5px; line-height: 1.2; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.72));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.media-tile__doc + .media-tile__cap { color: var(--c-ink-600); background: none;
  position: static; padding: 0 6px 6px; }

/* Modal: stopka z polem altu wstawianego obrazu */
.media-modal__foot { display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--s-4); }
.media-altbox { flex: 1; min-width: 240px; }
.media-altbox .field__label { margin-bottom: 4px; }

/* Modal: podgląd pliku przed dodaniem do biblioteki (zakładka „Prześlij”) */
.mm-uppreview { display: flex; align-items: center; gap: 14px;
  padding: 12px; border: 1px solid var(--c-ink-200); border-radius: var(--r-md);
  background: var(--c-ink-50); }
.mm-uppreview__media { flex: none; width: 72px; height: 72px;
  border-radius: var(--r-sm); overflow: hidden; background: #fff;
  display: grid; place-items: center; border: 1px solid var(--c-ink-200); }
.mm-uppreview__thumb { width: 100%; height: 100%; object-fit: cover; }
.mm-uppreview__doc { color: var(--c-ink-500); display: grid; place-items: center; }
.mm-uppreview__meta { display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px; min-width: 0; }
.mm-uppreview__name { font-size: 13px; color: var(--c-ink-700);
  word-break: break-all; }

/* Chipsy „dodawanie…" przy pickerze galerii/załączników */
.picker-chips { color: var(--c-ink-600); font-size: 13px; margin-bottom: 8px; }
.picker-chips:empty { display: none; }

/* Custom WYSIWYG (textarea.rte) */
.rte-editor { border: 1px solid var(--c-ink-300); border-radius: var(--r-sm); background: #fff; }
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 6px; border-bottom: 1px solid var(--c-ink-200); background: var(--c-ink-50);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.rte-btn {
  min-width: 32px; height: 30px; padding: 0 8px;
  border: 1px solid transparent; border-radius: var(--r-xs); background: none;
  font: inherit; font-size: 13px; color: var(--c-ink-800); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.rte-btn:hover { background: #fff; border-color: var(--c-ink-200); }
.rte-btn.is-active { background: var(--c-blue-50); border-color: var(--c-blue-200); color: var(--c-blue-700); }
.rte-area {
  min-height: 220px; max-height: 60vh; overflow-y: auto;
  padding: var(--s-4); font-size: 15px; line-height: 1.6; color: var(--c-ink-900);
}
.rte-area:focus { outline: none; box-shadow: inset 0 0 0 2px var(--c-blue-200); border-radius: 0 0 var(--r-sm) var(--r-sm); }
.rte-area:empty::before { content: "Zacznij pisać treść…"; color: var(--c-ink-400); }
.rte-area h2 { font-size: 22px; margin: .6em 0 .3em; }
.rte-area h3 { font-size: 18px; margin: .6em 0 .3em; }
.rte-area p { margin: 0 0 .7em; }
.rte-area ul, .rte-area ol { margin: 0 0 .7em 1.4em; }
.rte-area img { max-width: 100%; height: auto; border-radius: var(--r-sm); margin: .4em 0; }
.rte-area a { color: var(--c-blue-700); }

/* Miniatura na liście newsów */
.tbl-thumb { width: 56px; padding-right: 0; }
.tbl-thumb img {
  width: 48px; height: 36px; object-fit: cover;
  border-radius: var(--r-xs); border: 1px solid var(--c-ink-200); display: block;
}
.tbl-thumb__ph {
  width: 48px; height: 36px; border-radius: var(--r-xs);
  background: var(--c-ink-50); border: 1px dashed var(--c-ink-200); color: var(--c-ink-400);
  display: flex; align-items: center; justify-content: center;
}

/* Galeria / załączniki w kroku „Media" */
.media-strip { display: flex; flex-direction: column; }
.media-strip__row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--c-ink-100);
}
.media-strip__row img {
  width: 52px; height: 40px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--c-ink-200); flex-shrink: 0;
}
.media-strip__row > .t-small { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Miniatura wybranego obrazu w wizardzie */
.thumb-pick { display: flex; gap: var(--s-3); align-items: center; }
.thumb-pick img { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r-sm);
  border: 1px solid var(--c-ink-200); }

/* Drzewo struktury */
.tree-branch { margin: var(--s-3) 0 0 var(--s-5); padding-left: var(--s-4);
  border-left: 2px solid var(--c-ink-200); }
.tree-leaf { margin: var(--s-2) 0 0 var(--s-5); padding: 6px 10px;
  background: var(--c-ink-50); border-radius: var(--r-sm); }

/* Drzewo checkboxów publikacji — rozwijane wg struktury, na białej karcie.
   Rozwijanie/zwijanie napędza wspólny initTree() (data-tree-toggle/-children,
   .nav-tree__wrap .is-open). Styl gałęzi własny — ciemny tekst zamiast sidebarowego. */
.pub-scroll { max-height: 340px; overflow-y: auto;
  border: 1px solid var(--c-ink-100); border-radius: var(--r-sm); padding: var(--s-2); }
.pub-tree2, .pub-node2__children { list-style: none; margin: 0; padding: 0; }
.pub-node2__row { display: flex; align-items: center; gap: 4px; }
.pub-node2__toggle {
  flex-shrink: 0; width: 22px; height: 30px; padding: 0;
  background: none; border: 0; color: var(--c-ink-500); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs);
}
.pub-node2__toggle:hover { background: var(--c-ink-50); color: var(--c-ink-900); }
.pub-node2__toggle svg { transition: transform .22s ease; }
.pub-node2__toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.pub-node2__spacer { width: 22px; flex-shrink: 0; }
.pub-node2 { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-3);
  padding: 6px 8px; border-radius: var(--r-sm); color: var(--c-ink-900); }
.pub-node2:hover { background: var(--c-ink-50); }
.pub-node2 > span:first-of-type { min-width: 0; overflow-wrap: anywhere; }
.pub-node2__mode { margin-left: auto; flex-shrink: 0; }
.pub-node2__children { margin-left: 14px; border-left: 1px solid var(--c-ink-100); padding-left: 4px; }
@media (prefers-reduced-motion: reduce) {
  .pub-node2__toggle svg { transition: none; }
}
.nav-preload .pub-node2__toggle svg { transition: none !important; }
