/* server/app/static/css/styles.css — Pilot styling.
 *
 * Purpose:
 *   Responsive styles for the Support Intake SPA: desktop and narrow
 *   mobile, keyboard focus visibility, reduced-motion behaviour,
 *   mobile-sized touch targets (design doc).
 *
 * Public contracts:
 *   Class names referenced by static/js/app.js.
 *
 * Change safety:
 *   No build pipeline (AGENTS.md D2) — this file is served as-is.
 */

:root {
  --ink: #1c2733;
  --muted: #5b6b7c;
  --accent: #0b63ce;
  --accent-ink: #ffffff;
  --error: #b3261e;
  --ok: #146c2e;
  --line: #d7dee6;
  --bg: #f5f7fa;
  --card: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0; font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
}
main { max-width: 680px; margin: 0 auto; padding: 16px; }

.masthead {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--accent); }
.brand-sub { color: var(--muted); }
.brand-sub em { font-style: normal; font-size: 0.8em; }
#logout-btn { margin-left: auto; }

.demo-banner {
  background: #fff3cd; color: #664d03; padding: 8px 16px;
  text-align: center; font-size: 0.9rem; border-bottom: 1px solid #ffe69c;
}

h1 { font-size: 1.5rem; margin: 24px 0 8px; }
h2 { font-size: 1.15rem; margin: 16px 0 8px; }
.sub { color: var(--muted); margin-top: 0; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 12px; font-size: 1rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
}
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
textarea { min-height: 120px; }

button {
  font: inherit; min-height: 44px; min-width: 44px; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link-btn { background: none; border: none; color: var(--accent); padding: 8px 4px; }
/* §26: disabled vs pending vs warning are visually distinct and never
   color alone — disabled loses its border emphasis and gains a dashed
   outline; pending (aria-busy) keeps full contrast with an ellipsis
   label set by JS; warning keeps the strong border. */
button:disabled { opacity: 0.55; cursor: not-allowed;
  border-style: dashed; }
button[aria-busy="true"] { font-style: italic; cursor: progress; }
.warn { border-color: #b3261e; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.error { color: var(--error); margin: 6px 0; min-height: 1.2em; }
.ok-note { color: var(--ok); }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: -9999px; background: var(--accent);
  color: #fff; padding: 8px 16px; z-index: 10;
}
.skip-link:focus { left: 8px; top: 8px; }

/* Six-slot code display */
.code-slots { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.code-slots input {
  width: 44px; height: 52px; text-align: center; font-size: 1.4rem;
  padding: 4px;
}

/* Intake section rows: full-size tap targets, collapse to summaries */
.section-row {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin: 10px 0; overflow: hidden;
}
.section-summary {
  display: flex; width: 100%; text-align: left; background: none;
  border: none; padding: 16px; gap: 10px; align-items: baseline;
  min-height: 56px;
}
.section-summary .title { font-weight: 600; }
.section-summary .summary { color: var(--muted); font-size: 0.92rem; }
.section-summary .check { color: var(--ok); margin-left: auto; }
.section-body { padding: 0 16px 16px; border-top: 1px dashed var(--line); }

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: #e8f0fe; color: var(--accent); font-size: 0.8rem;
}

/* Address picker (Session 5, DR §7): suggestion listbox under the
   search combobox. Highlight is shape + background, not color alone. */
.suggestions { margin: 4px 0; }
.suggestions .suggestion {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); cursor: pointer; margin: 4px 0; min-height: 44px;
}
.suggestions .suggestion-active {
  border-color: var(--accent); background: #e8f0fe; font-weight: 600;
  outline: 2px solid var(--accent); outline-offset: -2px;
}

/* Payment billing-address radio group (DR §7: radio semantics, no
   Smart Tab) and the §15 submit-reason line. */
.billing-choice { border: 1px solid var(--line); border-radius: var(--radius);
  margin: 12px 0; padding: 8px 14px; }
.billing-choice legend { font-weight: 600; padding: 0 6px; }
.row-billing { display: flex; align-items: center; gap: 10px;
  font-weight: 400; margin: 8px 0; }
#billing-editor { border-left: 3px solid var(--line); padding-left: 14px; }
.submit-reason { margin-top: 8px; }

.history-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin: 8px 0;
  cursor: pointer; list-style: none;
}
.history-item .num { font-weight: 700; }
.history-item .status { float: right; }
.history-item .date { color: var(--muted); font-size: 0.82rem; }
#history-list { padding: 0; margin: 8px 0; }
/* Standard §21: loading / empty / failed are distinct, visible states. */
.history-loading { color: var(--muted); font-style: italic; list-style: none; }
.history-empty { color: var(--muted); list-style: none; padding: 14px 16px; }
.history-failed { list-style: none; }
#request-detail .snapshot { color: var(--ink); }
#request-detail .snapshot li { margin: 2px 0; }

