/* ===========================================================================
   RESPONSIVE LAYER — how the whole system behaves on phones and tablets.

   One file, loaded after the page's own stylesheets. Every screen is built for
   a desktop first; this is where it is made to work on a 360px phone that will
   really be used in a supplier's shop or at a BAC opening.

   WHAT THIS REPLACES. A blunt mobile block in main.css that set
       input, select, button { width: 100% !important }
       table { display: block !important }
   on EVERY page. It is why the password eye-icon sat on top of the placeholder
   text, why every button in a toolbar became full width, and why the giant gold
   "Menu" bar existed at all. Nothing here forces a width on a form control.

   TWO NAVIGATION PATTERNS, both driven by /js/shared/nav.js:
     public site    a compact header with a hamburger that opens a panel
     dashboards     a top app bar with a hamburger that opens a slide-in drawer

   BREAKPOINTS   900px  navigation collapses      768px  grids become one column
                 560px  phones                     380px  the smallest phones
   =========================================================================== */

:root { --appbar-h: 60px; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video, canvas { max-width: 100%; }

/* No grey/blue flash over a control when it is tapped; the focus ring is the feedback. */
a, button, [role="button"], summary { -webkit-tap-highlight-color: transparent; }

/* Header text never breaks in the middle of a link or a button, in any language. */
.nav-links a, .auth-btns a, .nav-a11y { white-space: nowrap; }

/* Controls that only exist on small screens are off by default. */
.nav-toggle, .topbar-burger, .nav-scrim { display: none; }

/* ---------------------------------------------------------------------------
   1. PUBLIC NAVBAR
   On a desktop .nav-panel is invisible to layout (display: contents), so the
   links and the sign-in buttons are laid out exactly as they always were.
   --------------------------------------------------------------------------- */
.nav-panel { display: contents; }
.nav-tools { display: flex; align-items: center; gap: 10px; margin-left: 20px; }

.nav-a11y {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 14px;
    background: transparent;
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, .35);
    border-radius: 10px;
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: pointer;
    transition: background-color .15s, color .15s;
}
.nav-a11y:hover { background: var(--accent-gold, #e5a823); color: var(--primary-navy, #0a192f); }
.nav-a11y:focus-visible, .nav-toggle:focus-visible, .topbar-burger:focus-visible {
    outline: 3px solid var(--accent-gold, #e5a823);
    outline-offset: 2px;
}
.nav-a11y svg { flex: none; }

.nav-toggle, .topbar-burger {
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 10px;
    cursor: pointer;
    flex: none;
}
.nav-toggle {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .35);
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s ease, background-color .2s ease;
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ''; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after  { top: 6px; }
.navbar.is-open .nav-toggle-bars { background: transparent; }
.navbar.is-open .nav-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
.navbar.is-open .nav-toggle-bars::after  { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 900px) {
    .navbar {
        padding: 10px 16px;
        gap: 10px;
        flex-wrap: nowrap;
        text-align: left;
        flex-direction: row;
    }
    .navbar-brand { margin: 0; justify-content: flex-start; min-width: 0; gap: 10px; font-size: 1rem; }
    .navbar-brand img { width: 40px !important; height: 40px !important; }
    .navbar-brand .brand-badge { font-size: .66rem; letter-spacing: .05em; }
    .nav-tools { margin-left: auto; gap: 8px; }
    .nav-toggle { display: inline-flex; }

    /* the panel drops from under the header, full width, big touch rows */
    .nav-panel {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-navy, #0a192f);
        padding: 6px 16px 20px;
        max-height: calc(100vh - 70px);
        max-height: calc(100dvh - 70px);
        overflow-y: auto;
        box-shadow: 0 22px 34px rgba(6, 14, 26, .4);
    }
    .navbar.is-open .nav-panel { display: block; }

    .nav-panel .nav-links { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin: 0; padding: 0; }
    .nav-panel .nav-links a {
        display: flex;
        align-items: center;
        min-height: 54px;
        padding: 0 6px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .1);
        font-size: 1.02rem;
        box-shadow: none;
    }
    .nav-panel .nav-links a.active {
        background: none;
        box-shadow: none;
        color: var(--accent-gold, #e5a823);
        border-left: 3px solid var(--accent-gold, #e5a823);
        padding-left: 12px;
    }
    .nav-panel .auth-btns { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin: 16px 0 0; width: auto; }
    .nav-panel .auth-btns a { display: flex; align-items: center; justify-content: center; min-height: 52px; font-size: 1rem; }
}

/* While a dashboard drawer is open the floating launcher would sit on top of its Log Out button. */
body.drawer-open .a11y-widget { visibility: hidden; }

@media (max-width: 480px) {
    .nav-a11y { width: 44px; height: 44px; padding: 0; justify-content: center; }
    .nav-a11y-label { display: none; }
}

/* ---------------------------------------------------------------------------
   2. DASHBOARDS — top app bar + slide-in drawer (admin, supplier)
   nav.js adds body.has-drawer, the burger button and the scrim.
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
    body.has-drawer {
        display: block;          /* undo the desktop "sidebar beside content" lock */
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }
    body.has-drawer.drawer-open { overflow: hidden; }

    body.has-drawer .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(86vw, 320px);
        max-width: 320px;
        flex: none;
        height: 100%;
        transform: translateX(-104%);
        transition: transform .25s ease;
        z-index: 1300;
        box-shadow: none;
        overflow: hidden;
        visibility: hidden;                  /* keeps closed-drawer links out of the tab order */
    }
    body.has-drawer.drawer-open .sidebar {
        transform: none;
        visibility: visible;
        box-shadow: 12px 0 40px rgba(0, 0, 0, .45);
    }
    body.has-drawer .sidebar-menu { display: block; }
    body.has-drawer .sidebar-menu li a { min-height: 52px; padding: 0 22px; }
    body.has-drawer .sidebar-footer { padding: 16px 18px 20px; }
    body.has-drawer .btn-logout, body.has-drawer .sidebar-security-link { min-height: 46px; display: flex; align-items: center; justify-content: center; }

    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(6, 14, 26, .6);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
        z-index: 1250;
    }
    body.drawer-open .nav-scrim { opacity: 1; pointer-events: auto; }

    body.has-drawer .dashboard-content {
        display: block;
        width: 100%;
        min-width: 0;
        overflow: visible;
    }

    /* the app bar: burger, then the page title, then bell + who */
    body.has-drawer .topbar {
        position: sticky;
        top: 0;
        z-index: 900;
        min-height: var(--appbar-h);
        padding: 8px 12px;
        gap: 10px;
        justify-content: flex-start;
    }
    .topbar-burger {
        display: inline-flex;
        background: var(--primary-navy, #0a192f);
        color: #fff;
        border: 0;
    }
    body.has-drawer .topbar-title { flex: 1 1 auto; min-width: 0; }
    body.has-drawer .topbar-title h2 {
        margin: 0;
        font-size: 1.08rem;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body.has-drawer .topbar-user { flex: none; gap: 6px; }
    body.has-drawer .topbar-who { border-left: 0; padding-left: 0; max-width: 132px; }
    body.has-drawer .topbar-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
    body.has-drawer .topbar-who span { display: none; }

    /* a page with no top bar of its own gets one from nav.js */
    .mobile-appbar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 900;
        min-height: var(--appbar-h);
        padding: 8px 12px;
        background: var(--surface-white, #fff);
        box-shadow: 0 2px 4px rgba(0, 0, 0, .06);
    }
    .mobile-appbar strong { color: var(--primary-navy, #0a192f); font-size: 1.02rem; }
}

@media (max-width: 560px) {
    body.has-drawer .topbar-who { display: none; }
}

/* ---------------------------------------------------------------------------
   3. CONTENT — grids, cards, tables, forms, dialogs
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .dash-container { padding: 16px 14px 96px; }      /* the room at the bottom is for the accessibility button */
    .dash-grid-2, .dash-grid-3, .dash-grid-4 { grid-template-columns: 1fr; gap: 14px; }
    .dash-card { padding: 16px; max-width: 100%; }
    .toolbar { flex-wrap: wrap; gap: 10px; }
    .toolbar .grow, .toolbar input[type="search"] { flex: 1 1 100%; min-width: 0; }

    /* Tables scroll INSIDE their card instead of widening the page. The old rule
       turned every table into display:block, which broke column alignment. */
    .dash-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.dash-table th, table.dash-table td { white-space: normal; padding: 10px 8px; }
    table.dash-table .empty, table.dash-table td[colspan] { min-width: 0; }

    /* Forms: comfortable to type into, and no iOS zoom-on-focus (needs >= 16px). Never under 16px, but larger with the
       Larger and Largest text settings, which enlarge 1rem (a flat 16px kept typed text from growing: 2026-11-29). */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select, textarea { font-size: max(16px, 1rem); min-height: 44px; max-width: 100%; }
    .btn, button.btn, .btn-gold, .btn-outline-gold, .btn-primary, .btn-accent, .btn-quiet { min-height: 44px; }
    .form-grid { grid-template-columns: 1fr; }

    /* Public pages */
    .bp-hero h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); line-height: 1.15; }
    .bottom-section { grid-template-columns: 1fr; }
    .action-grid { grid-template-columns: 1fr; }

    /* Dialogs and panels never exceed the screen */
    .ui-dialog { max-width: calc(100vw - 20px); }
    .yt-notif-panel { max-width: calc(100vw - 16px); }
}

/* the approvals queue: tabs scroll sideways rather than wrapping into a wall */

@media (max-width: 768px) {
    .site-footer { padding-bottom: 64px; }
}

@media (max-width: 380px) {
    .navbar-brand .brand-badge { display: none; }
    
}

/* a bar that is only a little wider than the phone menu (901-1060px): the Accessibility button shrinks to its icon and the links sit closer */
@media (min-width: 901px) and (max-width: 1060px) {
    .navbar { gap: 8px; padding-left: 16px; padding-right: 16px; }
    .nav-links { gap: 2px; margin-left: 6px; }
    .nav-links a { padding: 8px 8px; font-size: .84rem; }
    .auth-btns { gap: 8px; }
    .navbar .auth-btns a { padding: 8px 10px; font-size: .82rem; }
    .nav-a11y { width: 44px; height: 44px; padding: 0; justify-content: center; }
    .nav-a11y-label { display: none; }
}

@media (min-width: 901px) and (max-width: 1240px) {
    .navbar { gap: 14px; padding-left: 24px; padding-right: 24px; }
    .navbar-brand .brand-badge { white-space: nowrap; }
    .nav-links { gap: 8px; margin-left: 12px; }
    .nav-links a { padding: 8px 12px; font-size: .86rem; }
    .auth-btns { gap: 10px; }
    .navbar .auth-btns a { padding: 8px 12px; font-size: .84rem; }
    .nav-tools { margin-left: 4px; }
}
