/*
 * Growth Partner — app shell (UX overhaul phase 1)
 *
 * The layout frame, the grouped navy sidebar, the text country switch, the
 * user block and the phone tab bar. Spec: the <aside class="sb"> block in the
 * mock-up's Main.dc.html and the .ph-tab bar in M-Vandaag.dc.html.
 *
 * Three widths, one markup:
 *   > 768px     full sidebar (labels, group headings, user block)
 *   481–768px   icon rail: every label is hidden VISUALLY (never display:none,
 *               which would empty the links' accessible names, #86)
 *   <= 480px    the sidebar is an off-canvas drawer opened by the "Meer" tab
 *               of a fixed bottom tab bar
 * Guards: test/system/sidebar_rail_a11y_test.rb, test/system/phone_tab_bar_test.rb.
 *
 * Green text is allowed here only ON the navy sidebar (single-line rules
 * whose selector names the sidebar). Phone rules at the bottom of the file.
 */

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.main-wrap { margin-left: 13.5rem; flex: 1; min-width: 0; }
main.container { padding-top: 1.5rem; }

/* ── Zoeken top bar ── centred above every page (layout, global_search
   controller). The page's own top padding shrinks so the bar costs as little
   height as possible (the company rail must stay above the fold at 1440×900). */
/* Three columns: [back link] [search, centred] [empty]. */
.ux-topbar {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 640px) minmax(0, 1fr);
  align-items: center; gap: 12px; padding: 12px 1.5rem 0;
}
.ux-topbar + main.container { padding-top: 0.75rem; }
.ux-topbar-start { grid-column: 1; justify-self: start; min-width: 0; }
.ux-topbar-start .back-link { margin: 0; white-space: nowrap; }
.ux-topbar-form { grid-column: 2; margin: 0; min-width: 0; }
.ux-search { position: relative; width: 100%; }
/* Too narrow for three columns: the back link takes its own line above. */
@media (max-width: 1100px) {
  .ux-topbar { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .ux-topbar-start, .ux-topbar-form { grid-column: 1; }
  .ux-topbar-form { justify-self: center; width: min(640px, 100%); }
}
.ux-search input[type="search"] {
  width: 100%; height: 40px; margin: 0; padding: 0 3.25rem 0 2.4rem;
  border: 1px solid var(--gp-line); border-radius: 10px; background: #fff;
  font-size: 0.9rem; color: var(--gp-ink);
}
.ux-search input[type="search"]:focus { border-color: var(--gp-navy); box-shadow: 0 0 0 3px rgba(13, 58, 89, 0.14); }
.ux-search-icon { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); display: flex; color: var(--gp-body); pointer-events: none; }
.ux-search-icon svg { width: 16px; height: 16px; }
.ux-search-kbd {
  position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); pointer-events: none;
  padding: 1px 6px; border: 1px solid var(--gp-line); border-radius: 6px;
  background: var(--gp-surface, #f8fafc); color: var(--gp-body); font-size: 0.72rem; font-family: inherit;
}
.ux-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 900;
  max-height: min(70vh, 560px); overflow-y: auto;
  background: #fff; border: 1px solid var(--gp-line); border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16); padding: 6px;
}
.gp-search-group + .gp-search-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--gp-line); }
.gp-search-group-label {
  padding: 6px 10px 2px; font-family: var(--gp-font-heading); font-weight: 700; font-size: 0.68rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--gp-body);
}
.gp-search-option, .gp-search-all {
  display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 8px;
  text-decoration: none; color: var(--gp-ink);
}
.gp-search-option:hover, .gp-search-option[aria-selected="true"],
.gp-search-all:hover, .gp-search-all[aria-selected="true"] { background: var(--gp-green-tint); color: var(--gp-ink); }
.gp-search-title { font-weight: 600; font-size: 0.9rem; color: var(--gp-ink); overflow-wrap: anywhere; }
.gp-search-meta { font-size: 0.78rem; color: var(--gp-body); overflow-wrap: anywhere; }
.gp-search-all { margin-top: 4px; border-top: 1px solid var(--gp-line); border-radius: 0 0 8px 8px; font-weight: 700; font-size: 0.85rem; color: var(--gp-navy); }
.gp-search-empty { margin: 0; padding: 10px; color: var(--gp-body); font-size: 0.85rem; }
/* Full results page */
.gp-search-page-form { display: flex; gap: 8px; max-width: 640px; margin: 0 0 18px; }
.gp-search-page-form input[type="search"] { margin: 0; flex: 1 1 auto; }
.gp-search-page-form .gp-btn { flex: none; height: auto; }
.gp-search-page-groups { display: flex; flex-direction: column; gap: 16px; }
.gp-search-page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px 6px; }
.gp-search-page-head .gp-eyebrow { margin: 0; }

