/*
 * diveos_shell.css — layout shell + sidebar + side drawer styles
 *
 * Loaded by application.css after tokens + patterns. Lives separately from
 * patterns.css because the shell is a singular structural component, not
 * a reusable pattern.
 *
 * Per docs/archive/UI-MIGRATION-PLAN.md T6 + UI-ARCHITECTURE.md §1 sidebar IA spec.
 */

/* ─── Body + shell ─────────────────────────────────────────────────── */
.diveos-body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  /* Inter OpenType features per the repo spec (cv11 single-storey a,
     ss01/ss03 alternates). Harmless on General Sans / Geist Mono. */
  font-feature-settings: "cv11", "ss01", "ss03";
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.diveos-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Mobile hamburger ─────────────────────────────────────────────── */
.diveos-hamburger {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  /* 44px minimum touch target per DESIGN.md a11y section. */
  width: 44px;
  height: 44px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.diveos-hamburger:hover { background: var(--surface-alt); }

/* ─── Sidebar ──────────────────────────────────────────────────────── */
.diveos-sidebar {
  display: flex;
  flex-direction: column;
  /* v4: gray-100 sidebar per the repo spec (was white --surface). */
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 24px 16px 16px;
}

.diveos-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 16px;
}
/* Primary CTA — clean .dv-btn--lg component (not utility soup). Layout-only
   here: full width + the gap before the nav. */
.diveos-sidebar__cta {
  display: flex;
  width: 100%;
  justify-content: center;
  margin-bottom: 32px;
}
/* Brand mark links to Today (logo-links-home). Quiet hover — tint the
   product mark, no background block in the brand zone. */
.diveos-sidebar__brand-link { color: inherit; }
.diveos-sidebar__brand-link:hover .diveos-sidebar__product { color: var(--accent-strong); }
.diveos-sidebar__product {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}
.diveos-sidebar__tenant {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0;
}

.diveos-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
/* Section labels inside the sidebar get tighter top margins than the
   global .section-label utility (which is tuned for in-content use). */
.diveos-sidebar__nav .section-label {
  margin: 18px 10px 6px;
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted-2);
}
.diveos-sidebar__nav .section-label:first-child { margin-top: 0; }

.diveos-sidebar__items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.diveos-sidebar__item {
  position: relative;
}
.diveos-sidebar__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.diveos-sidebar__link:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}
.diveos-sidebar__item--active .diveos-sidebar__link {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
/* Active state is the accent-soft fill + accent text (our treatment); no
   left-edge bar. ::before neutralized — kept out so it can't mis-position. */
.diveos-sidebar__item--active::before { content: none; }
.diveos-sidebar__label { line-height: 1.2; }
.diveos-sidebar__badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: var(--text-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  line-height: 1.4;
}

/* ─── Owner footer ─────────────────────────────────────────────────── */
.diveos-sidebar__owner-trigger { position: relative; }
.diveos-sidebar__owner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease-out;
}
.diveos-sidebar__owner:hover { background: var(--surface-alt); }
.diveos-sidebar__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.diveos-sidebar__owner-text { min-width: 0; flex: 1; }
.diveos-sidebar__owner-label {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.diveos-sidebar__owner-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.diveos-sidebar__owner-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
  text-transform: capitalize;
}

/* Upward-opening account menu (footer sits at bottom of sidebar) */
.diveos-sidebar__owner-menu {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  min-width: 200px;
  margin-bottom: 6px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  z-index: 20;
}
.diveos-sidebar__owner-menu.hidden { display: none; }
.diveos-sidebar__owner-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease-out;
}
.diveos-sidebar__owner-menu-item:hover { background: var(--bg); }
.diveos-sidebar__owner-menu-item--divided {
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* ─── Main pane ────────────────────────────────────────────────────── */
.diveos-main {
  background: var(--bg);
  outline: none;
  min-height: 100vh;
  /* Grid items default to min-width:auto, so a wide unwrappable child (mono
     trip title + action buttons) inflates the shell column past the viewport
     and forces horizontal scroll on phones. 0 lets the pane shrink-to-fit. */
  min-width: 0;
}
.diveos-content {
  max-width: 1280px;
  margin-inline: auto;   /* centre the content column within the main pane */
  /* --shell-pad-top is the single source of truth for the pane's top padding.
     Full-bleed headers (.dv-page-head / .dv-page-tools / .page-header /
     .hero-show__band) pull up by EXACTLY this via calc() so the band sits flush
     at the pane top on every breakpoint — no hardcoded -40px to drift out of
     sync (it previously left a 16px gap on mobile where the pad is 56px). */
  --shell-pad-top: 40px;
  padding: var(--shell-pad-top) 48px 64px;
}

/* Full-bleed pages (content_for :full_bleed) — e.g. the POS booking wizard:
   the page owns the whole content pane as a fixed-height app-shell region
   (its own header/stepper, an internally-scrolling body, and a footer pinned
   to the viewport bottom) instead of the default padded, page-scrolling column. */
.diveos-main--bleed {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.diveos-content--bleed {
  flex: 1;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Side drawer (the layout-level Turbo Frame) ───────────────────── */
.side-drawer {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  width: 560px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}
.side-drawer > * { min-height: 0; height: 100%; width: 100%; }
.side-drawer.side-drawer--open {
  transform: translateX(0);
  pointer-events: auto;
}
.side-drawer::-webkit-scrollbar { width: 8px; }
.side-drawer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── Side-drawer scrim ─────────────────────────────────────────────── */
/* Dims the page behind ANY open side panel (Trip / Diver / Fleet / Gear /
   Team / Fast-create), matching the Bookings slideover's `.slideover-backdrop`
   look. Sits just below the drawer (z-index 40 vs the drawer's 40 — declared
   first so the later drawer paints above) and fades in/out. The side_panel
   controller toggles `.side-drawer-scrim--visible` in lock-step with the
   drawer's open class; clicking it closes the drawer via the controller's
   outside-click handler. */
.side-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(15, 27, 45, 0.30);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}
.side-drawer-scrim--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Mobile drawer scrim ──────────────────────────────────────────── */
/* Desktop never shows it; below 1024px it sits between the page and the
   open drawer so a tap outside dismisses instead of dead-ending. */
.diveos-scrim { display: none; }

/* ─── Responsive: mobile (< 1024px) ────────────────────────────────── */
@media (max-width: 1023px) {
  .diveos-shell { grid-template-columns: 1fr; }
  .diveos-hamburger { display: inline-flex; }
  .diveos-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
    z-index: 50;
    height: 100vh;
  }
  .diveos-shell--menu-open .diveos-sidebar { transform: translateX(0); }
  .diveos-shell--menu-open .diveos-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 32, 0.45);
  }
  .diveos-content { --shell-pad-top: 56px; padding: var(--shell-pad-top) 16px 32px; }
  .side-drawer { width: 100vw; max-width: 100vw; }
}

