/* ── COSHH app-specific styles ─────────────────────────────────────────── */

/* ── Header nav ── */
.app-nav {
    display: flex;
    align-items: stretch;
    height: var(--header-h);
}
.app-nav-link {
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    color: rgba(255,255,255,.75);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.app-nav-link:hover  { color: #fff; border-bottom-color: rgba(255,255,255,.4); text-decoration: none; }
.app-nav-link.active { color: #fff; border-bottom-color: #fff; }

/* ── Sortable table headers ── */
.sort-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
}
.sort-link:hover { color: var(--brand); text-decoration: none; }
.sort-indicator { font-size: .7rem; color: var(--text-muted); }
.sort-indicator.active { color: var(--brand); }

/* ── Dashboard search ── */
.search-form { display: flex; flex-direction: column; gap: .5rem; }
.search-row  { display: flex; gap: .5rem; }
.search-row .form-control { flex: 1; }
.filter-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.filter-row .form-control { flex: 1; min-width: 140px; }

@media (max-width: 640px) {
    .search-row {
        flex-wrap: wrap;
    }
    .search-row .form-control {
        flex: 1 1 100%;   /* input takes its own full-width line */
    }
    .search-row .btn,
    .search-row a.btn {
        flex: 1;           /* buttons share the second line equally */
    }
    .filter-row .form-control {
        flex: 1 1 calc(50% - .25rem);
        min-width: 0;      /* allow text to truncate rather than overflow */
    }
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: .2em .55em;
    border-radius: 4px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.2;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn); }
.badge-info    { background: var(--brand-light); color: var(--brand); }
.badge-muted   { background: #eee; color: var(--text-muted); }

/* ── GHS pictograms ── */
.ghs-pictograms {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.ghs-pic-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    cursor: default;
}
.ghs-pic-img {
    width: 64px;
    height: 64px;
}
.ghs-pic-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    max-width: 70px;
    line-height: 1.2;
}

/* ── Mobile card view (dashboard product list) ── */
@media (max-width: 640px) {
    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: .75rem;
        padding: .75rem;
        background: var(--card-bg);
    }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: .25rem 0;
        border: none;
        font-size: .875rem;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--text-muted);
        flex-shrink: 0;
        margin-right: .75rem;
    }
    .data-table tbody td:first-child {
        font-size: 1rem;
        font-weight: 600;
        padding-bottom: .5rem;
        border-bottom: 1px solid var(--border);
        margin-bottom: .25rem;
        display: block;
    }
    .data-table tbody td:first-child::before { display: none; }
}

/* ── Print styles ── */
@media print {
    .no-print,
    .app-header,
    .app-nav,
    .nav-overlay,
    .app-footer,
    .coshh-menu,
    .alert { display: none !important; }

    body { background: white; }
    .app-main { max-width: 100% !important; padding: 0 !important; }
    .form-section {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
        margin-bottom: .75rem;
    }
    .ghs-pic-img { width: 50px; height: 50px; }
    a { color: inherit; text-decoration: none; }
    .btn { display: none !important; }
}

/* ── Detail page ── */
.detail-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    display: block;
    margin-bottom: .2rem;
}
.text-muted { color: var(--text-muted); }

/* ── Desktop: wider layout (1400px across the whole app) ── */
body:not(:has(.admin-wrap)) .app-main { max-width: 1400px; }
.header-inner { max-width: 1400px; }

/* ── Admin layout override ── */
.admin-wrap    { max-width: 1400px; }
.admin-content { max-width: calc(1400px - 220px); }

/* ── Admin sidebar: mobile drawer ── */
@media (max-width: 640px) {
    .admin-sidebar {
        display: block; /* override style.css display:none */
        position: fixed;
        top: var(--header-h);
        left: -220px;
        height: calc(100vh - var(--header-h));
        z-index: 99;
        transition: left .25s ease;
        overflow-y: auto;
    }
    .admin-sidebar.open { left: 0; }
}

