/* Ensign Career Coach: app patterns (chat shell, messages, composer, fields).
   Extends ecc-components.base.css (the five components mirrored from Claude Design).
   Reads ecc-tokens.css custom properties only. Load order:
   ecc-tokens.css -> ecc-ces-compat.css -> ecc-components.base.css -> ecc-app.css -> the app's own CSS */

/* ---------- Page ---------- */
body.ecc {
  margin: 0;
  background: var(--surface-sunken);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  max-width: 100vw;
  overflow-x: hidden;
}

/* ---------- Shell: fixed left rail + dominant chat canvas ---------- */
.ecc-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100dvh;
  min-width: 0;
}
.ecc-sidebar {
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.ecc-sidebar-label {
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-eyebrow);
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  margin: var(--space-4) 0 0;
}
.ecc-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ---------- Feed: fills the width up to the gutter, no 65ch cap ---------- */
.ecc-feed {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6) var(--gutter);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.ecc-msg { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-body); line-height: var(--leading-body); }
.ecc-msg-assistant {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  max-width: 100%;
}
.ecc-msg-name { font-size: var(--text-caption); font-weight: 700; color: var(--brand); margin: 0 0 var(--space-2); }
.ecc-msg-user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--brand);
  color: #ffffff;
  border-radius: 14px 14px 4px 14px; /* one-off "who said this" cue from the design system */
  padding: var(--space-4) var(--space-5);
}
.ecc-msg-user .ecc-msg-name { color: #d1e7dd; }

/* ---------- Composer ---------- */
.ecc-composer {
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  padding: var(--space-4) var(--gutter) var(--space-5);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
  min-width: 0;
}
.ecc-composer-label { flex: 1 1 100%; font-size: var(--text-caption); font-weight: 600; color: var(--ink-muted); }

/* ---------- Text fields: one look everywhere (chat, forms, feedback, intake) ---------- */
.ecc-field,
.ecc-composer textarea {
  flex: 1 1 240px;
  min-width: 0;
  min-height: var(--touch-min);
  padding: 14px 18px;
  background: var(--input-fill);
  color: var(--ink);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  box-shadow: var(--shadow-card);
  resize: vertical;
}
.ecc-field::placeholder,
.ecc-composer textarea::placeholder { color: var(--ink-muted); opacity: 1; }
.ecc-field:focus,
.ecc-composer textarea:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: var(--shadow-focus); /* replaces shadow-card, never stacks */
}
.ecc-field:focus-visible,
.ecc-composer textarea:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
.ecc-field[aria-invalid="true"] { border-color: var(--danger-text); }
.ecc-field-error { color: var(--danger-text); font-size: var(--text-caption); }
input.ecc-field { border-radius: var(--radius-md); resize: none; } /* single-line inputs are controls: radius-md */

/* ---------- Chip row: single line, scroll buttons, never a bare scrollbar ---------- */
.ecc-chip-rail { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.ecc-chip-track { display: flex; gap: var(--space-2); overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; min-width: 0; flex: 1; }
.ecc-chip-track::-webkit-scrollbar { display: none; }
.ecc-chip-scroll { flex: 0 0 var(--touch-min); height: var(--touch-min); border-radius: var(--radius-pill); border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.ecc-chip-scroll:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

/* ---------- Toast ---------- */
.ecc-toast { position: fixed; right: var(--space-6); bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); background: var(--surface); border: 1.5px solid var(--success-border); color: var(--success-text); border-radius: var(--radius-lg); box-shadow: var(--shadow-toast); padding: var(--space-3) var(--space-5); font-size: var(--text-control); font-weight: 600; }

/* ---------- Breakpoints ---------- */
@media (max-width: 899.98px) {
  .ecc-shell { grid-template-columns: minmax(0, 1fr); }
  .ecc-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: min(88vw, 320px);
    padding-top: calc(var(--space-5) + env(safe-area-inset-top, 0px));
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow-toast);
    overflow-y: auto;
  }
  .ecc-sidebar.is-open { transform: none; }
  .ecc-scrim { position: fixed; inset: 0; z-index: 30; background: var(--overlay); }
  .ecc-scrim[hidden] { display: none; }
}
@media (min-width: 900px) { .ecc-menu-button, .ecc-scrim { display: none; } }
@media (max-width: 639.98px) {
  :root { --gutter: 16px; }
  .ecc-composer textarea, .ecc-composer .ecc-field { flex-basis: 100%; }
  .ecc-composer .ecc-btn { flex: 1 1 100%; }
  .ecc-msg-assistant { padding: 14px 16px; }
}
@media (max-width: 375px) {
  :root { --gutter: 12px; }
  .ecc-msg-user { max-width: 90%; }
}

/* ---------- Windows High Contrast ---------- */
@media (forced-colors: active) {
  .ecc-field, .ecc-composer textarea { border-color: ButtonText; }
  .ecc-field:focus-visible, .ecc-composer textarea:focus-visible { outline-color: Highlight; }
  .ecc-pill, .ecc-chip { border-color: ButtonText; }
}
