/* ==========================================================================
   KuKA shell - app chrome (Pages/Shared/_Layout.cshtml) + list refinements.
   Loaded after app.css and kuka-theme.css. Brand variables (--kuka-*) come
   from kuka-theme.css; hex fallbacks keep this file safe on its own.
   Mobile-first; breakpoints 768 / 1280 (see tokens.css).
   ========================================================================== */

/* ---- Top bar: navy, logo tile + wordmark, light controls ---- */
.kuka-topbar {
    --kuka-on-navy: #e8ecf2;
    --kuka-on-navy-muted: #b6c0d1;
    --bs-navbar-color: var(--kuka-on-navy-muted);
    --bs-navbar-hover-color: #ffffff;
    --bs-navbar-active-color: #ffffff;
    --bs-nav-link-color: var(--kuka-on-navy-muted);
    --bs-nav-link-hover-color: #ffffff;
    padding-block: var(--tt-space-2);
    min-height: var(--tt-topbar-height);
    color: var(--kuka-on-navy);
    background-color: var(--kuka-navy-900, #0f1729);
    background-image: var(--kuka-gradient-brand, linear-gradient(#0f1729, #0f1729));
    border-bottom: 1px solid var(--kuka-bronze-500, #b78a2e);
    box-shadow: 0 2px 12px rgba(11, 18, 32, 0.25);
}

.kuka-topbar .navbar-brand {
    color: #ffffff;
    text-align: start;
    word-break: normal;
    white-space: nowrap;
    min-height: var(--tt-touch-target-min);
}

.kuka-topbar__tile {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--tt-radius-md);
    /* the mark is navy + brass: it needs a light tile to stay legible on navy */
    background-color: #f4efe3;
    box-shadow: inset 0 0 0 1px rgba(183, 138, 46, 0.55);
}

.kuka-topbar__mark {
    display: block;
    height: 1.75rem;
    width: auto;
    aspect-ratio: 120 / 130;
    /* The SVG artwork is not centered in its 120x130 viewBox (bars span x 25-104,
       y 26-130, i.e. 4.5 right / 13 low of centre). Compensate here instead of
       editing the shared asset (also used by /welcome and the favicon). */
    transform: translate(-3.75%, -10%);
}

.kuka-topbar__wordmark {
    font-family: var(--kuka-font-display, var(--tt-font-family));
    font-size: 1.25rem;
    font-weight: var(--tt-font-weight-bold);
    letter-spacing: 0.02em;
    color: #ffffff;
}

.kuka-topbar .nav-link,
.kuka-topbar .tt-hamburger {
    display: inline-flex;
    align-items: center;
    min-height: var(--tt-touch-target-min);
    border-radius: var(--tt-radius-md);
    color: var(--kuka-on-navy-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.kuka-topbar .tt-hamburger {
    color: #ffffff;
}

.kuka-topbar .nav-link:hover,
.kuka-topbar .nav-link:focus,
.kuka-topbar .nav-link.show,
.kuka-topbar .tt-hamburger:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

.kuka-topbar .nav-link:focus-visible,
.kuka-topbar .tt-hamburger:focus-visible,
.kuka-topbar .navbar-brand:focus-visible {
    outline: 2px solid var(--kuka-bronze-300, #d1b06b);
    outline-offset: 2px;
    box-shadow: none;
}

/* User name can be long on phones: keep the bar on one line */
.kuka-topbar #userDropdown {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .kuka-topbar #userDropdown {
        max-width: 18rem;
    }
}

/* Dropdown menus (user, language): raised surface, bronze active/hover */
.kuka-topbar .dropdown-menu {
    --bs-dropdown-border-color: var(--tt-color-border);
    --bs-dropdown-border-radius: var(--tt-radius-md);
    --bs-dropdown-link-active-bg: var(--kuka-navy-700, #1f3d7a);
    --bs-dropdown-link-active-color: #ffffff;
    margin-top: var(--tt-space-2);
    padding: var(--tt-space-1);
    border-top: 2px solid var(--kuka-bronze-500, #b78a2e);
    box-shadow: var(--tt-shadow-lg);
}

.kuka-topbar .dropdown-item {
    min-height: var(--tt-touch-target-min);
    display: flex;
    align-items: center;
    border-radius: var(--tt-radius-sm);
}

.kuka-topbar .dropdown-item:hover,
.kuka-topbar .dropdown-item:focus {
    background-color: rgba(183, 138, 46, 0.14);
    color: var(--tt-color-text);
}

.kuka-topbar .dropdown-item.active:hover {
    color: #ffffff;
}

/* ---- Drawer: navy header, bronze active bar ---- */
.tt-drawer__header {
    color: #ffffff;
    background-color: var(--kuka-navy-900, #0f1729);
    background-image: var(--kuka-gradient-brand, linear-gradient(#0f1729, #0f1729));
    border-bottom: 2px solid var(--kuka-bronze-500, #b78a2e);
}

.tt-drawer__title {
    font-family: var(--kuka-font-display, var(--tt-font-family));
    color: #ffffff;
}

.tt-drawer__header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.85;
}

.tt-drawer__header .btn-close:hover {
    opacity: 1;
}

.tt-drawer__heading {
    color: var(--kuka-bronze-700, #8a6420);
}

html[data-bs-theme="dark"] .tt-drawer__heading {
    color: var(--kuka-bronze-300, #d1b06b);
}

.tt-drawer__link {
    position: relative;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tt-drawer__link::before {
    content: "";
    position: absolute;
    inset-block: 0.5rem;
    inset-inline-start: 0.25rem;
    width: 3px;
    border-radius: var(--tt-radius-pill);
    background-color: var(--kuka-bronze-500, #b78a2e);
    transform: scaleY(0);
    transition: transform 0.15s ease;
}

.tt-drawer__link:hover {
    color: var(--tt-color-text);
    background-color: rgba(183, 138, 46, 0.1);
}

.tt-drawer__link:hover::before {
    transform: scaleY(0.4);
}

.tt-drawer__link.active,
.tt-drawer__link[aria-current="page"] {
    color: var(--kuka-navy-700, #1f3d7a);
    background-color: rgba(183, 138, 46, 0.14);
}

.tt-drawer__link.active::before,
.tt-drawer__link[aria-current="page"]::before {
    transform: scaleY(1);
}

html[data-bs-theme="dark"] .tt-drawer__link.active,
html[data-bs-theme="dark"] .tt-drawer__link[aria-current="page"] {
    color: var(--kuka-bronze-300, #d1b06b);
    background-color: rgba(209, 176, 107, 0.14);
}

/* ---- Restaurants list (.kuka-list) ---- */
.kuka-list__header {
    position: relative;
    padding-block-end: var(--tt-space-3);
    border-bottom: 1px solid var(--tt-color-border);
}

.kuka-list__header::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    bottom: -1px;
    width: 3rem;
    height: 3px;
    background-color: var(--kuka-bronze-500, #b78a2e);
    border-radius: var(--tt-radius-pill);
}

.kuka-list__title {
    font-family: var(--kuka-font-display, var(--tt-font-family));
    color: var(--kuka-navy-900, var(--tt-color-text));
}

html[data-bs-theme="dark"] .kuka-list__title {
    color: var(--tt-color-text);
}

.kuka-list .notion-toolbar__search,
.kuka-list .notion-toolbar .form-select {
    min-height: var(--tt-touch-target-min);
    border-radius: var(--tt-radius-md);
    border-color: var(--tt-color-border);
}

.kuka-list .notion-toolbar__search:focus,
.kuka-list .notion-toolbar .form-select:focus {
    border-color: var(--kuka-bronze-500, #b78a2e);
    box-shadow: 0 0 0 0.2rem rgba(183, 138, 46, 0.25);
}

.kuka-table .kuka-table__name {
    font-weight: var(--tt-font-weight-semibold);
    color: var(--tt-color-text);
}

.kuka-table .kuka-table__muted {
    color: var(--tt-color-text-muted);
}

.kuka-table .kuka-table__num {
    font-variant-numeric: tabular-nums;
}

/* Row actions: quiet ghost icon buttons, 44px touch targets from app.css */
.kuka-table .tt-icon-btn {
    border-color: transparent;
    background-color: transparent;
    color: var(--tt-color-text-muted);
}

.kuka-table .tt-icon-btn:hover {
    color: var(--kuka-navy-700, var(--tt-color-primary));
    border-color: var(--kuka-bronze-500, #b78a2e);
    background-color: rgba(183, 138, 46, 0.12);
}

.kuka-table .tt-icon-btn--danger:hover {
    color: var(--tt-color-danger);
    border-color: var(--tt-color-danger);
    background-color: var(--tt-color-danger-subtle);
}

html[data-bs-theme="dark"] .kuka-table .tt-icon-btn:hover {
    color: var(--kuka-bronze-300, #d1b06b);
}

html[data-bs-theme="dark"] .kuka-table .tt-icon-btn--danger:hover {
    color: var(--tt-color-danger);
}

@media (min-width: 768px) {
    /* overflow:hidden on .tt-table would break position:sticky on the header */
    table.kuka-table {
        overflow: visible;
        border-collapse: separate;
        border-spacing: 0;
    }

    .kuka-table thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background-color: var(--tt-color-surface-sunken);
        border-block-end: 1px solid var(--tt-color-border-strong);
        box-shadow: 0 1px 0 var(--tt-color-border-strong);
        white-space: nowrap;
    }

    .kuka-table thead th:first-child {
        border-top-left-radius: var(--tt-radius-lg);
    }

    .kuka-table thead th:last-child {
        border-top-right-radius: var(--tt-radius-lg);
    }

    .kuka-table tbody tr:last-child td:first-child {
        border-bottom-left-radius: var(--tt-radius-lg);
    }

    .kuka-table tbody tr:last-child td:last-child {
        border-bottom-right-radius: var(--tt-radius-lg);
    }

    .kuka-table tbody td {
        border-block-end: 1px solid var(--tt-color-border);
        transition: background-color 0.12s ease;
    }

    .kuka-table tbody tr:last-child td {
        border-block-end: 0;
    }

    /* beats staff-notion.css `table.notion-table tbody tr:hover td` */
    table.notion-table.kuka-table tbody tr:hover td {
        background-color: rgba(183, 138, 46, 0.07);
    }

    .kuka-table tbody tr:hover td:first-child {
        box-shadow: inset 3px 0 0 var(--kuka-bronze-500, #b78a2e);
    }
}

/* ---- Empty state ---- */
.kuka-empty {
    margin-block-start: var(--tt-space-4);
    background-color: var(--tt-color-surface);
    background-image: var(--kuka-grid-pattern, none);
    border: 1px dashed var(--tt-color-border-strong);
    border-radius: var(--tt-radius-lg);
}

.kuka-empty__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background-color: rgba(183, 138, 46, 0.14);
    box-shadow: inset 0 0 0 1px rgba(183, 138, 46, 0.45);
}

.kuka-empty__badge .tt-empty__icon {
    font-size: 1.75rem;
    color: var(--kuka-bronze-700, #8a6420);
}

html[data-bs-theme="dark"] .kuka-empty__badge .tt-empty__icon {
    color: var(--kuka-bronze-300, #d1b06b);
}

@media (prefers-reduced-motion: reduce) {
    .kuka-topbar .nav-link,
    .kuka-topbar .tt-hamburger,
    .tt-drawer__link,
    .tt-drawer__link::before,
    .kuka-table tbody td {
        transition: none;
    }
}

/* ==========================================================================
   Mobile pass (360-767px)
   ========================================================================== */

/* Scoped _Layout.cshtml.css sets `a { color: #0077cc }`; it beats the single-class
   .tt-drawer__link rule, so inactive drawer links turned blue. Specificity bump. */
.tt-drawer .tt-drawer__link {
    color: var(--tt-color-text-muted);
}

/* Same scoped rule makes footer links light-theme blue in both themes */
footer.footer a {
    color: var(--tt-color-primary);
}

/* flex dropdown items collapse the space after the flag icon */
.kuka-topbar .dropdown-item .fi {
    margin-inline-end: 0.5rem;
}

@media (max-width: 575.98px) {
    /* Compact controls: user + language collapse to icon-only (text stays in the DOM for
       screen readers; font-size 0 hides it visually), so the bar never wraps. */
    .kuka-topbar .navbar-nav {
        flex-wrap: nowrap;
        gap: 0 !important;
    }

    .kuka-topbar #userDropdown,
    .kuka-topbar #languageDropdown {
        justify-content: center;
        min-width: var(--tt-touch-target-min);
        max-width: none;
        padding-inline: 0.5rem;
        font-size: 0;
    }

    .kuka-topbar #userDropdown .bi {
        margin: 0 !important;
        font-size: 1.5rem;
    }

    .kuka-topbar #languageDropdown .fi {
        font-size: 1.25rem;
    }

    .kuka-topbar #userDropdown::after,
    .kuka-topbar #languageDropdown::after {
        display: none;
    }

    .kuka-topbar #themeToggle {
        justify-content: center;
        min-width: var(--tt-touch-target-min);
    }

    .kuka-topbar .navbar-brand {
        flex: none;
    }
}

@media (max-width: 767.98px) {
    /* Platform dashboard: compact stat strip uses the 14rem *max* to count columns, which
       left one 195px tile per row. Two across on phones. */
    .kuka-bo-stats.kuka-bo-stats--compact {
        grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    }

    /* .tt-container pages (Billing, Menus) already sit inside the layout's .container:
       the second gutter doubled the side inset. */
    main > .tt-container.notion-page {
        padding-inline: 0;
    }

    /* Card-collapsed tables: keep the label from shrinking ("VISITO R") and let long
       values (ids, emails) wrap at the end of the row. */
    .tt-table td::before {
        flex: none;
    }

    .tt-table td {
        min-width: 0;
        overflow-wrap: anywhere;
        text-align: end;
    }

    /* Rows are already cards: drop the outer table frame (double border) */
    table.tt-table.notion-table {
        background-color: transparent;
        border: 0;
        box-shadow: none;
    }

    /* Fixed primary action bar (~66px) would sit on top of the footer links: lift the footer
       above it and reserve the space once, instead of the extra main padding. */
    body:has(.tt-action-bar:not(.tt-action-bar--inline)) {
        margin-bottom: calc(60px + 66px + env(safe-area-inset-bottom, 0px));
    }

    body:has(.tt-action-bar:not(.tt-action-bar--inline)) .footer {
        bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    }

    body:has(.tt-action-bar:not(.tt-action-bar--inline)) main {
        padding-bottom: 1rem;
    }

    /* Only in-flow (inline) bars: no space reserved for a fixed bar that isn't there */
    body:has(.tt-action-bar--inline):not(:has(.tt-action-bar:not(.tt-action-bar--inline))) main {
        padding-bottom: 1rem;
    }
}
