/* =========================================
   🌲 SVEDBERGA GLOBAL UI PATCH (CLEAN)
   Native Select Compatible
========================================= */

/* -------------------------------
   1️⃣ Native Select Styling
-------------------------------- */
.form-select {
    padding-right: 2.75rem !important;
    background-position: right 0.85rem center !important;
}

.form-select-sm {
    padding-right: 2.5rem !important;
}

/* Focus styling (what we CAN control) */
.form-select:focus,
.form-control:focus {
    border-color: var(--primary-400) !important;
    box-shadow: 0 0 0 0.15rem var(--primary-light) !important;
}

/* -------------------------------
   2️⃣ Checkbox Theming
-------------------------------- */
.form-check-input {
    border: 1px solid var(--input-stroke) !important;
}

.form-check-input:checked {
    background-color: var(--primary-600) !important;
    border-color: var(--primary-600) !important;
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.15rem var(--primary-light) !important;
}

/* -------------------------------
   3️⃣ Tabs
-------------------------------- */
.nav-tabs .nav-link {
    color: var(--text-secondary-light);
}

.nav-tabs .nav-link:hover {
    color: var(--primary-600) !important;
}

.nav-tabs .nav-link.active {
    color: var(--primary-600) !important;
    border-color: var(--primary-600) var(--primary-600) transparent !important;
}

/* -------------------------------
   4️⃣ Buttons
-------------------------------- */
.btn-primary-600 {
    background-color: var(--primary-600) !important;
    border-color: var(--primary-600) !important;
}

.btn-primary-600:hover {
    background-color: var(--primary-700) !important;
    border-color: var(--primary-700) !important;
}

/* -------------------------------
   5️⃣ Pagination Active
-------------------------------- */
.page-link.bg-primary-600 {
    background-color: var(--primary-600) !important;
    border-color: var(--primary-600) !important;
}

.page-link.bg-primary-600:hover {
    background-color: var(--primary-700) !important;
}

/* -------------------------------
   6️⃣ Bootstrap Dropdown (NOT native select)
-------------------------------- */
.dropdown-menu {
    --bs-dropdown-link-hover-bg: var(--primary-50);
    --bs-dropdown-link-hover-color: var(--primary-700);
    --bs-dropdown-link-active-bg: var(--primary-600);
    --bs-dropdown-link-active-color: #ffffff;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--primary-50) !important;
    color: var(--primary-700) !important;
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--primary-600) !important;
    color: #ffffff !important;
}

/* -------------------------------
   7️⃣ Remove Default Blue Focus Outline
-------------------------------- */
*:focus-visible {
    outline: none;
}

/* -------------------------------
   8️⃣ Ensure Bootstrap Primary Uses Brand
-------------------------------- */
:root {
    --bs-primary: var(--primary-600);
    --bs-primary-rgb: 23,58,41;
}

/* -------------------------------
   9️⃣ Hide VERTICAL scrollbar only (embedded iframe)
   Hides the vertical scrollbar on the page but keeps it
   scrollable, and leaves horizontal scrollbars intact.
-------------------------------- */
html {
    scrollbar-width: none;             /* Firefox — hides scrollbars */
    -ms-overflow-style: none;          /* IE / old Edge */
}

html::-webkit-scrollbar:vertical {
    display: none;                     /* Chrome / Safari / Edge / WebViews */
    width: 0;
}
/* =========================================
   STORE LABEL (standalone two-store build)
   -----------------------------------------
   New in the standalone app. The original only ever served one store at a
   time and had nothing to label. Every merged list shows which store a row
   came from, and the text always comes from shops.shop_name in that row's own
   database.
========================================= */

.store-label {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    background-color: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    color: var(--neutral-600);
}

.store-label--remco {
    background-color: var(--primary-50);
    border-color: var(--primary-100);
    color: var(--primary-600);
}

.store-label--thujor {
    background-color: var(--success-focus);
    border-color: var(--success-100);
    color: var(--success-main);
}

.store-cell {
    white-space: nowrap;
}

/* =========================================================================
   APP SHELL: collapsible sidebar + slim top bar (standalone build)
   -------------------------------------------------------------------------
   Replaces the old top navbar. Self-contained and prefixed (.app-*) so it
   never collides with the theme's own .sidebar classes. Colours use the
   theme tokens so the shell matches the rest of the app.
   ========================================================================= */

:root {
    --app-sidebar-width: 264px;
    --app-sidebar-collapsed: 76px;
    --app-topbar-height: 64px;
}

/* ---- Sidebar -------------------------------------------------------- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--app-sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--base, #fff);
    border-right: 1px solid var(--neutral-200);
    z-index: 1040;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--app-topbar-height);
    padding: 0 20px;
    border-bottom: 1px solid var(--neutral-200);
    flex-shrink: 0;
}

.app-sidebar__logo-full { height: 34px; display: block; }
.app-sidebar__logo-icon { height: 30px; display: none; }

.app-sidebar__close {
    display: none;
    background: none;
    border: 0;
    font-size: 20px;
    color: var(--text-secondary-light);
    cursor: pointer;
}

.app-sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 20px;

    /* Scroll works, scrollbar hidden. Applied to this container only, not the
       page. Cross-browser: Firefox, old Edge/IE, and WebKit below. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.app-sidebar__nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.app-sidebar__group-title {
    padding: 16px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--neutral-500);
    white-space: nowrap;
}

.app-sidebar__list {
    list-style: none;
    margin: 0 0 4px;
    padding: 0;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: var(--text-secondary-light);
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-nav-link__icon {
    font-size: 20px;
    flex-shrink: 0;
}

.app-nav-link:hover {
    background: var(--primary-50);
    color: var(--primary-600);
}

.app-nav-link.is-active {
    background: var(--primary-600);
    color: #fff;
}

/* Collapse toggle now lives in the top bar (icon only), not the sidebar. */
.app-topbar__collapse {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
}

.app-topbar__collapse:hover {
    background: var(--neutral-200);
    color: var(--primary-600);
}

.app-topbar__collapse-icon {
    transition: transform 0.2s ease;
}

.app-sidebar__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1035;
}

/* ---- Content shell -------------------------------------------------- */
.app-shell {
    margin-left: var(--app-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s ease;
}

.app-content {
    flex: 1 1 auto;
    padding: 24px;
}

/* Footer sits outside .app-shell (see layoutBottom.php for why) and is aligned
   to the content with the same left offset, tracking the sidebar state exactly
   like .app-shell does. */
.d-footer {
    margin-left: var(--app-sidebar-width);
    transition: margin-left 0.2s ease;
}

body.sidebar-collapsed .d-footer {
    margin-left: var(--app-sidebar-collapsed);
}

/* ---- Top bar -------------------------------------------------------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--app-topbar-height);
    padding: 0 24px;
    background: var(--base, #fff);
    border-bottom: 1px solid var(--neutral-200);
}

.app-topbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.app-topbar__stores {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.app-topbar__hamburger {
    display: none;
    background: none;
    border: 0;
    font-size: 24px;
    color: var(--text-primary-light);
    cursor: pointer;
}

.app-topbar__icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--neutral-200);
    color: var(--text-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.app-topbar__profile {
    position: relative;
}

.app-topbar__avatar {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--primary-600);
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.app-topbar__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--base, #fff);
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 8px 0;
    display: none;
    z-index: 1050;
}

.app-topbar__dropdown.is-open {
    display: block;
}

.app-topbar__dropdown-head {
    padding: 8px 16px;
    border-bottom: 1px solid var(--neutral-200);
    margin-bottom: 4px;
}

.app-topbar__dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary-light);
    text-decoration: none;
}

.app-topbar__dropdown-item:hover {
    background: var(--primary-50);
    color: var(--primary-600);
}

.app-topbar__dropdown-item--danger {
    color: #dc3545;
}

.app-topbar__dropdown-item--danger:hover {
    background: rgba(220, 53, 69, 0.08);
    color: #dc3545;
}

/* ---- Collapsed (desktop, icons only) -------------------------------- */
body.sidebar-collapsed .app-sidebar {
    width: var(--app-sidebar-collapsed);
}

body.sidebar-collapsed .app-shell {
    margin-left: var(--app-sidebar-collapsed);
}

body.sidebar-collapsed .app-nav-link__label,
body.sidebar-collapsed .app-sidebar__group-title,
body.sidebar-collapsed .app-sidebar__logo-full {
    display: none;
}

body.sidebar-collapsed .app-sidebar__logo-icon {
    display: block;
}

body.sidebar-collapsed .app-sidebar__brand {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .app-nav-link {
    justify-content: center;
    padding: 10px;
}

/* The top-bar collapse icon flips to hint at the current state. */
body.sidebar-collapsed .app-topbar__collapse-icon {
    transform: scaleX(-1);
}

/* Keep a visual gap between groups when the titles are hidden. */
body.sidebar-collapsed .app-sidebar__group-title {
    display: block;
    height: 1px;
    padding: 0;
    margin: 12px 10px;
    background: var(--neutral-200);
    text-indent: -9999px;
    overflow: hidden;
}

/* ---- Responsive: off-canvas below 992px ----------------------------- */
@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--app-sidebar-width);
    }

    .app-shell {
        margin-left: 0;
    }

    /* Off-canvas: content and footer are full width. */
    .d-footer {
        margin-left: 0;
    }

    .app-sidebar__close {
        display: block;
    }

    /* Collapse is a desktop concept. On mobile the hamburger opens the
       off-canvas panel instead. */
    .app-topbar__collapse {
        display: none;
    }

    .app-topbar__hamburger {
        display: block;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .app-sidebar__backdrop {
        display: block;
    }

    body.sidebar-collapsed .app-nav-link__label,
    body.sidebar-collapsed .app-sidebar__group-title,
    body.sidebar-collapsed .app-sidebar__logo-full {
        display: revert;
    }

    body.sidebar-collapsed .app-sidebar__logo-icon {
        display: none;
    }

    body.sidebar-collapsed .app-nav-link {
        justify-content: flex-start;
        padding: 10px 12px;
    }
}
