/* =============================================================================
   OTMS — _layout.css : sidebar + topbar + content shell
   ============================================================================= */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    transition: grid-template-columns var(--t-slow);
}
.app-shell.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed-w) 1fr;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 24px rgba(0, 0, 0, .1);
    z-index: 30;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border: none; }

.sidebar-brand {
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--topbar-h);
}
.sidebar-brand-logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
    flex-shrink: 0;
}
.sidebar-brand-logo svg { color: #fff; }
.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.sidebar-brand-text strong {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -.01em;
    color: #fff;
}
.sidebar-brand-text small {
    font-size: 10px;
    color: var(--sidebar-text-dim);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: 2px;
}

.sidebar-collapsed .sidebar-brand-text { display: none; }

.sidebar-section {
    padding: 14px 8px 4px;
}
.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: var(--sidebar-text-dim);
    padding: 4px 8px 8px;
}
.sidebar-collapsed .sidebar-section-title { display: none; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin: 0 4px;
    color: var(--sidebar-text);
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    transition: background var(--t), color var(--t);
    position: relative;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    width: calc(100% - 8px);
    text-align: left;
}
.sidebar-nav-item:hover {
    background: var(--sidebar-active-bg);
    color: #fff;
    text-decoration: none;
}
.sidebar-nav-item.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    font-weight: 600;
}
.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--sidebar-active-bd);
    border-radius: 2px;
}
.sidebar-nav-item svg {
    flex-shrink: 0;
    opacity: .8;
}
.sidebar-nav-item.active svg { opacity: 1; }
.sidebar-nav-item-badge {
    margin-left: auto;
    background: var(--brand-blue);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 9px 0;
}
.sidebar-collapsed .sidebar-nav-item > span,
.sidebar-collapsed .sidebar-nav-item-badge {
    display: none;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 12px 8px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

/* ===== MAIN AREA ===== */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;  /* fix dla flex children */
    background: var(--bg);
    min-height: 100vh;
}

/* ===== TOPBAR (glassmorphism) ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--topbar-border);
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 18px;
    gap: 14px;
}
.topbar-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-soft);
    transition: all var(--t);
}
.topbar-toggle:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
    background: var(--card);
}

.topbar-search {
    position: relative;
    max-width: 480px;
    flex: 1 1 auto;
    min-width: 200px;
}
.topbar-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--card);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    transition: all var(--t);
}
.topbar-search input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.topbar-search .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.topbar-search .search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    background: var(--border);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: var(--r-xs);
    pointer-events: none;
    font-family: var(--font-mono);
}

.topbar-rates {
    display: flex;
    gap: 8px;
    align-items: center;
}
.topbar-rate {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: var(--r-sm);
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-soft);
    font-family: var(--font-mono);
}
.topbar-rate-trend.up   { color: var(--st-success); }
.topbar-rate-trend.down { color: var(--st-danger); }

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--t);
}
.topbar-icon-btn:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}
.topbar-icon-btn .badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--st-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0 5px;
    height: 16px;
    line-height: 16px;
    border-radius: 8px;
    border: 2px solid var(--bg-elevated);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all var(--t);
}
.topbar-user:hover {
    background: var(--card);
}
.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.topbar-user-info strong {
    font-size: 12.5px;
    color: var(--text);
}
.topbar-user-info small {
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}

.topbar-dept-badge {
    background: linear-gradient(135deg, var(--brand-navy), var(--brand-blue));
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    box-shadow: 0 2px 8px rgba(12, 29, 58, .25);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ===== CONTENT ===== */
.content {
    padding: 24px;
    flex: 1;
    max-width: 100%;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 14px;
}
.page-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    line-height: 1.15;
    letter-spacing: -.02em;
    display: flex;
    align-items: center;
    gap: 12px;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 0;
    font-weight: 500;
}
.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ===== FLASH MESSAGES ===== */
.flash-stack {
    position: fixed;
    top: 70px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}
.flash {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--st-info);
    border-radius: var(--r);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    animation: slideInRight var(--t-slow);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 13px;
}
.flash.success { border-left-color: var(--st-success); }
.flash.error,
.flash.danger  { border-left-color: var(--st-danger); }
.flash.warning { border-left-color: var(--st-warning); }
.flash-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: var(--r-xs);
}
.flash-close:hover { color: var(--text); background: var(--border); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ===== MOBILE ===== */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: var(--sidebar-collapsed-w) 1fr;
    }
    .sidebar-brand-text,
    .sidebar-section-title,
    .sidebar-nav-item > span:not(.sidebar-nav-item-badge) {
        display: none;
    }
    .sidebar-nav-item {
        justify-content: center;
        padding: 9px 0;
    }
    .topbar-rates,
    .topbar-user-info,
    .topbar-dept-badge {
        display: none;
    }
    .content {
        padding: 14px;
    }
}

