/**
 * App shell top header — aligned with retail-pos app-topbar
 * + hotel-specific branch / housekeeping / sidebar logo polish
 */

:root {
    --app-topbar-height: 64px;
    --sidebar-header-height: 88px;
    --app-text-primary: #0f172a;
    --app-text-body: #334155;
    --app-text-muted: #64748b;
    --app-border: #e2e8f0;
    --app-surface: #f8fafc;
    --app-primary: #008a5e;
    --app-primary-hover: #007a54;
    --app-primary-dark: #006b49;
    --app-primary-light: #e8f7f1;
    --app-primary-border: #b8e6d4;
    --app-primary-focus: rgba(0, 138, 94, 0.12);
    --app-radius-md: 10px;
    --app-radius-lg: 12px;
    --app-white: #fff;
}

/* Bootstrap primary → brand green (app shell) */
.wrapper .btn-primary,
.topbar .btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-hover);
    --bs-btn-hover-border-color: var(--app-primary-hover);
    --bs-btn-active-bg: var(--app-primary-dark);
    --bs-btn-active-border-color: var(--app-primary-dark);
    --bs-btn-disabled-bg: var(--app-primary);
    --bs-btn-disabled-border-color: var(--app-primary);
    background-color: var(--app-primary);
    border-color: var(--app-primary);
    color: var(--app-white);
}

.wrapper .btn-primary:hover,
.topbar .btn-primary:hover {
    background-color: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
    color: var(--app-white);
}

/* Topbar shell — z-index above page overlays */
.app-shell-header .topbar.app-topbar {
    height: var(--app-topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    box-shadow: none;
    z-index: 1030;
}

.app-shell-header .topbar .navbar.app-topbar__nav {
    width: 100%;
    height: var(--app-topbar-height);
    padding: 0 1rem 0 1.25rem;
}

.wrapper .page-wrapper {
    margin-top: var(--app-topbar-height);
}

/* Collapsed sidebar hover-expand */
@media screen and (min-width: 1025px) {
    .wrapper.toggled .topbar,
    .wrapper.toggled .page-wrapper,
    .wrapper.toggled .page-footer {
        transition: left 0.2s ease-out, margin-left 0.2s ease-out;
    }

    .wrapper.toggled.sidebar-hovered .topbar {
        left: 250px;
    }

    .wrapper.toggled.sidebar-hovered .page-wrapper {
        margin-left: 250px;
    }

    .wrapper.toggled.sidebar-hovered .page-footer {
        left: 250px;
    }
}

.app-topbar__start {
    gap: 0.65rem;
    min-width: 0;
}

.app-topbar__menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: var(--app-radius-md);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text-body);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.app-topbar__menu-toggle:hover {
    background: var(--app-primary-light);
    border-color: var(--app-primary-border);
    color: var(--app-primary);
}

.app-topbar__brand {
    min-width: 0;
    max-width: min(320px, 28vw);
}

.app-topbar__company-name {
    display: block;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-text-primary);
    letter-spacing: -0.01em;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quick actions */
.app-topbar__center {
    min-width: 0;
}

.app-topbar__action-list {
    gap: 0.5rem !important;
}

.app-shell-header .header-action-btn {
    padding: 0.5rem 1rem;
    min-height: 40px;
    border-radius: var(--app-radius-md);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    box-shadow: none;
    transform: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.app-shell-header .header-action-btn:hover,
.app-shell-header .header-action-btn:focus {
    transform: none;
    box-shadow: none;
}

.app-shell-header .header-action-btn i {
    font-size: 1.1rem;
}

.app-shell-header .header-btn-purchase {
    background: var(--app-surface);
    color: var(--app-text-body);
    border-color: var(--app-border);
}

.app-shell-header .header-btn-purchase:hover,
.app-shell-header .header-btn-purchase:focus {
    background: var(--app-primary-light);
    border-color: var(--app-primary-border);
    color: var(--app-primary);
}

.app-shell-header .header-btn-sale {
    background: var(--app-primary);
    color: #fff;
    border-color: var(--app-primary);
}

.app-shell-header .header-btn-sale:hover,
.app-shell-header .header-btn-sale:focus {
    background: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
    color: #fff;
}

.app-shell-header .header-btn-pos {
    background: var(--app-primary-dark);
    color: #fff;
    border-color: var(--app-primary-dark);
}

.app-shell-header .header-btn-pos:hover,
.app-shell-header .header-btn-pos:focus {
    background: #005a3d;
    border-color: #005a3d;
    color: #fff;
}

/* Hotel branch selector in action row */
.app-shell-header .header-branch-wrap {
    min-width: 140px;
    max-width: 200px;
}

.app-shell-header .header-branch-wrap .select2-container .select2-selection--single {
    height: 40px !important;
    border-radius: var(--app-radius-md) !important;
    border-color: var(--app-border) !important;
    background: var(--app-white) !important;
}

.app-shell-header .header-branch-wrap .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px !important;
    color: var(--app-text-primary) !important;
    font-size: 0.875rem;
    font-weight: 500;
}

