/* The AInBox chrome, injected into every app by /_shell/nav.js. Scoped under
   #ainbox-nav so it cannot collide with the host app's own styles. */

/* `box-sizing: border-box` is what makes one rule work for both layout styles
   in the suite, and it is not optional. magpie and superbot give <body> a
   Tailwind `h-screen` (height: 100vh); with content-box, padding-top would add
   44px ON TOP of the viewport height and push the whole app into a scrollbar.
   With border-box the body still measures 100vh and its content box shrinks by
   the bar's height, which is what a fixed header wants. Ordinary
   document-flow pages (peacock, help, pipelines, engine) are unaffected —
   there the padding just makes room. */
body { box-sizing: border-box; padding-top: 44px; }

/* h-screen is 100vh, the tallest a phone's viewport gets: with the browser's
   toolbar showing, the bottom of the app (the chat composer) sits under it.
   dvh follows the toolbar; a browser without dvh drops the line and keeps
   Tailwind's 100vh. */
body.h-screen { height: 100dvh; }

/* Colours, radii and fonts come from /_shell/syalia-tokens.css, which nav.js
   injects immediately before this file. Never hardcode one here: the values
   that used to live inline were right in June and silently wrong the moment
   the palette moved. e2e/tests/test_design_system.py enforces it. */

#ainbox-nav {
  position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 2147483000;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur-glass); backdrop-filter: var(--blur-glass);
  border-bottom: var(--bw) solid var(--glass-border);
  color: var(--text);
  font: var(--weight-medium) 14px/1 var(--font-sans), system-ui, sans-serif;
  box-sizing: border-box;
}
#ainbox-nav a, #ainbox-nav button {
  color: inherit; font: inherit; text-decoration: none; background: transparent;
  border: 0; cursor: pointer; padding: 7px 11px; border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 7px;
  transition: background var(--dur-micro) var(--ease);
}
#ainbox-nav a:hover, #ainbox-nav button:hover { background: var(--surface-2); }
#ainbox-nav .mark { width: 22px; height: 22px; }
#ainbox-nav .spacer { flex: 1; }
#ainbox-nav .user { color: var(--text-dim); font-size: .85rem; display: inline-flex; align-items: center; gap: 4px; }
/* Icons are Material Icons ligatures. syalia-tokens.css registers the family,
   and every page that loads this file loads that one first.
   Until the font arrives (or if it never does), the browser lays out the
   ligature's name, "account_circle", as text in the fallback font: on a CI
   runner with only DejaVu Sans that pushed sign-out 155px past a 1440px
   window (#275). A glyph is 1em wide, so a 1em box that clips changes nothing
   once the font is in and keeps the bar's width when it is not. */
#ainbox-nav .ico {
  font-family: "Material Icons"; font-weight: normal; font-style: normal;
  font-size: 18px; line-height: 1; letter-spacing: normal; text-transform: none;
  white-space: nowrap; direction: ltr; font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  display: inline-block; width: 1em; overflow: hidden; flex-shrink: 0;
}

/* Bandeja's unread count, beside its tab. The phone has carried this number
   since its tab bar existed; the web's landing made the tab bar the only place
   it could live, so the two surfaces now read the same (#348). Nothing is
   rendered at zero: a "0" would read as news. */
#ainbox-nav .count {
  min-width: 1.25rem; padding: 1px 5px; border-radius: var(--radius-full);
  background: var(--accent); color: var(--bg);
  font-size: .68rem; font-weight: var(--weight-semibold); line-height: 1.25;
  text-align: center; flex-shrink: 0;
}

/* The per-app bar: ONE row directly under the chrome, carrying only app-local
   controls — magpie's mode tabs, peacock's project title, help's search box.
   Identity, the signed-in user and sign-out live in #ainbox-nav above and
   appear exactly once in the suite; an app that draws its own is a bug that
   e2e/tests/test_design_system.py fails the build for.

   Namespaced on a single class so it cannot collide with a host app's own
   styles — the same discipline the token slice follows. Deliberately NOT glass
   like #ainbox-nav: two stacked translucent bars over seven different app
   backgrounds read as a rendering artefact. A flat surface reads as a second
   row that belongs to the app. */
.ainbox-appbar {
  display: flex; align-items: center; gap: 8px;
  height: 44px; box-sizing: border-box; padding: 0 12px;
  background: var(--surface-2);
  border-bottom: var(--bw) solid var(--border);
  color: var(--text);
  font: var(--weight-medium) 14px/1 var(--font-sans), system-ui, sans-serif;
}
/* Slots. Any may be omitted; `.mid` is the only one that grows, so a bar with
   just a left cluster keeps its controls left-aligned instead of stretching
   them across the row. */