/* ── Sidebar ── flat Airclima navy; the active link is the raised navy with
   a green icon (decorative, on navy). */
.sidebar {
  width: 13.5rem;
  background: var(--gp-navy); color: var(--gp-on-navy-body);
  position: fixed; top: 0; bottom: 0;
  display: flex; flex-direction: column; gap: 0.9rem;
  padding: 1.2rem 0.75rem 0.75rem;
  z-index: 100; overflow-y: auto; overflow-x: hidden;
}

/* Brand: wordmark with the green square. */
.sidebar-brand {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.1rem 0.5rem;
  font-family: var(--gp-font-heading); font-weight: 700; font-size: 0.9rem;
  letter-spacing: 0.25em; text-transform: uppercase; color: #fff;
}
.sidebar-brand-mark { width: 11px; height: 11px; flex: none; background: var(--gp-green); }

/* Country switch: a two-segment text toggle on the deep navy. */
.country-switcher {
  display: flex; gap: 3px; padding: 3px;
  background: var(--gp-navy-deep); border-radius: 10px;
}
.country-tab {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 0.35rem 0.25rem; border-radius: 8px;
  color: var(--gp-on-navy); text-decoration: none;
  font-size: 0.78rem; font-weight: 600;
}
.country-tab:hover { color: #fff; }
.country-tab.active { color: #fff; background: var(--gp-navy-raised); }
.country-tab-code { display: none; }

/* Nav links. Pico gives every <nav> justify-content: space-between, which
   would spread the groups down the full height. */
.sidebar-nav { display: flex; flex-direction: column; justify-content: flex-start; gap: 2px; }
.sidebar-nav-main { flex: 1; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.6rem; border-radius: 10px;
  color: var(--gp-on-navy-body); text-decoration: none;
  font-size: 0.85rem; font-weight: 600;
}
.sidebar-link:hover { color: #fff; background: var(--gp-navy-deep); }
.sidebar-link.active { color: #fff; background: var(--gp-navy-raised); }
.sidebar-link.active .sidebar-icon { color: var(--gp-green); }
.sidebar-icon { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }
.sidebar-icon svg, .sidebar-user-icon svg { width: 100%; height: 100%; }
.sidebar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sidebar-badge {
  background: var(--gp-red-ink); color: #fff; font-size: 0.7rem; font-weight: 700;
  padding: 0.1rem 0.45rem; border-radius: 999px; min-width: 1.25rem;
  text-align: center; line-height: 1.2;
}

/* Groups (role="group" for the accessible name only — Pico's group styling
   is stripped from the vendored file, frontend.md "Pico gotchas"). */
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-group-label {
  display: block; padding: 0.9rem 0.6rem 0.3rem;
  font-family: var(--gp-font-heading); font-weight: 700; font-size: 0.65rem;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--gp-on-navy);
}

/* Beheer: one link above the user block. */
.sidebar-admin { border-top: 1px solid var(--gp-navy-raised); padding-top: 0.6rem; }

/* User block: avatar, name, role and two small links. */
.sidebar-user {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.6rem;
  padding: 0.75rem 0.5rem 0.25rem;
  border-top: 1px solid var(--gp-navy-raised);
}
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 0.72rem; color: var(--gp-on-navy); }
.sidebar-user-links { display: flex; align-items: center; gap: 0.9rem; flex-basis: 100%; padding-left: calc(28px + 0.6rem); }
.sidebar-logout-form { margin: 0; display: inline-flex; }
.sidebar-user-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  width: auto; height: auto; margin: 0; padding: 0;
  background: transparent; border: 0; border-radius: 4px; box-shadow: none;
  color: var(--gp-on-navy); font-family: inherit; font-size: 0.75rem; font-weight: 600; line-height: 1.4;
  text-decoration: underline; text-underline-offset: 0.15em; cursor: pointer;
}
.sidebar-user-link:hover, .sidebar-user-link.active { color: #fff; background: transparent; }
.sidebar-user-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: none; }
.sidebar-user-icon { display: none; width: 1.2rem; height: 1.2rem; flex-shrink: 0; }

/* The phone tab bar only exists at <= 480px. */
.ux-tabbar { display: none; }
.sidebar-backdrop { display: none; }

/* ── Icon rail (481–768px) ── */
@media (max-width: 768px) {
  .sidebar { width: 3.5rem; padding: 1rem 0.35rem 0.5rem; gap: 0.75rem; }
  .main-wrap { margin-left: 3.5rem; }
  .sidebar-brand { justify-content: center; padding: 0.25rem 0; }
  .country-switcher { flex-direction: column; }
  .country-tab-code { display: inline; font-size: 0.72rem; letter-spacing: 0.05em; }
  .sidebar-link { justify-content: center; gap: 0; padding: 0.55rem 0; }
  .sidebar-icon { width: 1.35rem; height: 1.35rem; }
  .sidebar-group { border-top: 1px solid var(--gp-navy-raised); margin-top: 0.4rem; padding-top: 0.4rem; }
  .sidebar-link .sidebar-badge { position: absolute; top: 2px; right: 2px; font-size: 0.6rem; padding: 0 0.3rem; min-width: 1rem; }
  .sidebar-link { position: relative; }
  .sidebar-user { flex-direction: column; flex-wrap: nowrap; padding: 0.6rem 0 0; gap: 0.5rem; }
  .sidebar-user-links { flex-direction: column; flex-basis: auto; padding-left: 0; gap: 0.25rem; }
  .sidebar-user-link { justify-content: center; width: 2.5rem; height: 2.5rem; }
  .sidebar-user-icon { display: inline-block; }
}

/* Hidden VISUALLY only: each label is still the accessible name of its link,
   group or country tab. Mirrors .visually-hidden. Scoped with a min-width so
   the <= 480px drawer shows the full labels again. */
@media (min-width: 481px) and (max-width: 768px) {
  .sidebar-label, .sidebar-group-label, .sidebar-brand-name, .sidebar-user-info {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ── Phone (<= 480px): off-canvas drawer + bottom tab bar ── */
@media (max-width: 480px) {
  /* The drawer: full labels again. visibility keeps the closed drawer out of
     the tab order and the accessibility tree while it is off-screen. */
  .sidebar {
    width: 15rem; padding: 1.2rem 0.75rem 0.75rem; gap: 0.9rem;
    transform: translateX(-100%); visibility: hidden;
    transition: transform 0.2s, visibility 0.2s;
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .main-wrap { margin-left: 0; padding-bottom: calc(4.25rem + env(safe-area-inset-bottom)); }
  main.container { padding-top: 1rem; }
  .ux-topbar { padding: 10px 12px 0; }
  .ux-topbar + main.container { padding-top: 0.75rem; }
  .ux-search-kbd { display: none; }
  .ux-search input[type="search"] { height: 44px; padding-right: 0.8rem; font-size: 1rem; }
  .sidebar-brand { justify-content: flex-start; padding: 0.1rem 0.5rem; }
  .country-switcher { flex-direction: row; }
  .country-tab-code { display: none; }
  .sidebar-link { justify-content: flex-start; gap: 0.7rem; padding: 0.7rem 0.6rem; }
  .sidebar-link .sidebar-badge { position: static; font-size: 0.7rem; padding: 0.1rem 0.45rem; min-width: 1.25rem; }
  .sidebar-group { border-top: 0; margin-top: 0; padding-top: 0; }
  .sidebar-user { flex-direction: row; flex-wrap: wrap; padding: 0.75rem 0.5rem 0.25rem; gap: 0.35rem 0.6rem; }
  .sidebar-user-links { flex-direction: row; flex-basis: 100%; padding-left: calc(28px + 0.6rem); gap: 1.2rem; }
  .sidebar-user-link { width: auto; height: auto; min-height: 40px; justify-content: flex-start; }
  .sidebar-user-icon { display: none; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: rgba(11, 46, 71, 0.45);
  }
  .sidebar.open ~ .sidebar-backdrop { display: block; }
  body.sidebar-locked { overflow: hidden; }

  /* The tab bar: white, a hairline on top, the current tab navy with a
     decorative green top edge. Under the backdrop (z 99) while the drawer is
     open; above page content and sticky bars. */
  .ux-tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    margin: 0; padding: 0 0 env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--gp-line);
  }
  .ux-tab {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    width: auto; min-width: 0; min-height: 3.5rem; margin: 0; padding: 0.45rem 0.15rem 0.6rem;
    background: #fff; color: var(--gp-body); border: 0; border-radius: 0; box-shadow: none;
    font-family: inherit; font-size: 0.68rem; font-weight: 700; line-height: 1.2;
    text-decoration: none; cursor: pointer;
  }
  .ux-tab:hover { color: var(--gp-navy); background: var(--gp-surface); }
  .ux-tab.active { color: var(--gp-navy); box-shadow: inset 0 3px 0 var(--gp-green); }
  .ux-tab:focus-visible { outline: 2px solid var(--gp-navy); outline-offset: -2px; }
  .ux-tab-icon { width: 1.35rem; height: 1.35rem; flex: none; }
  .ux-tab-icon svg { width: 100%; height: 100%; }
  .ux-tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ux-tab-badge {
    position: absolute; top: 0.3rem; left: calc(50% + 0.35rem);
    font-size: 0.62rem; padding: 0 0.3rem; min-width: 1rem;
  }

  /* The bulk action bar floats above the tab bar, not on top of it. */
  .bulk-bar-visible { bottom: calc(4.25rem + env(safe-area-inset-bottom)); }
}