.app-shell-header .header-branch-wrap .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
}

/* Override legacy theme blue on utility nav links */
.app-shell-header .topbar .navbar .navbar-nav .nav-link:hover,
.app-shell-header .topbar .navbar .navbar-nav .nav-link:focus {
    background-color: var(--app-primary-light);
    color: var(--app-primary);
}

.app-shell-header .dropdown-app.show > .nav-link,
.app-shell-header .dropdown-app > .nav-link[aria-expanded="true"] {
    background: var(--app-primary) !important;
    border-color: var(--app-primary) !important;
    color: #fff !important;
}

.app-shell-header .app-topbar__utility-list > .nav-item,
.app-shell-header .app-topbar__action-list > .nav-item {
    height: auto;
    width: auto;
}

.app-shell-header .topbar .navbar .navbar-nav .nav-item {
    height: auto;
    width: auto;
}

/* Utility icons */
.app-topbar__utilities {
    flex-shrink: 0;
}

.app-topbar__utility-list {
    gap: 0.35rem !important;
}

.app-shell-header .app-topbar__utility-list > .nav-item {
    height: auto;
}

.app-shell-header .app-topbar__utility-list .nav-link {
    width: 42px;
    height: 42px;
    border-radius: var(--app-radius-md);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: #475569;
    font-size: 1.15rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.app-shell-header .app-topbar__utility-list .nav-link:hover,
.app-shell-header .app-topbar__utility-list .nav-link:focus {
    background: var(--app-primary-light);
    border-color: var(--app-primary-border);
    color: var(--app-primary);
}

.app-shell-header .app-topbar__utility-list .invoice-counts-icon {
    color: var(--app-primary);
    font-size: 1.15rem;
}

.app-shell-header .app-topbar__utility-list .flag-icon {
    width: 1.25em;
    height: 1em;
    border-radius: 2px;
}

.app-shell-header .header-notification-item .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
}

.app-shell-header .header-notification-menu {
    width: 360px;
    max-width: 90vw;
}

.app-shell-header .header-notification-menu__body {
    max-height: 360px;
    overflow-y: auto;
}

/* Shortcut app grid */
.app-shell-header .topbar .navbar .dropdown-app .dropdown-menu {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 0.65rem;
}

.app-shell-header .topbar .navbar .dropdown-app .dropdown-menu .app-box {
    border-radius: var(--app-radius-md);
    border: 1px solid transparent;
    padding: 0.5rem 0.65rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.app-shell-header .topbar .navbar .dropdown-app .dropdown-menu .app-box:hover {
    background: var(--app-primary-light);
    border-color: var(--app-primary-border);
}

.app-shell-header .topbar .navbar .dropdown-app .dropdown-menu .app-icon i {
    color: var(--app-primary);
}

.app-shell-header .topbar .navbar .dropdown-app .dropdown-menu .app-name p {
    color: var(--app-text-body);
    font-size: 0.875rem;
    font-weight: 500;
}

.app-shell-header .topbar .navbar .dropdown-app .dropdown-menu .header-shortcut-hint {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--app-border);
    background: var(--app-surface, #fff);
    color: var(--app-text-muted, #64748b);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.35;
}

/* User menu */
.app-shell-header .user-box.app-topbar__user {
    height: var(--app-topbar-height);
    border-left: 1px solid var(--app-border);
    border-right: 0;
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    margin-left: 0.25rem;
}

.app-shell-header .app-topbar__user > .nav-link {
    border-radius: var(--app-radius-lg);
    padding: 0.35rem 0.5rem;
    gap: 0.65rem !important;
    width: auto;
    height: auto;
    transition: background 0.2s ease;
}

.app-shell-header .app-topbar__user > .nav-link:hover,
.app-shell-header .app-topbar__user > .nav-link:focus {
    background: var(--app-surface);
}

.app-shell-header .app-topbar__user .user-img {
    width: 38px;
    height: 38px;
    border: 2px solid var(--app-primary-border);
    object-fit: cover;
}

.app-shell-header .app-topbar__user .user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--app-text-primary);
}

.app-shell-header .app-topbar__user .designattion {
    font-size: 12px;
    color: var(--app-text-muted);
}