/* ===== NOTIFICATIONS DROPDOWN ===== */
.topbar-notif-wrap { position: relative; }
.topbar-notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    overflow: hidden;
    animation: dropIn .18s ease-out;
}
.topbar-notif-dropdown[hidden] { display: none; }
.topbar-notif-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--card-hover);
}
.topbar-notif-list {
    max-height: 420px;
    overflow-y: auto;
}
.topbar-notif-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.topbar-notif-item {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background var(--t-fast);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.topbar-notif-item:last-child { border-bottom: none; }
.topbar-notif-item:hover { background: var(--card-hover); }
.topbar-notif-item.unread { background: color-mix(in srgb, var(--brand-blue) 5%, var(--bg-elevated)); }
.topbar-notif-item.unread::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--brand-blue);
    margin-top: 6px;
    flex-shrink: 0;
}
.topbar-notif-item-content {
    flex: 1;
    min-width: 0;
}
.topbar-notif-item-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
    color: var(--text);
}
.topbar-notif-item-body {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.topbar-notif-item-time {
    font-size: 10.5px;
    color: var(--text-dim);
    margin-top: 4px;
    font-family: var(--font-mono);
}

/* ── Zwijane sekcje sidebara (Baza danych / Administracja) ── */
.sidebar-collapsible { padding: 0; margin: 0; }
.sidebar-collapsible > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center;
    user-select: none; outline: none;
}
.sidebar-collapsible > summary::-webkit-details-marker { display: none; }
.sidebar-collapsible > summary::marker { content: ''; }
.sidebar-collapsible > summary .sb-chev {
    margin-left: auto; display: inline-flex; transition: transform .18s ease; opacity: .55;
}
.sidebar-collapsible[open] > summary .sb-chev { transform: rotate(180deg); }
.sidebar-collapsible > summary:hover .sb-chev { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   TOP MENU — premium lift 2026 (globalny pasek; dopracowanie wyglądu)
   Nadpisania na końcu → wygrywają kaskadę. Wyłącznie tokeny, dark-safe.
   ═══════════════════════════════════════════════════════════════ */
.topbar { gap: 12px; padding: 0 16px; }

/* Wyszukiwarka globalna — solidne, eleganckie pole z miękkim chipem ikony i focus-ringiem */
.topbar-search { max-width: 540px; }
.topbar-search input {
    height: 40px; padding: 0 64px 0 42px; border: 1px solid var(--border);
    border-radius: var(--r); background: var(--card); box-shadow: var(--shadow-sm);
    font-size: 13px; transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.topbar-search input::placeholder { color: var(--text-dim); }
.topbar-search input:hover { border-color: var(--border-strong); }
.topbar-search input:focus {
    border-color: var(--brand-blue); background: var(--bg-elevated);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12), var(--shadow-sm);
}
.topbar-search .search-icon {
    left: 7px; width: 26px; height: 26px; border-radius: 7px; color: var(--brand-blue);
    background: color-mix(in srgb, var(--brand-blue) 12%, transparent);
    display: inline-flex; align-items: center; justify-content: center;
}
.topbar-search .search-kbd {
    right: 9px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
    background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
    padding: 2px 7px; border-radius: var(--r-xs);
}

/* Kursy NBP — czytelne „money chipy": symbol w kółku + wartość + trend */
.topbar-rates { gap: 8px; }
.topbar-rate {
    gap: 7px; padding: 0 10px 0 5px; height: 34px; border-radius: var(--r); background: var(--card);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: border-color var(--t), box-shadow var(--t);
}
.topbar-rate:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.topbar-rate .tr-code {
    width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px; color: var(--brand-blue-dark);
    background: color-mix(in srgb, var(--brand-blue) 12%, transparent);
}
.topbar-rate .tr-val { font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.topbar-rate-trend { display: inline-flex; }
.topbar-rate.up   .tr-code { color: var(--st-success); background: var(--st-success-bg); }
.topbar-rate.down .tr-code { color: var(--st-danger);  background: var(--st-danger-bg); }
.topbar-rate-trend.up   { color: var(--st-success); }
.topbar-rate-trend.down { color: var(--st-danger); }

/* Przyciski-ikony (motyw, powiadomienia) — miękki lift na hover */
.topbar-icon-btn {
    width: 38px; height: 38px; border-radius: var(--r); background: var(--card);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    transition: border-color var(--t), box-shadow var(--t), color var(--t), transform var(--t-fast);
}
.topbar-icon-btn:hover { border-color: var(--brand-blue); color: var(--brand-blue); box-shadow: var(--shadow); transform: translateY(-1px); }
.topbar-icon-btn .badge-count {
    top: -5px; right: -5px; min-width: 17px; height: 17px; line-height: 17px; padding: 0 5px;
    border-radius: 9px; box-shadow: 0 1px 3px rgba(220, 38, 38, .4);
}

/* Badge wydziału (TRANSPORT) — wyrównany wzrostem, dopieszczony */
.topbar-dept-badge {
    height: 34px; padding: 0 14px; border-radius: var(--r); font-size: 11px;
    box-shadow: 0 2px 10px rgba(12, 29, 58, .28);
}

/* Blok użytkownika — wyraźniejszy stan hover + obwódka awatara */
.topbar-user { gap: 9px; padding: 4px 11px 4px 5px; border-radius: var(--r); border: 1px solid transparent; }
.topbar-user:hover { background: var(--card); border-color: var(--border); box-shadow: var(--shadow-sm); }
.topbar-user .avatar, .topbar-user [class*="avatar"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 3px color-mix(in srgb, var(--brand-blue) 25%, transparent); }
.topbar-user-info strong { font-weight: 700; }

@media (max-width: 720px) {
    .topbar-search { max-width: none; }
    .topbar-rates { display: none; }
}
