/* Hotelinnovativ Spesen shell — desktop sidebar + mobile-only bottom tabs */

:root {
    --hi-navy: #073050;
    --hi-navy-deep: #052038;
    --hi-navy-mid: #0a4068;
    --hi-gold: #b89855;
    --hi-gold-soft: #c9ad6e;
    --hi-mist: #6a8499;
    --hi-lime: #abd173;
    --hi-surface: #f4f7fa;
    --tabbar-h: 72px;
}

body.hi-shell {
    font-family: "Instrument Sans", "Segoe UI", sans-serif;
}

/* —— Desktop sidebar (Spesen) —— */
body.hi-shell .sidebar {
    background: linear-gradient(180deg, var(--hi-navy) 0%, var(--hi-navy-deep) 100%) !important;
    border-right: 1px solid rgba(184, 152, 85, 0.22) !important;
    color: #fff;
}

body.hi-shell .brand {
    align-items: center;
    text-align: center;
    border-bottom-color: rgba(139, 165, 184, 0.25) !important;
}

body.hi-shell .brand-logo--hi {
    max-width: min(220px, 100%);
    max-height: 64px;
    margin-bottom: 14px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

body.hi-shell .brand-title {
    color: #fff !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

body.hi-shell .brand small,
body.hi-shell .admin-brand-pill {
    color: var(--hi-mist) !important;
    background: transparent !important;
    border: 0 !important;
    letter-spacing: 0.04em;
}

body.hi-shell .nav-group-label {
    margin: 18px 8px 8px;
    padding: 0;
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--hi-mist) !important;
}

body.hi-shell .nav-link {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 11px 14px !important;
    margin-bottom: 6px !important;
    border-radius: 12px !important;
    border: 0 !important;
    color: #fff !important;
    background: transparent !important;
}

body.hi-shell .nav-link__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    color: inherit;
}

body.hi-shell .nav-link__icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

body.hi-shell .nav-link:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

body.hi-shell .nav-link.active {
    background: var(--hi-gold) !important;
    color: var(--hi-navy) !important;
    font-weight: 650;
    box-shadow: 0 6px 16px rgba(184, 152, 85, 0.28);
}

body.hi-shell .nav-group-toggle {
    border: 0 !important;
    border-radius: 12px !important;
    color: #fff !important;
    padding: 11px 14px !important;
}