.ainbox-appbar > .start,
.ainbox-appbar > .end { display: flex; align-items: center; gap: 8px; }
.ainbox-appbar > .mid {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.ainbox-appbar > .end { margin-left: auto; }

/* Tabs. The current one is marked by a colour + an underline rather than a
   filled pill: the bar sits on top of seven different app backgrounds and a
   fill that reads right on one reads as a bug on another. */
#ainbox-nav .tab { color: var(--text-dim); position: relative; }
#ainbox-nav .tab:hover { color: var(--text); }
#ainbox-nav .tab.active { color: var(--text); }
#ainbox-nav .tab.active::after {
  content: ''; position: absolute; left: 11px; right: 11px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
#ainbox-nav .tab .ico { font-size: 18px; }
#ainbox-nav .tab.icon-only, #ainbox-nav .fb { padding: 7px 9px; }
/* Icon-only tabs keep their label in the accessibility tree — an icon is not
   an accessible name, and this is also what a testid-free locator would find. */
#ainbox-nav .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Narrow viewports: drop the primary labels before anything can overflow the
   bar. The tabs stay, so the bar degrades to icons rather than to a scrollbar. */
@media (max-width: 860px) {
  #ainbox-nav .tab .label:not(.sr-only) { display: none; }
  #ainbox-nav .tab { padding: 7px 9px; }
  #ainbox-nav .user { display: none; }
}
/* An admin's bar has eight tabs and sign-out, about 490px at the padding
   above: on a phone it ran past the edge and clipped Salir (#206). */
@media (max-width: 480px) {
  #ainbox-nav { gap: 2px; padding: 0 4px; }
  #ainbox-nav a, #ainbox-nav button, #ainbox-nav .tab, #ainbox-nav .tab.icon-only, #ainbox-nav .fb { padding: 7px 4px; }
  /* The underline's 11px insets would leave a 4px dot on a 26px tab. */
  #ainbox-nav .tab.active::after { left: 4px; right: 4px; }
  /* Icon-only and 2px a side: the bar is at its budget, and this button must
     not push Salir past the edge (#206). */
  #ainbox-nav .fb { padding: 7px 2px; }
}
/* Ten tabs, the comment button and sign-out for an admin: below 400px only
   less padding fits them, or Salir runs past the edge (#206, #465). */
@media (max-width: 400px) {
  #ainbox-nav { gap: 0; padding: 0 2px; }
  #ainbox-nav a, #ainbox-nav button, #ainbox-nav .tab, #ainbox-nav .tab.icon-only, #ainbox-nav .fb { padding: 7px 2px; }
  #ainbox-nav .tab .ico { font-size: 16px; }
}

/* The feedback dialog (#465). A <dialog> sits in the top layer, so no app's
   stacking context or overflow can clip it. Every colour is a token; the text
   and controls are Spanish, in the same voice as the rest of the suite. */
#ainbox-feedback {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0; overflow: auto;
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--border); border-radius: var(--radius-lg);
  font: var(--weight-medium) 14px/1.45 var(--font-sans), system-ui, sans-serif;
}
#ainbox-feedback::backdrop { background: rgba(0, 0, 0, .55); }
#ainbox-feedback .fb-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
#ainbox-feedback h2 { margin: 0; font-size: 1.05rem; color: var(--text); }
#ainbox-feedback p { margin: 0; }
#ainbox-feedback .fb-field { display: block; font-size: .78rem; color: var(--text-dim); }
#ainbox-feedback select,
#ainbox-feedback textarea,
#ainbox-feedback input[type=email] {
  display: block; width: 100%; box-sizing: border-box; margin-top: 4px;
  background: var(--surface-2); color: var(--text);
  border: var(--bw) solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; font: inherit; font-weight: var(--weight-normal);
}
#ainbox-feedback textarea { resize: vertical; min-height: 84px; }
#ainbox-feedback .fb-shot { display: flex; gap: 12px; align-items: center; }
#ainbox-feedback .fb-shot img {
  max-width: 150px; max-height: 92px;
  border: var(--bw) solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg);
}
#ainbox-feedback .fb-check { display: flex; gap: 6px; align-items: center; font-size: .85rem; }
#ainbox-feedback .fb-attach input { margin-top: 6px; font-size: .82rem; }
#ainbox-feedback .fb-files,
#ainbox-feedback .fb-note { font-size: .76rem; color: var(--text-faint); }
#ainbox-feedback .fb-error { color: var(--err); font-size: .85rem; }
#ainbox-feedback .fb-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
#ainbox-feedback button {
  font: inherit; cursor: pointer; padding: 7px 14px; min-height: 34px;
  background: transparent; color: var(--text-dim);
  border: var(--bw) solid var(--border); border-radius: var(--radius-sm);
}
#ainbox-feedback button:hover { color: var(--text); border-color: var(--border-hi); }
#ainbox-feedback button.fb-send { background: var(--accent); color: var(--bg); border-color: transparent; }
#ainbox-feedback button[disabled] { opacity: .55; cursor: default; }
#ainbox-feedback a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }
