/*
 * UI2 — układ aplikacji.
 * Spójny sidebar, topbar, przestrzeń robocza i moduł konta.
 * Ładowany po app.css i ui-foundation.css.
 */

:root {
    --layout-sidebar-width: 264px;
    --layout-content-max: 1580px;
    --layout-gutter: clamp(30px, 3.2vw, 52px);
    --layout-topbar-height: 72px;
}

/* ===== Admin shell ===== */
.app-shell {
    grid-template-columns: var(--layout-sidebar-width) minmax(0, 1fr);
}

.sidebar {
    width: var(--layout-sidebar-width);
    padding: 20px 14px 18px;
}

.sidebar__brand {
    min-height: 58px;
    padding: 5px 9px 18px;
}

.sidebar-quick-action {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 15px 4px 4px;
    padding: 0 15px;
    border: 1px solid rgba(137, 158, 255, 0.25);
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(135deg, rgba(98, 124, 245, 0.92), rgba(57, 86, 218, 0.95));
    box-shadow: 0 13px 28px rgba(21, 43, 126, 0.28);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 800;
}

.sidebar-quick-action:hover {
    transform: translateY(-1px);
    border-color: rgba(173, 189, 255, 0.48);
    box-shadow: 0 16px 34px rgba(21, 43, 126, 0.36);
}

.sidebar-quick-action svg,
.button--sidebar svg,
.account-link__icon svg,
.topbar-link svg,
.nav-item__icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar__nav {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 22px;
    overflow-y: auto;
    padding: 20px 2px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.13) transparent;
}

.sidebar__nav-group {
    display: grid;
    gap: 5px;
}

.sidebar__section-label {
    padding: 0 12px 7px;
    color: #697d9e;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.nav-item {
    min-height: 43px;
    gap: 10px;
    padding-inline: 10px 12px;
}

.nav-item__icon {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
}

.nav-item__icon svg {
    width: 17px;
    height: 17px;
}

.nav-item--active::after {
    content: "";
    position: absolute;
    right: 10px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #FF9A52;
    box-shadow: 0 0 0 4px rgba(255, 105, 0, .12);
}

.sidebar__footer {
    gap: 12px;
    padding: 15px 5px 0;
}

.account-link {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 720;
}

.account-link__icon {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #a9b8d1;
    background: rgba(255,255,255,.055);
}

.account-link__icon svg {
    width: 15px;
    height: 15px;
}

.button--sidebar {
    min-height: 39px;
    gap: 8px;
    color: #aebdd2;
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(255,255,255,.045);
    box-shadow: none;
}

.button--sidebar:hover {
    color: #ffffff;
    border-color: rgba(255,255,255,.18);
    background: rgba(255,255,255,.085);
}

.button--sidebar svg {
    width: 16px;
    height: 16px;
}

/* ===== Workspace + topbar ===== */
.workspace {
    min-height: 100vh;
    padding: 0 var(--layout-gutter) 72px;
}

.workspace > * {
    width: min(100%, var(--layout-content-max));
}

.app-topbar {
    position: sticky;
    z-index: 24;
    top: 0;
    width: auto !important;
    max-width: none !important;
    min-height: var(--layout-topbar-height);
    margin: 0 calc(var(--layout-gutter) * -1) 34px !important;
    padding: 0 var(--layout-gutter);
    border-bottom: 1px solid rgba(211, 221, 233, .85);
    background: rgba(248, 250, 255, .87);
    box-shadow: 0 8px 24px rgba(24, 39, 67, .035);
    backdrop-filter: blur(18px) saturate(145%);
}

.app-topbar__inner {
    width: min(100%, var(--layout-content-max));
    min-height: var(--layout-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 0 auto;
}

.app-breadcrumbs {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #94a1b3;
    font-size: 13px;
}

.app-breadcrumbs a {
    color: #748398;
    text-decoration: none;
    font-weight: 650;
}

.app-breadcrumbs a:hover {
    color: var(--ui-primary);
}

.app-breadcrumbs strong {
    overflow: hidden;
    color: #253348;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-topbar__actions {
    display: flex;
    align-items: center;
    gap: 11px;
}

.topbar-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid #dfe6ef;
    border-radius: 10px;
    color: #536176;
    background: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 720;
}