.app-shell-header .app-topbar__user .dropdown-menu {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 0.35rem;
}

.app-shell-header .app-topbar__user .dropdown-item {
    border-radius: 8px;
    font-size: 14px;
    color: var(--app-text-body);
    padding: 0.55rem 0.75rem;
}

.app-shell-header .app-topbar__user .dropdown-item:hover {
    background: var(--app-primary-light);
    color: var(--app-primary);
}

.app-shell-header .app-topbar__user .dropdown-item i {
    color: var(--app-text-muted);
}

/* Invoice breakdown popover */
.invoice-breakdown {
    min-width: 250px;
    font-size: 0.875rem;
    color: var(--app-text-body);
}

.invoice-breakdown strong {
    color: var(--app-primary);
    font-weight: 600;
}

/* Keyboard shortcuts help modal */
.app-kbd-shortcuts-modal .modal-body {
    padding-top: 0.75rem;
}

.app-kbd-shortcuts-tabs {
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.35rem;
    overflow-x: auto;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.app-kbd-shortcuts-tabs .nav-link {
    white-space: nowrap;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid transparent;
}

.app-kbd-shortcuts-tabs .nav-link:hover {
    color: var(--app-primary);
    background: rgba(0, 138, 94, 0.08);
}

.app-kbd-shortcuts-tabs .nav-link.active {
    color: #fff;
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.app-kbd-shortcuts-tab-content {
    min-height: 180px;
}

.app-kbd-shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-kbd-shortcuts-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
    background: rgba(0, 0, 0, 0.03);
    transition: background-color 0.15s ease;
}

.app-kbd-shortcuts-row:hover {
    background: rgba(0, 138, 94, 0.08);
    color: inherit;
}

.app-kbd-shortcuts-row--static {
    cursor: default;
    background: transparent;
    border: 1px dashed rgba(0, 0, 0, 0.12);
}

.app-kbd-shortcuts-row--static:hover {
    background: transparent;
}

.app-kbd-shortcuts-row__label {
    font-size: 0.925rem;
    font-weight: 500;
}

.app-kbd-shortcuts-row__keys {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: transparent;
    border: 0;
    padding: 0;
}

.app-kbd-shortcuts-row__keys > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.35rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    color: #333;
}

/* Mobile */
@media screen and (max-width: 1024px) {
    .app-topbar__menu-toggle {
        display: inline-flex;
    }
}

@media (max-width: 991.98px) {
    .app-shell-header .header-action-btn {
        padding: 0.45rem 0.85rem;
        font-size: 12px;
    }

    .app-topbar__brand {
        max-width: 200px;
    }
}