body.hi-shell .nav-group-toggle__main {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

body.hi-shell .nav-group-toggle:hover,
body.hi-shell .nav-group-toggle.is-active,
body.hi-shell .nav-group--expandable.is-open > .nav-group-toggle {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: transparent !important;
}

body.hi-shell .nav-link--child {
    padding-left: 48px !important;
    font-size: 0.9rem !important;
    color: rgba(255, 255, 255, 0.88) !important;
}

body.hi-shell .nav-link--child.active {
    background: var(--hi-gold) !important;
    color: var(--hi-navy) !important;
}

body.hi-shell .sidebar-footer {
    border-top: 1px solid rgba(139, 165, 184, 0.25);
    color: var(--hi-mist);
    margin-top: auto;
    padding-top: 14px;
}

body.hi-shell .sidebar-footer button.secondary {
    width: 100%;
    border-radius: 999px;
    border-color: rgba(255, 255, 255, 0.18);
    background: transparent;
    color: var(--hi-mist);
}

body.hi-shell .sidebar-footer button.secondary:hover {
    background: var(--hi-gold);
    border-color: var(--hi-gold);
    color: var(--hi-navy);
}

body.hi-shell .main {
    background: var(--hi-surface);
    color: var(--hi-navy);
    /* Override portal dark tokens — main content is light Spesen surface */
    --text: #073050;
    --muted: #3d5a70;
    --panel: #ffffff;
    --panel-2: #f4f7fa;
    --line: rgba(7, 48, 80, 0.14);
    --link: #0a4068;
    --link-hover: #8a6f35;
    --select-text: #073050;
    --select-bg: #ffffff;
    --select-border: rgba(7, 48, 80, 0.22);
    --btn-secondary-text: #073050;
    --btn-secondary-bg: #e8eef4;
    --btn-secondary-border: rgba(7, 48, 80, 0.18);
    --surface-inset: #ffffff;
    --surface-inset-text: #073050;
    --surface-inset-text-muted: #3d5a70;
    --table-row-border: rgba(7, 48, 80, 0.1);
    --card-bg-end: #ffffff;
}

body.hi-shell .main,
body.hi-shell .main p,
body.hi-shell .main label,
body.hi-shell .main td,
body.hi-shell .main th,
body.hi-shell .main li,
body.hi-shell .main span:not(.badge):not(.app-tab__label),
body.hi-shell .main .muted,
body.hi-shell .main small {
    color: inherit;
}

body.hi-shell .main .muted,
body.hi-shell .main .help,
body.hi-shell .main .hint {
    color: var(--muted) !important;
}

body.hi-shell .main a:not(.nav-link):not(.app-tab):not(.tvm-btn):not(.btn) {
    color: var(--link);
}

body.hi-shell .main input,
body.hi-shell .main select,
body.hi-shell .main textarea {
    color: var(--text);
    background: #fff;
    border-color: var(--input-border, rgba(7, 48, 80, 0.22));
}

body.hi-shell .card {
    background: #fff;
    border: 1px solid rgba(7, 48, 80, 0.08);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(7, 48, 80, 0.06);
    color: var(--hi-navy);
}

body.hi-shell .app-toolbar {
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(7, 48, 80, 0.08);
    color: var(--hi-navy);
}

body.hi-shell h1,
body.hi-shell h2,
body.hi-shell h3 {
    color: var(--hi-navy);
}

body.hi-shell button:not(.secondary):not(.theme-toggle):not(.app-tab):not(.app-sheet__action):not(.menu-btn):not(.nav-group-toggle) {
    background: var(--hi-navy);
    border-color: var(--hi-navy);
    color: #fff;
    border-radius: 999px;
}

body.hi-shell button:not(.secondary):not(.theme-toggle):not(.app-tab):not(.app-sheet__action):not(.menu-btn):not(.nav-group-toggle):hover {
    background: var(--hi-gold);
    border-color: var(--hi-gold);
    color: var(--hi-navy);
}

html[data-theme="dark"] body.hi-shell .main {
    background: #0a1624;
    color: #e8eef4;
    --text: #e8eef4;
    --muted: #9bb0c0;
    --panel: #112338;
    --panel-2: #0d1c2c;
    --line: rgba(255, 255, 255, 0.12);
    --link: #c9ad6e;
    --link-hover: #e0c888;
    --select-text: #e8eef4;
    --select-bg: #112338;
    --select-border: rgba(255, 255, 255, 0.18);
    --btn-secondary-text: #e8eef4;
    --btn-secondary-bg: #152a40;
    --btn-secondary-border: rgba(255, 255, 255, 0.16);
    --surface-inset: #112338;
    --surface-inset-text: #e8eef4;
    --surface-inset-text-muted: #9bb0c0;
    --table-row-border: rgba(255, 255, 255, 0.1);
    --card-bg-end: #112338;
}

html[data-theme="dark"] body.hi-shell .app-toolbar {
    background: rgba(7, 48, 80, 0.94);
    border-bottom-color: rgba(255, 255, 255, 0.08);
    color: #e8eef4;
}

html[data-theme="dark"] body.hi-shell .card {
    background: #112338;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e8eef4;
}

html[data-theme="dark"] body.hi-shell h1,
html[data-theme="dark"] body.hi-shell h2,
html[data-theme="dark"] body.hi-shell h3 {
    color: #f2f6fa;
}

html[data-theme="dark"] body.hi-shell .main input,
html[data-theme="dark"] body.hi-shell .main select,
html[data-theme="dark"] body.hi-shell .main textarea {
    color: #e8eef4;
    background: #0d1c2c;
}

/* Bottom tab bar / sheets: desktop hidden */
.app-tabbar,
.app-sheet,
.app-sheet-overlay {
    display: none;
}

/* —— Mobile: bottom webapp nav (no sidebar / hamburger) —— */
@media (max-width: 1024px) {
    body.hi-shell .sidebar,
    body.hi-shell .sidebar-overlay,
    body.hi-shell .menu-btn,
    body.hi-shell .admin-mobile-nav,
    body.hi-shell .app-toolbar__menu {
        display: none !important;
    }

    body.hi-shell .layout {
        grid-template-columns: 1fr !important;
    }

    body.hi-shell.sidebar-open .sidebar,
    body.hi-shell.sidebar-open .sidebar-overlay {
        display: none !important;
    }

    body.hi-shell .main {
        padding: 12px 12px calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px)) !important;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    body.hi-shell .app-toolbar {
        position: sticky;
        top: 0;
        z-index: 30;
        padding-top: max(10px, env(safe-area-inset-top));
        flex-wrap: wrap;
        gap: 8px;
    }

    .app-tabbar {
        display: block !important;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: linear-gradient(180deg, var(--hi-navy), var(--hi-navy-deep));
        border-top: 1px solid rgba(184, 152, 85, 0.3);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -8px 28px rgba(5, 32, 56, 0.28);
    }

    .app-tabbar[hidden] {
        display: block !important; /* JS unhides; CSS owns visibility on mobile */
    }

    .app-tabbar__scroll {
        display: flex;
        align-items: stretch;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }

    .app-tabbar__scroll::-webkit-scrollbar {
        display: none;
    }

    .app-tab {
        appearance: none;
        border: 0;
        background: transparent;
        color: rgba(255, 255, 255, 0.85);
        text-decoration: none;
        cursor: pointer;
        font-family: inherit;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-width: 64px;
        flex: 0 0 auto;
        padding: 8px 10px;
        border-radius: 14px;
        -webkit-tap-highlight-color: transparent;
    }

    .app-tab__icon {
        width: 22px;
        height: 22px;
        display: grid;
        place-items: center;
    }

    .app-tab__icon svg {
        width: 20px;
        height: 20px;
        display: block;
    }

    .app-tab__label {
        font-size: 0.62rem;
        font-weight: 650;
        white-space: nowrap;
        max-width: 68px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .app-tab.is-active {
        background: var(--hi-gold);
        color: var(--hi-navy);
    }

    .app-sheet-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(5, 32, 56, 0.45);
    }

    .app-sheet-overlay[hidden] {
        display: none !important;
    }

    .app-sheet {
        display: block;
        position: fixed;
        left: 50%;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
        transform: translateX(-50%);
        z-index: 60;
        width: min(420px, calc(100% - 20px));
        max-height: min(52vh, 420px);
        overflow: auto;
        background: #fff;
        color: var(--hi-navy);
        border-radius: 20px;
        padding: 16px 14px 14px;
        box-shadow: 0 16px 40px rgba(5, 32, 56, 0.28);
    }

    .app-sheet[hidden] {
        display: none !important;
    }

    .app-sheet__kicker {
        margin: 0 0 10px;
        font-size: 0.7rem;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        font-weight: 650;
        color: var(--hi-mist);
    }

    .app-sheet__meta {
        margin-bottom: 12px;
        font-size: 0.92rem;
        color: var(--hi-navy-mid);
    }

    .app-sheet__link,
    .app-sheet__action {
        display: block;
        width: 100%;
        text-align: left;
        appearance: none;
        border: 0;
        background: var(--hi-surface);
        color: var(--hi-navy);
        font: inherit;
        font-weight: 600;
        padding: 14px 16px;
        border-radius: 999px;
        margin-bottom: 8px;
        text-decoration: none;
        cursor: pointer;
    }

    .app-sheet__link.is-active,
    .app-sheet__link:hover,
    .app-sheet__action:hover {
        background: var(--hi-gold);
        color: var(--hi-navy);
    }

    .app-sheet__action--danger {
        background: rgba(185, 28, 28, 0.08);
        color: #9b1c1c;
    }

    /* Prevent cut-off / horizontal page scroll on module pages */
    body.hi-shell .main .card,
    body.hi-shell .main .grid-2,
    body.hi-shell .main .grid-3,
    body.hi-shell .main .admin-section,
    body.hi-shell .main .admin-form-panel,
    body.hi-shell .main .topbar,
    body.hi-shell .main .toolbar {
        max-width: 100%;
        min-width: 0;
    }

    body.hi-shell .main .grid-2,
    body.hi-shell .main .grid-3 {
        grid-template-columns: 1fr !important;
    }

    body.hi-shell .main table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.hi-shell .main iframe,
    body.hi-shell .main video,
    body.hi-shell .main img {
        max-width: 100%;
        height: auto;
    }

    body.hi-shell .main input,
    body.hi-shell .main select,
    body.hi-shell .main textarea,
    body.hi-shell .main button {
        max-width: 100%;
    }
}