.topbar-link:hover {
    color: var(--ui-primary);
    border-color: #cbd7ee;
    background: #ffffff;
    box-shadow: var(--ui-shadow-xs);
}

.topbar-link svg {
    width: 15px;
    height: 15px;
}

.topbar-account {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid #d5deeb;
    border-radius: 11px;
    color: #2e4fc9;
    background: linear-gradient(145deg, #EAF4FB, #ffffff);
    text-decoration: none;
    font-size: 13px;
    font-weight: 850;
    box-shadow: var(--ui-shadow-xs);
}

.topbar-account:hover {
    transform: translateY(-1px);
    border-color: #bfcdf0;
    box-shadow: var(--ui-shadow-sm);
}

.workspace-header {
    position: relative;
    align-items: center;
    min-height: 112px;
    margin-bottom: 24px;
    padding: 23px 26px;
    overflow: hidden;
    border: 1px solid rgba(218, 227, 237, .95);
    border-radius: 20px;
    background: rgba(255,255,255,.78);
    box-shadow: 0 12px 36px rgba(24, 39, 67, .045);
    backdrop-filter: blur(12px);
}

.workspace-header::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -90px;
    width: 230px;
    height: 230px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(72, 104, 232, .10), transparent 67%);
    pointer-events: none;
}

.workspace-header > * {
    position: relative;
    z-index: 1;
}

.workspace-header h1 {
    font-size: clamp(31px, 2.5vw, 40px);
}

.workspace-header--compact {
    min-height: 104px;
}

.workspace-header--compact h1 {
    font-size: clamp(29px, 2.35vw, 37px);
}

/* Widok diagnostyki używa teraz tego samego shellu. */
.workspace--diagnostics .stats-grid,
.workspace--diagnostics .diagnostics-grid {
    width: min(100%, var(--layout-content-max));
}

/* ===== Powierzchnie modułów ===== */
.client-toolbar,
.project-toolbar,
.content-card,
.form-card,
.details-card,
.diagnostics-hero,
.empty-state {
    backdrop-filter: blur(10px);
}

.client-toolbar,
.project-toolbar {
    position: relative;
    overflow: hidden;
}

.client-toolbar::before,
.project-toolbar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--ui-primary), #7891f8 42%, transparent 82%);
    opacity: .75;
}

.content-card__header,
.section-heading {
    min-width: 0;
}

.content-card__header > div,
.section-heading > div {
    min-width: 0;
}

/* ===== Konto — odrębny moduł ===== */
.account-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 12%, rgba(73, 103, 229, .10), transparent 28rem),
        linear-gradient(180deg, #F7FAFC, #f1f5fa);
}

.account-topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    min-height: 70px;
    padding: 0 var(--layout-gutter);
    border-bottom: 1px solid rgba(214, 223, 234, .92);
    background: rgba(255,255,255,.88);
    box-shadow: 0 7px 24px rgba(24,39,67,.035);
    backdrop-filter: blur(16px);
}

.account-topbar .back-link {
    font-weight: 720;
}

.account-layout {
    width: min(1060px, calc(100% - 80px));
    align-items: stretch;
    gap: 24px;
    padding-top: 64px;
}

.account-summary,
.account-password-card {
    border: 1px solid var(--ui-border);
    border-radius: 22px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--ui-shadow-sm);
}

.account-summary {
    padding: 34px;
}

.account-password-card {
    padding: 34px;
}

/* ===== Client/public topbar — spójność bez przebudowy viewera ===== */
.client-topbar,
.map-topbar {
    position: relative;
    z-index: 40;
    height: 72px;
    padding-inline: clamp(24px, 3vw, 42px);
    border-bottom-color: #dfe6ef;
    background: rgba(255,255,255,.94);
    box-shadow: 0 9px 30px rgba(20,35,58,.055);
    backdrop-filter: blur(16px);
}

.client-topbar__actions {
    gap: 12px;
}

.client-topbar__brand .brand-placeholder {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
}

.client-topbar__actions .button {
    min-height: 39px;
}