@media (max-width: 767.98px) {
    .app-shell-header .header-action-btn .btn-text {
        display: none;
    }

    .app-shell-header .header-action-btn {
        padding: 0;
        min-width: 42px;
        min-height: 42px;
        justify-content: center;
        gap: 0 !important;
    }

    .app-shell-header .header-action-btn i {
        margin: 0 !important;
        font-size: 1.2rem !important;
    }

    .app-shell-header .header-branch-item {
        display: none !important;
    }

    .app-topbar__action-list {
        gap: 0.35rem !important;
    }

    .app-topbar__utility-list {
        gap: 0.25rem !important;
    }

    .app-shell-header .topbar .navbar.app-topbar__nav {
        padding: 0 0.65rem;
        gap: 0.5rem !important;
    }

    .app-shell-header .user-box.app-topbar__user {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .app-shell-header .app-topbar__user .user-info {
        display: none;
    }
}

/* Current subscription chip — slate + sky accent */
.app-topbar__subscription {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 16rem;
    min-height: 42px;
    padding: 0.35rem 0.7rem;
    border-radius: var(--app-radius-md);
    border: 1px solid #334155;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #0c4a6e 100%);
    color: #e2e8f0;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.28);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.app-topbar__subscription:hover,
.app-topbar__subscription:focus {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #0369a1 100%);
    border-color: #38bdf8;
    color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
}

.app-topbar__subscription-plan {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 9rem;
}

.app-topbar__subscription-status {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(125, 211, 252, 0.45);
    color: #e0f2fe;
    white-space: nowrap;
}

.app-topbar__subscription-status--trialing {
    color: #bae6fd;
    border-color: #38bdf8;
    background: rgba(14, 165, 233, 0.2);
}

.app-topbar__subscription-status--active {
    color: #bbf7d0;
    border-color: #4ade80;
    background: rgba(34, 197, 94, 0.18);
}

.app-topbar__subscription-status--past_due {
    color: #fed7aa;
    border-color: #fb923c;
    background: rgba(249, 115, 22, 0.2);
}

.app-topbar__subscription-status--expired,
.app-topbar__subscription-status--cancelled {
    color: #fecaca;
    border-color: #f87171;
    background: rgba(239, 68, 68, 0.2);
}

.app-topbar__subscription--empty {
    gap: 0.35rem;
}

.app-topbar__subscription--empty i {
    font-size: 1rem;
    color: #7dd3fc;
}

@media (max-width: 991.98px) {
    .app-topbar__subscription-plan {
        max-width: 6.5rem;
    }
}

@media (max-width: 575.98px) {
    .app-shell-header .app-topbar__utility-list .nav-link {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }
}

/* ---------- Sidebar logos (expanded + collapsed) ---------- */
.wrapper .sidebar-wrapper .sidebar-header {
    height: var(--sidebar-header-height);
    border-bottom: 1px solid var(--app-border);
    background: var(--app-white);
    overflow: hidden;
    padding: 0 10px 0 12px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.wrapper .sidebar-wrapper .sidebar-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.wrapper .sidebar-wrapper .sidebar-header .logo-icon {
    width: auto !important;
    height: auto !important;
    max-width: none;
    max-height: none;
    flex-shrink: 0;
}

.wrapper .sidebar-wrapper .sidebar-header .main-logo {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: min(200px, 100%) !important;
    max-height: calc(var(--sidebar-header-height) - 10px) !important;
    object-fit: contain !important;
    object-position: left center;
}

.wrapper .sidebar-wrapper .sidebar-header .short-logo {
    display: none !important;
}

.wrapper .sidebar-wrapper .sidebar-header .toggle-icon {
    color: #475569;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wrapper .sidebar-wrapper .sidebar-header .toggle-icon:hover {
    background: var(--app-primary-light);
    color: var(--app-primary);
    border-color: var(--app-primary-border);
}

.wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header {
    width: 70px !important;
    justify-content: center;
    padding: 0;
    gap: 0;
}

.wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header > div:first-child {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
}

.wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header .main-logo {
    display: none !important;
}

.wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header .short-logo {
    display: block !important;
    width: 52px !important;
    height: 52px !important;
    max-width: 52px !important;
    max-height: 52px !important;
    object-fit: cover !important;
    object-position: center;
    border-radius: 12px;
    transform: scale(1.28);
    transform-origin: center center;
}

.wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header .toggle-icon {
    display: none !important;
}

.wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header {
    padding: 0 10px 0 12px;
}

.wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header > div:first-child {
    flex: 1 1 auto;
    width: auto;
    height: 100%;
    overflow: hidden;
    border-radius: 0;
}

.wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header .main-logo {
    display: block !important;
    max-width: min(200px, 100%) !important;
    max-height: calc(var(--sidebar-header-height) - 10px) !important;
    transform: none;
}

.wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header .short-logo {
    display: none !important;
    transform: none;
}

.wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header .toggle-icon {
    display: inline-flex !important;
}

.wrapper .sidebar-wrapper .metismenu {
    margin-top: var(--sidebar-header-height) !important;
}

.wrapper .sidebar-wrapper .simplebar-content {
    padding-top: 0;
}

/* Dark theme compatibility */
html.dark-theme {
    --app-text-primary: #f1f5f9;
    --app-text-body: #cbd5e1;
    --app-text-muted: #94a3b8;
    --app-border: #334155;
    --app-surface: #1e293b;
    --app-white: #0f172a;
    --app-primary-light: rgba(0, 138, 94, 0.18);
    --app-primary-border: rgba(0, 138, 94, 0.35);
}

html.dark-theme .app-shell-header .topbar.app-topbar {
    background: #0f172a;
    border-bottom-color: #334155;
}

html.dark-theme .wrapper .sidebar-wrapper .sidebar-header {
    background: #0f172a;
    border-bottom-color: #334155;
}

html.dark-theme .app-kbd-shortcuts-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

html.dark-theme .app-kbd-shortcuts-tabs .nav-link {
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
}

html.dark-theme .app-kbd-shortcuts-tabs .nav-link.active {
    background: var(--app-primary);
    color: #fff;
}

html.dark-theme .app-kbd-shortcuts-row {
    background: rgba(255, 255, 255, 0.04);
}

html.dark-theme .app-kbd-shortcuts-row:hover {
    background: rgba(0, 138, 94, 0.18);
}

html.dark-theme .app-kbd-shortcuts-row--static {
    border-color: rgba(255, 255, 255, 0.18);
}

html.dark-theme .app-kbd-shortcuts-row__keys > span {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #f3f3f3;
}