/* ─── Responsive: phones (< 640px) ─────────────────────────────────── */
/* The info strip's N-up grid has a min-content width (~345px for the trip
   strip) that propagates up and forces horizontal page scroll on phones.
   Stack the cells; side dividers become bottom dividers. */
@media (max-width: 639px) {
  .info-strip { grid-template-columns: 1fr; }
  .info-strip__cell { border-right: 0; }
  .info-strip__cell:not(:last-child) { border-bottom: 1px solid var(--border); }
}

/* ── Sidebar collapse (rail ⇄ 68px icon strip) ───────────────────────────
   Relocated here from components/package_builder.css: this is general shell/
   sidebar behaviour (the brand chevron toggle + collapsed rail), not package-
   builder-specific. Lives with the shell so the package-builder CSS can ship
   as its own PR without the sidebar depending on it. */
/* ─── 3. Sidebar collapse (extends the real .diveos-sidebar) ───────── */
/* The shell grid resolves the rail width from --sidebar-w. Collapse swaps
   that var on the shell so the grid column tracks the 68px rail. The width
   transition lives on the sidebar; the grid column follows because it reads
   the same var. */
.diveos-sidebar {
  /* add the animated width so collapse glides (the shell sets the column) */
  transition: width var(--t-slow) var(--ease-out-quart);
  overflow: hidden;
}
/* Animate the GRID TRACK so the rail glides. The column drives the sidebar
   width, so the transition must live on grid-template-columns — a transition
   on the sidebar's own width is clipped instantly by the resized track. */
.diveos-shell {
  transition: grid-template-columns var(--t-slow) var(--ease-out-quart);
}
.diveos-shell.is-rail-collapsed {
  grid-template-columns: 68px 1fr;
}

/* collapse toggle — ghost button styled like a quiet nav affordance.
   Lives in the brand header; the markup adds it next to the brand block. */
.diveos-sidebar__collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  margin-left: auto;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}
.diveos-sidebar__collapse:hover { background: var(--surface-alt); color: var(--ink); }

/* ── collapsed state ──────────────────────────────────────────────── */
.diveos-shell.is-rail-collapsed .diveos-sidebar { width: 68px; padding: 24px 0 16px; }

/* brand: hide the text block, center the logo, drop the toggle below it */
.diveos-shell.is-rail-collapsed .diveos-sidebar__brand {
  padding: 0 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.diveos-shell.is-rail-collapsed .diveos-sidebar__brand-link { justify-content: center; }
.diveos-shell.is-rail-collapsed .diveos-sidebar__brand-link > div { display: none; }
.diveos-shell.is-rail-collapsed .diveos-sidebar__collapse { margin-left: 0; }

/* CTA → icon-only 40px accent square */
.diveos-shell.is-rail-collapsed .diveos-sidebar__cta {
  width: 40px;
  height: 40px;
  margin: 0 auto 24px;
  padding: 0;
}
.diveos-shell.is-rail-collapsed .diveos-sidebar__cta i,
.diveos-shell.is-rail-collapsed .diveos-sidebar__cta svg { margin: 0; }
.diveos-shell.is-rail-collapsed .diveos-sidebar__cta .pkb-cta-label { display: none; }

/* nav: section labels → a hairline divider; items → icon-only */
.diveos-shell.is-rail-collapsed .diveos-sidebar__nav { padding: 0 10px; }
.diveos-shell.is-rail-collapsed .diveos-sidebar__nav .section-label {
  height: 1px;
  margin: 14px 8px 8px;
  padding: 0;
  background: var(--hairline);
  overflow: hidden;
  text-indent: -9999px;
}
.diveos-shell.is-rail-collapsed .diveos-sidebar__link {
  justify-content: center;
  padding: 9px 0;
}
.diveos-shell.is-rail-collapsed .diveos-sidebar__label,
.diveos-shell.is-rail-collapsed .diveos-sidebar__badge { display: none; }
/* active item: just the accent icon on accent-soft (no left bar in collapsed) */
.diveos-shell.is-rail-collapsed .diveos-sidebar__item--active .diveos-sidebar__link {
  background: var(--accent-soft);
}

/* owner footer → avatar only */
.diveos-shell.is-rail-collapsed .diveos-sidebar__owner {
  justify-content: center;
  padding: 8px 0;
}
.diveos-shell.is-rail-collapsed .diveos-sidebar__owner-text { display: none; }

/* respect reduced-motion for the width glide */
@media (prefers-reduced-motion: reduce) {
  .diveos-sidebar { transition: none; }
}