/* ── Form: file upload hint ── */
.upload-hint {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

/* ── Scan barcode button ── */
.btn-scan {
    background: var(--brand-light);
    color: var(--brand);
    border: 1px solid var(--brand);
    padding: .45rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    cursor: pointer;
    white-space: nowrap;
}
.btn-scan:hover { background: var(--brand); color: #fff; }

/* ── Risk assessment form ── */
.ra-field { margin-bottom: 1.25rem; }
.ra-field textarea { min-height: 80px; resize: vertical; }

/* ── Icons (includes/icons.php): inline SVG that inherits the text colour ── */
.ic { vertical-align: middle; flex-shrink: 0; }
.btn .ic, .btn-scan .ic { vertical-align: -.2em; margin-right: .3rem; }
.btn .ic:only-child, .btn-scan .ic:only-child { margin-right: 0; }

/* ── Header: ONE ≡ menu, never bare icons (David's cross-app rule, 2026-10-21) ──
   The old ⚙ (Admin) and ✕ (Sign out) glyphs and the phone hamburger drawer are
   gone. The nav links stay inline at every width - on a narrow phone they scroll
   sideways rather than hide - and the ≡ holds the actions: Admin, Sign out. */
.header-inner { gap: .5rem; }
.app-nav { min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.app-nav::-webkit-scrollbar { display: none; }
@media (max-width: 768px) {
    .app-nav-link { padding: 0 .7rem; font-size: .85rem; border-bottom-width: 2px; }
}
@media (max-width: 480px) {
    .logo-img { display: none; }            /* the word COSHH is enough on a phone */
    .app-nav-link { padding: 0 .55rem; font-size: .8rem; }
}

.coshh-menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: none; border: none; color: #fff; cursor: pointer;
    transition: background .15s; flex-shrink: 0;
}
.coshh-menu-btn:hover, .coshh-menu-btn[aria-expanded="true"] { background: rgba(255,255,255,.15); }
.coshh-menu {
    position: absolute; top: 100%; right: max(.75rem, calc((100% - 1400px) / 2 + .75rem));
    z-index: 300; width: 240px; padding: .4rem 0;
    background: var(--brand-dark);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
}
.coshh-menu[hidden] { display: none; }
.coshh-menu__user {
    padding: .5rem 1.1rem .35rem; font-size: .72rem; letter-spacing: .05em;
    text-transform: uppercase; color: rgba(255,255,255,.55);
}
@media (min-width: 480px) { .coshh-menu__user { display: none; } }   /* the name is in the bar from here up */
.coshh-menu__link {
    display: flex; align-items: center; gap: .65rem;
    padding: .75rem 1.1rem; color: rgba(255,255,255,.88);
    font-weight: 600; font-size: .95rem; text-decoration: none;
}
.coshh-menu__link:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
@media (max-width: 480px) {
    .coshh-menu { left: 0; right: 0; width: auto; border-radius: 0; }   /* full-width drop-down on a phone */
}

/* ── Admin header: a visible way back, and the sidebar's account rows ── */
.header-back {
    display: inline-flex; align-items: center; gap: .35rem;
    margin-left: .75rem; margin-right: auto;
    padding: .3rem .65rem; border-radius: var(--radius-sm);
    color: #fff; font-size: .85rem; font-weight: 600; text-decoration: none;
    background: rgba(255,255,255,.12); white-space: nowrap;
}
.header-back:hover { background: rgba(255,255,255,.22); text-decoration: none; color: #fff; }
.sidebar-nav li a { display: flex; align-items: center; gap: .6rem; }
.sidebar-account { display: none; }                 /* desktop: these rows live in the ≡ menu */
@media (max-width: 640px) { .sidebar-account { display: block; } }

/* ── Admin pages on a phone: the inline two/three-column grids (admin/index.php
   quick links, stock-checks/run.php location list + products, edit.php field
   pairs) ran off the right edge at 375px. One column below 640px; the attribute
   selector catches every inline grid-template-columns without touching the
   page markup. ── */
@media (max-width: 640px) {
    .admin-content [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

/* ── Admin sidebar drawer on a phone: overlay (the ≡ opens it) ── */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(0,0,0,.45);
    z-index: 98;
}
.nav-overlay.open { display: block; }

/* ── Embedded in the Mendip App (desktop shell tab / phone frame) ───────────
   Its strip already shows the app name and the person, and a sign-out here
   would drop the shared SSO for the Mendip App too. Slim, don't hide: the
   nav stays (the strip is ITS chrome, not our navigation). --header-h is
   what the drawer and overlay offsets read, so redefine it rather than
   fight each rule. */
body.embedded { --header-h: 44px; }
body.embedded .header-logo,
body.embedded .header-user,
body.embedded .coshh-menu__user,
body.embedded .coshh-menu__link--logout,
body.embedded .sidebar-logout             { display: none !important; }
body.embedded .coshh-menu-btn:not(.has-admin) { display: none; }   /* staff: the menu would be empty */
body.embedded .header-inner               { padding: 0 .5rem; }
body.embedded .app-nav-link               { font-size: .85rem; padding: 0 .8rem; }
body.embedded .header-back                { margin-left: 0; }
body.embedded .sidebar-account            { display: block; }      /* "Back to COSHH" inside the frame */
@media (min-width: 641px) {
    /* Desktop shell: the admin ≡ would only repeat Back to COSHH (Sign out is hidden when framed) */
    body.embedded .app-header--admin .coshh-menu-btn { display: none; }
}

/* ── Phones: a quick double tap on a control must not zoom (estate fyi 2026-09-24).
   Element selector on purpose, so anything that wants a different gesture
   still wins; text inputs are left alone (double-tap selects a word). ── */
button, summary, label, [role="button"], a { touch-action: manipulation; }

/* ── Footer: the estate "Leave feedback" link - a way in, not a call to action ── */
.app-footer { margin-top: auto; }
.app-footer .feedback-link { color: var(--text-muted); }
.admin-content .app-footer { border-top: none; text-align: left; padding: 1.5rem 0 0; }

/* ── Home page: the four questions (2026-10-21) ─────────────────────────── */
.ask-hero { text-align: center; padding: 1.25rem 0 .5rem; }
.ask-hero h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; }
.ask-hero p  { color: var(--text-muted); margin: 0; }
.ask-search { display: flex; gap: .5rem; margin: 1rem auto; max-width: 720px; }
.ask-search .form-control { flex: 1; min-width: 0; font-size: 1.05rem; }
.ask-search .btn { padding-left: 1rem; padding-right: 1rem; }
@media (max-width: 480px) { .ask-search .btn-primary span { display: none; } }   /* the magnifier is enough */
.ask-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; max-width: 900px; margin: 1rem auto; }
@media (max-width: 640px) { .ask-grid { grid-template-columns: 1fr; } }
.ask-card {
    display: flex; gap: .9rem; align-items: center; padding: 1rem 1.1rem;
    background: var(--card-bg); border: 2px solid var(--border); border-radius: var(--radius);
    color: inherit; text-decoration: none; transition: border-color .15s, transform .15s;
}
.ask-card:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); color: inherit; }
.ask-card__icon {
    width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
    background: var(--brand-light); color: var(--brand);
}
.ask-card__icon--danger, .ask-card--danger .ask-card__icon { background: var(--danger-bg); color: var(--danger); }
.ask-card--danger { border-color: #f1c2c7; }
.ask-card--danger:hover { border-color: var(--danger); }
.ask-card__t { display: block; font-weight: 700; font-size: 1.1rem; }
.ask-card__s { display: block; color: var(--text-muted); font-size: .85rem; margin-top: .15rem; }
.ask-card .chev { margin-left: auto; color: var(--text-muted); }
.ask-area { text-align: center; color: var(--text-muted); font-size: .85rem; margin: .5rem 0 1rem; }
.ask-area a { color: var(--brand); }

/* the Photo button (a file input dressed as a button: the phone opens its camera) and what comes back */
.photo-btn { cursor: pointer; }
.photo-btn input { display: none; }
@media (max-width: 480px) { .photo-btn span { display: none; } }
.lookup-card { margin: .75rem 0 1rem; }
.lookup-reading { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .5rem; }
.lookup-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0; }
.lookup-reading__t { font-size: 1rem; line-height: 1.35; }
.ai-suggest { margin: 0 0 1rem; }
.lk-table img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.lk-table form { display: inline; }

