/* Rozložení aplikace: na počítači (od 960 px) postranní menu a nahoře název stránky, na telefonu horní lišta
   s avatarem, spodní záložky a výsuvný panel „Více“. Barvy se berou z proměnných v app.css (světlý i tmavý režim). */
:root {
    --nav-bg: var(--accent);
    --nav-fg: #ffffff;
    --nav-muted: rgba(255, 255, 255, 0.78);
    --nav-hover: rgba(255, 255, 255, 0.14);
    --nav-line: rgba(255, 255, 255, 0.22);
    --nav-pill-bg: #ffffff;
    --nav-pill-fg: var(--accent-strong);
    --sidebar-width: 17rem;
    --bottomnav-height: 4.25rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --nav-bg: var(--surface);
        --nav-fg: var(--ink);
        --nav-muted: var(--muted);
        --nav-hover: var(--soft);
        --nav-line: var(--line);
        --nav-pill-bg: var(--accent);
        --nav-pill-fg: var(--accent-fg);
    }
}

.shell { min-height: 100vh; }
.shell-main { min-width: 0; }

/* --- Horní lišta ---------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0.4rem 1.25rem;
    padding-top: max(0.4rem, env(safe-area-inset-top, 0px));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar-mobile { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar-desktop { display: none; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    font-weight: 800;
    font-size: 1.3rem;
    text-decoration: none;
    color: var(--ink);
}

.page-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }

.avatar {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 800;
    font-size: 1.05rem;
}

.avatar-button {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

/* --- Obsah ---------------------------------------------------------------- */
/* Na telefonu je dole místo pro spodní navigaci. */
.shell--nav .content {
    padding-bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px) + 1.5rem);
}

/* --- Postranní menu (počítač) -------------------------------------------- */
.sidebar { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.6rem 1.1rem;
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--nav-fg);
    text-decoration: none;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 46px;
    padding: 0.5rem 0.85rem;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--nav-fg);
    font: inherit;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.nav-link .icon { width: 1.3em; height: 1.3em; }
.nav-link:hover { background: var(--nav-hover); }
/* Aktivní položka je „pilulka“ v opačných barvách. */
.nav-link.active, .nav-link.active:hover { background: var(--nav-pill-bg); color: var(--nav-pill-fg); }
.sidebar a:focus-visible, .sidebar button:focus-visible { outline-color: var(--nav-fg); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.35rem 0.25rem;
    border-top: 1px solid var(--nav-line);
}
.sidebar .avatar { background: var(--nav-pill-bg); color: var(--nav-pill-fg); }
.sidebar-user-text { flex: 1; min-width: 0; }
.sidebar-user-name { color: var(--nav-fg); font-weight: 800; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { color: var(--nav-muted); font-size: 0.85rem; }
.sidebar-user form { margin: 0; }

.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--nav-fg);
    cursor: pointer;
}
.icon-button:hover { background: var(--nav-hover); }

/* --- Spodní navigace (telefon) ------------------------------------------- */
.bottomnav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 56px;
    padding: 0.4rem 0.25rem;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.tab-icon { display: grid; place-items: center; width: 3.4rem; height: 1.9rem; border-radius: 99px; }
.tab-icon .icon { width: 1.4em; height: 1.4em; }
.tab.active { color: var(--accent-strong); }
.tab.active .tab-icon { background: var(--soft); }

/* --- Panel „Více“ (telefon) ---------------------------------------------- */
.scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    padding: 0;
    border: 0;
    background: rgba(20, 32, 27, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0.5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -12px 32px -12px rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s;
}

body.sheet-open .scrim { opacity: 1; visibility: visible; }
body.sheet-open .sheet { transform: none; visibility: visible; }

.sheet-handle { width: 40px; height: 4px; margin: 0.25rem auto 0.9rem; border-radius: 99px; background: var(--line); }
.sheet-user { display: flex; align-items: center; gap: 0.85rem; padding: 0 0.5rem 0.9rem; }
.sheet-name { font-weight: 800; overflow-wrap: anywhere; }
.sheet-role { color: var(--muted); font-size: 0.9rem; }
.sheet form { margin: 0; }

.sheet-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    min-height: 52px;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.sheet-item .icon { width: 1.35em; height: 1.35em; color: var(--accent); }
.sheet-item:hover { background: var(--soft); }
.sheet-item--danger, .sheet-item--danger .icon { color: var(--danger); }

/* Tlačítko instalace je vidět, jen když prohlížeč nabídne instalaci (třídu nastavuje pwa.js). */
[data-pwa-install] { display: none; }
html.pwa-can-install .nav-link[data-pwa-install], html.pwa-can-install .sheet-item[data-pwa-install] { display: flex; }

/* --- Počítač -------------------------------------------------------------- */
@media (min-width: 960px) {
    .topbar-mobile, .bottomnav, .scrim, .sheet { display: none; }
    .topbar-desktop { display: flex; align-items: center; min-height: 52px; }
    .shell--nav .topbar { padding: 0.5rem 2rem; }

    .shell--nav .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 25;
        display: flex;
        flex-direction: column;
        width: var(--sidebar-width);
        padding: 1rem 0.85rem;
        padding-top: max(1rem, env(safe-area-inset-top, 0px));
        background: var(--nav-bg);
        color: var(--nav-fg);
        border-right: 1px solid var(--nav-line);
    }

    .shell--nav .shell-main { margin-left: var(--sidebar-width); }
    .shell--nav .content { max-width: 56rem; padding: 2rem 2rem 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .scrim, .sheet { transition: none; }
}