/* ===== Standalone photo editor ===== */
.workspace--standalone {
    padding-top: 34px;
}

.workspace--standalone > .back-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    margin-bottom: 20px;
    padding: 0 12px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    color: #536176;
    background: rgba(255,255,255,.82);
    text-decoration: none;
    font-size: 13px;
    font-weight: 720;
}

.workspace--standalone > .back-link:hover {
    color: var(--ui-primary);
    border-color: #c5d2ea;
    background: #ffffff;
}

/* ===== Desktop responsiveness ===== */
@media (max-width: 1280px) {
    :root {
        --layout-sidebar-width: 244px;
        --layout-gutter: 30px;
    }

    .sidebar {
        padding-inline: 12px;
    }

}

@media (max-height: 760px) {
    .sidebar__brand {
        padding-bottom: 12px;
    }

    .sidebar-quick-action {
        margin-top: 10px;
    }

    .sidebar__nav {
        gap: 12px;
        padding-block: 13px;
    }

    .nav-item {
        min-height: 39px;
    }

    .sidebar__footer {
        gap: 8px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .app-topbar {
        animation: ui2-topbar-enter 260ms ease-out both;
    }

    @keyframes ui2-topbar-enter {
        from { opacity: 0; transform: translateY(-5px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

/* ===== MVP20.3: menu konta zawsze rozwijane w dół ===== */
.topbar-account-menu {
    position: relative;
    z-index: 80;
    flex: 0 0 auto;
}

.topbar-account-menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.topbar-account-menu > summary::-webkit-details-marker {
    display: none;
}

.topbar-account-menu[open] > .topbar-account {
    color: #ffffff;
    border-color: #1F6FB2;
    background: linear-gradient(145deg, #1F6FB2, #1F6FB2);
    box-shadow: 0 10px 25px rgba(31, 111, 178, .25);
}

.topbar-account-dropdown {
    position: absolute;
    z-index: 120;
    top: calc(100% + 10px);
    right: 0;
    bottom: auto;
    width: 238px;
    overflow: hidden;
    padding: 8px;
    border: 1px solid #dce4ef;
    border-radius: 16px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 22px 55px rgba(21, 34, 58, .18), 0 4px 14px rgba(21, 34, 58, .08);
    transform-origin: top right;
    animation: topbar-account-dropdown-in .16s ease-out both;
    backdrop-filter: blur(18px) saturate(145%);
}

.topbar-account-dropdown::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 13px;
    width: 11px;
    height: 11px;
    border-top: 1px solid #dce4ef;
    border-left: 1px solid #dce4ef;
    background: #ffffff;
    transform: rotate(45deg);
}

.topbar-account-dropdown__header {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding: 9px 9px 12px;
    border-bottom: 1px solid #edf1f6;
}

.topbar-account-dropdown__avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: #1F6FB2;
    background: #EAF4FB;
    font-size: 13px;
    font-weight: 850;
}

.topbar-account-dropdown__header > div {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.topbar-account-dropdown__header strong,
.topbar-account-dropdown__header span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-account-dropdown__header strong {
    color: #1e2b40;
    font-size: 12.5px;
}

.topbar-account-dropdown__header span:last-child {
    color: #7a899d;
    font-size: 11.5px;
}

.topbar-account-dropdown form {
    margin: 0;
}

.topbar-account-dropdown__item {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    color: #435168;
    background: transparent;
    text-decoration: none;
    font: inherit;
    font-size: 12.5px;
    font-weight: 720;
    text-align: left;
    cursor: pointer;
}

.topbar-account-dropdown__item:hover,
.topbar-account-dropdown__item:focus-visible {
    color: #1F6FB2;
    background: #f0f4ff;
    outline: none;
}

.topbar-account-dropdown__item--danger:hover,
.topbar-account-dropdown__item--danger:focus-visible {
    color: #b43c37;
    background: #fff2f1;
}

.topbar-account-dropdown__item svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes topbar-account-dropdown-in {
    from { opacity: 0; transform: translate3d(0, -6px, 0) scale(.98); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .topbar-account-dropdown { animation: none; }
}