/* a question's own page */
.back-home { display: inline-flex; align-items: center; gap: .3rem; color: var(--brand); font-weight: 600; font-size: .9rem; text-decoration: none; margin-bottom: .5rem; }
.ask-head { display: flex; gap: .9rem; align-items: center; margin: .25rem 0 1rem; }
.ask-head .ask-card__icon { width: 44px; height: 44px; }
.ask-head h1 { font-size: 1.35rem; margin: 0; }
.ask-head p  { margin: .1rem 0 0; color: var(--text-muted); font-size: .9rem; }

/* results */
.result-group__t { font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 1rem 0 .4rem; font-weight: 700; }
.result {
    display: flex; gap: .8rem; align-items: center; padding: .8rem 1rem; margin-bottom: .5rem;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: inherit; text-decoration: none;
}
.result:hover { border-color: var(--brand); text-decoration: none; color: inherit; }
.result__body { flex: 1; min-width: 0; }
.result__name { font-weight: 600; }
.result__meta { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }
.result__meta .ic { vertical-align: -.15em; }
.result__ghs { display: flex; gap: .25rem; flex-shrink: 0; }
.result__ghs img { width: 26px; height: 26px; }
.result .badge { flex-shrink: 0; }
.result .chev { color: var(--text-muted); flex-shrink: 0; }

