/* Szkielet aplikacji: sidebar, topbar, ekran logowania, karty. */

/* ---------- App shell (sidebar layout) ---------- */
body.app-shell {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Pierwszy cel Tabu: omija menu (WCAG 2.4.1). Absolutny, więc nie jest
   elementem flexa body. */
.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 300;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
/* Cel linku — fokus programowy, nie kontrolka; obrys zbędny. */
.content:focus { outline: none; }

.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0 0 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
/* Ta sama wysokość co .topbar (72px) i brak paddingu nad nią — znak
   i tytuł strony leżą na jednej osi, a dolne krawędzie się spotykają. */
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 72px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    flex-shrink: 0;
}
.brand .logo {
    width: 32px;
    height: 32px;
    background: var(--brand);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}
/* Znak jako SVG, nie litera: flex centruje pole linii fontu, a nie sam
   glif, więc "Y" z tekstu siedział wizualnie za nisko. */
.brand .logo svg { display: block; width: 100%; height: 100%; }
.sidebar .brand .name { font-weight: 600; font-size: 14px; }
.sidebar .brand .sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.sidebar nav .nav-group { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.sidebar nav .nav-heading {
    padding: 0 12px 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.sidebar nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.sidebar nav a:hover { background: var(--surface-alt); color: var(--text); }
/* Ikony menu (_nav_icons.svg): kreska jak przełącznik motywu, kolor jak tekst linku. */
.nav-icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
}
.sidebar nav a:hover .nav-icon,
.sidebar nav a.active .nav-icon { opacity: 1; }
.sidebar nav a.active {
    background: var(--surface-alt);
    color: var(--text);
}
.sidebar nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 18px;
    background: var(--accent-soft-text);
    border-radius: 2px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
/* Formularz i przycisk jako flex: przycisk liniowy w <form> siadał na linii bazowej
   fontu formularza i jego tekst był 1–2 px niżej niż "Moje konto" obok. */
.sidebar-footer .logout,
.sidebar-footer .logout form { display: flex; align-items: center; }
.sidebar-footer .logout button {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.3;
    font-family: inherit;
    cursor: pointer;
    transition: color var(--transition);
}
.sidebar-footer .logout button:hover { color: var(--text); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface-alt);
    color: var(--text-dim);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent-soft-text); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.auth-theme-toggle { position: fixed; top: 20px; right: 20px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    height: 72px;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar h1 { font-size: 17px; font-weight: 600; line-height: 1.3; }
/* Długi tytuł (klient — lokalizacja) skraca się wielokropkiem — bez tego wychodził
   spod przycisków akcji, które się nie kurczą. Telefon nadpisuje to w responsive.css. */
.topbar-left h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-left .back-link { flex-shrink: 0; white-space: nowrap; }
.topbar .user { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    transition: color var(--transition);
}
.back-link:hover { color: var(--accent-soft-text); }

/* --content-pad-y czyta też .sticky-bar: przeglądarki przyklejają element
   wewnątrz paddingu kontenera przewijania, więc offset musi go znosić. */
/* Jedna szerokość dla wszystkich zakładek — przełączanie nie zmienia rozmiaru
   widoku. Wąskie formularze same ograniczają pola (.stacked-fields, .field-narrow). */
.content { --content-pad-y: 28px; padding: var(--content-pad-y) 32px; flex: 1; max-width: 1500px; min-width: 0; min-height: 0; overflow-y: auto; }

/* ---------- Auth shell (login / register) ---------- */
body.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
}
.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-card h1 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.auth-card .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; margin-top: -8px; }
.auth-card .hint {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}
/* Link w zdaniu: podkreślenie, bo sam kolor odróżnia go od tekstu tylko 1.4:1 (WCAG 1.4.1). */
.auth-card .hint a { color: var(--accent-soft-text); text-decoration: underline; text-underline-offset: 2px; }
.auth-card .hint a:hover { text-decoration-thickness: 2px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .field label { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 8px; }

/* ---------- Cards & sections ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 20px;
}
.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-subtle);
    margin-bottom: 14px;
    padding-left: 9px;
    border-left: 2px solid var(--accent);
}
/* Odstęp tylko wtedy, gdy przed tytułem stoi coś widocznego — ukryte inputy
   (csrf_token, id formularza) nie mogą go wywoływać, a :not(:first-child) je liczył. */
:not(input[type="hidden"]) ~ .section-title { margin-top: 36px; }
.divider { border-top: 1px solid var(--border); margin: 20px 0; }

.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.content-header h2 { font-size: 14px; color: var(--text-subtle); font-weight: 500; }