/* PWA install gate — visibility driven by JS (works on large tablets / iPad landscape too) */
.pwa-install-gate {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top, 0px)) 18px max(24px, env(safe-area-inset-bottom, 0px));
    background:
        radial-gradient(700px 320px at 15% -10%, rgba(184, 152, 85, 0.28), transparent 55%),
        linear-gradient(160deg, #052038 0%, #073050 50%, #0a4068 100%);
    color: #fff;
    text-align: center;
    box-sizing: border-box;
}

.pwa-install-gate.is-visible,
html.pwa-gate-on .pwa-install-gate {
    display: flex;
}

.pwa-install-gate[hidden] {
    display: none !important;
}

.pwa-install-gate__card {
    width: min(420px, 100%);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(184, 152, 85, 0.35);
    border-radius: 22px;
    padding: 28px 22px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pwa-install-gate__logo {
    max-width: 220px;
    max-height: 72px;
    margin: 0 auto 18px;
    display: block;
}

.pwa-install-gate__title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 700;
}

.pwa-install-gate__text {
    margin: 0 0 18px;
    color: var(--hi-mist, #d7e2ec);
    line-height: 1.45;
    font-size: 0.95rem;
}

.pwa-install-gate__btn {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    width: 100%;
    padding: 14px 18px;
    border-radius: 999px;
    background: var(--hi-gold, #b89855);
    color: var(--hi-navy, #073050);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 10px;
    touch-action: manipulation;
}

.pwa-install-gate__hint {
    margin: 12px 0 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.4;
}