/* Manage contact methods (Session 4): masked rows, inline named
   confirmation, inline last-method explanation (standard §16.3/§24.1). */
#contact-list { padding: 0; margin: 8px 0; list-style: none; }
.contact-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin: 8px 0;
}
.contact-row .contact-value { font-weight: 600; }
.contact-row .contact-actions { margin-left: auto; display: flex;
  flex-wrap: wrap; align-items: center; gap: 10px; }
.contact-row .confirm-question { margin: 4px 0; }
.contact-explanation { margin: 4px 0; }
/* §22: per-row inline errors inside section bodies and next to the
   decision buttons sit by the failing control, never stacked at the
   page level. */
.row-error, .decision-error { margin: 6px 0; }

/* AI-context debug offer (Session 7, DR §4): rendered ONLY on a
   resolved right-click while ?aicontext is present — the flag-off
   path creates no menu element and attaches no listeners at all
   (ship-dark). Session 8's inspector overlay replaces this minimal
   affordance. Not color-alone: the outline + background distinguish
   it from page content. */
.ai-context-menu {
  position: fixed; z-index: 60; width: 180px; padding: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 4px 14px rgba(28, 39, 51, 0.18);
}
.ai-context-menu button {
  width: 100%; text-align: left; min-height: 44px;
}

/* AI-context inspector overlay (Session 8, spec §12–§15, §26–§27):
   rendered ONLY while ?aicontext is present AND a resolved
   right-click / Ctrl+Alt+C opened it — the flag-off path creates no
   element and attaches no listeners (ship-dark, DR §4). Layout
   follows the spec §12 sketch trimmed to the ratified pilot scopes. */
.ai-context-inspector {
  position: fixed; z-index: 70; right: 12px; top: 12px;
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); overflow: auto;
  background: var(--card); border: 2px solid var(--accent);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(28, 39, 51, 0.28);
  padding: 12px 14px; font-size: 0.88rem;
}
.ai-ctx-head { display: flex; align-items: center; gap: 10px; }
.ai-ctx-title { margin: 0; font-size: 1rem; flex: 1; }
.ai-ctx-close { min-height: 44px; }
.ai-ctx-breadcrumb { color: var(--muted); margin: 6px 0;
  word-break: break-all; }
.ai-ctx-crumb.unavailable { color: #b3261e; font-style: italic; }
.ai-ctx-sep { margin: 0 4px; }
.ai-ctx-summary { margin: 4px 0 10px; }
.ai-ctx-scopes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.ai-ctx-scope-btn { min-height: 44px; }
.ai-ctx-scope-btn.active { border-color: var(--accent);
  background: #e8f0fe; font-weight: 600; outline: 2px solid var(--accent);
  outline-offset: -2px; }
.ai-ctx-composer-label { display: block; font-weight: 600; margin-top: 8px; }
.ai-ctx-composer { width: 100%; box-sizing: border-box;
  border: 2px dashed var(--accent); border-radius: var(--radius);
  padding: 8px; font: inherit; }
.ai-ctx-note { color: var(--muted); font-size: 0.8rem; margin: 4px 0 8px; }
.ai-ctx-preview-label { font-weight: 600; margin: 8px 0 4px; }
.ai-ctx-preview { background: #f4f6f8; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px; max-height: 260px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: monospace; font-size: 0.78rem; }
.ai-ctx-meta { color: var(--muted); font-size: 0.8rem; }
.ai-ctx-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-ctx-copy { min-height: 44px; }

.demo-panel {
  margin-top: 40px; padding: 14px; border: 2px dashed #c9a227;
  border-radius: var(--radius); background: #fffbea; font-size: 0.9rem;
}
.demo-panel h2 { margin-top: 0; }
.demo-panel select { margin: 4px 0 10px; }
.demo-code { font-family: monospace; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media (max-width: 480px) {
  main { padding: 12px; }
  /* One-column layout: rows of controls stack; every control keeps a
     ≥44px touch target (D6). Code slots stay ≥44px wide. */
  .row { flex-direction: column; align-items: stretch; gap: 8px; }
  .row button, .row input { width: 100%; }
  .code-slots { flex-wrap: wrap; gap: 6px; }
  .code-slots input { width: 44px; height: 48px; font-size: 1.25rem; }
  .contact-row { flex-direction: column; align-items: flex-start; }
  .contact-row .contact-actions { margin-left: 0; width: 100%; }
  .suggestions .suggestion { min-height: 48px; padding: 14px; }
  .timing button { width: 100%; min-height: 56px; }
  .history-item .status { float: none; display: block; margin-top: 4px; }
  button { min-height: 48px; }
  input, textarea, select { font-size: 16px; }   /* prevents iOS zoom-on-focus */
}