/* the emergency contacts strip */
.em-strip {
    display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem; margin-bottom: 1rem;
    background: var(--danger-bg); border: 1px solid #f1c2c7; border-radius: var(--radius-sm);
}
.em-strip { flex-direction: column; align-items: stretch; gap: .45rem; }
.em-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.em-row__t { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--danger); flex-basis: 100%; }
@media (min-width: 641px) { .em-row__t { flex-basis: auto; min-width: 9.5rem; } }
.em-strip__t { display: inline-flex; align-items: center; gap: .3rem; font-weight: 700; color: var(--danger); margin-right: .25rem; }
.em-call { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; border-radius: 99px; background: var(--danger); color: #fff; font-weight: 700; text-decoration: none; }
.em-call:hover { background: #6b1a21; color: #fff; text-decoration: none; }
.em-call small { font-weight: 500; opacity: .85; }
/* the people on now: white chips with a red edge, the hours in small type */
.em-call--person { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); padding: .4rem .75rem; font-size: .92rem; }
.em-call--person:hover { background: var(--danger); color: #fff; }
.em-call--person small { color: inherit; opacity: .9; font-weight: 600; }
.em-call--person em { font-style: normal; font-size: .72rem; font-weight: 500; opacity: .75; margin-left: .15rem; }
.em-call--later { border-style: dashed; opacity: .85; }
.em-call--nonumber { cursor: default; }
.em-none, .em-more { font-size: .85rem; color: var(--danger); font-weight: 600; }
.em-more { opacity: .8; }

/* the answer panel on a product page */
.ask-panel { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1rem; margin-bottom: 1rem; border-top: 5px solid var(--brand); }
.ask-panel--emergency { border-top-color: var(--danger); }
.ask-panel__head { display: flex; gap: .8rem; align-items: center; margin-bottom: .9rem; }
.ask-panel__q { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
.ask-panel__p { font-size: 1.25rem; font-weight: 700; line-height: 1.25; }
.ask-block { margin-bottom: 1rem; }
.ask-block__t { display: flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--brand); margin-bottom: .3rem; }
.ask-panel--emergency .ask-block__t { color: var(--danger); }
.ask-block__b { white-space: pre-line; font-size: 1rem; line-height: 1.5; }
.ask-block--big .ask-block__b { font-size: 1.1rem; }
.ask-empty { color: var(--text-muted); font-style: italic; }
.ask-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.ask-ghs { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .9rem; }
.ask-ghs img { width: 44px; height: 44px; }
.ask-loc { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.ask-loc:last-child { border-bottom: none; }
.ask-loc .ic { color: var(--brand); }
.ask-foot { font-size: .8rem; color: var(--text-muted); margin-top: .75rem; }
.ai-note { margin-top: .75rem; padding: .9rem 1rem; background: var(--bg); border-radius: var(--radius-sm); font-size: .95rem; }
.ai-note h4 { margin: .6rem 0 .25rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.ai-note ul { margin: 0; padding-left: 1.2rem; }
.ai-note__tag { font-size: .75rem; color: var(--text-muted); margin-top: .6rem; }
.ask-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.ask-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 99px; font-size: .85rem; color: var(--brand); text-decoration: none; background: var(--card-bg); }
.ask-chip:hover { border-color: var(--brand); text-decoration: none; }
.ask-chip--danger { color: var(--danger); }

/* ── Login: password eye swaps to eye-off while shown ── */
.input-toggle-pw .pw-hide { display: none; }
.input-toggle-pw.is-shown .pw-show { display: none; }
.input-toggle-pw.is-shown .pw-hide { display: inline; }

/* ── Input group (password show/hide) ── */
.input-group { display: flex; position: relative; }
.input-group .form-control { flex: 1; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-toggle-pw {
    border: 1px solid var(--border);
    border-left: none;
    background: var(--bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 0 .75rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
}
