/* ==========================================================================
   Fynex Network Design Tokens — aligned with Tiosan Support Copilot UI/UX
   Self-hosted Inter + clean emerald/mint-slate surface hierarchy
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/inter-greek.woff2) format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Crisp Tiosan Surfaces */
  --bg-main: #ffffff;
  --bg-subtle: #f4f6f5;
  --bg-thread: #f5f7f6;
  --bg-hover: #edf1ef;
  --bg-user-bubble: #eef2f0;
  --bg-composer: #ffffff;
  --bg-popover: #ffffff;

  /* Borders & Dividers */
  --border: #dde3e0;
  --border-focus: #b9c6c1;

  /* Typography (WCAG AA on white and tinted surfaces) */
  --text-primary: #12211b;
  --text-secondary: #43524c;
  --text-muted: #5a6963;

  /* Emerald Brand Accent */
  --brand: #0b6e4f;
  --brand-strong: #075e42;
  --brand-soft: #e7f4ee;
  --brand-border: #bfe3d3;

  /* Amber (Warnings / Retakes / Review) */
  --kb-accent: #7a4f00;
  --kb-soft: #fff7e0;
  --kb-border: #ecd28f;

  /* Danger (Errors / Blocking Flags) */
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;

  /* Blue / Slate (Collecting / Active) */
  --slate: #1a47a0;
  --slate-soft: #e8f0fe;
  --slate-line: #c5d6fa;

  /* Semantic Aliases for Shared Components */
  --paper: var(--bg-subtle);
  --paper-subtle: var(--bg-hover);
  --card: var(--bg-main);
  --ink: var(--text-primary);
  --ink-soft: var(--text-secondary);
  --muted: var(--text-muted);
  --line: var(--border);
  --line-strong: var(--border-focus);
  --accent: var(--brand);
  --accent-deep: var(--brand-strong);
  --accent-soft: var(--brand-soft);
  --sage: var(--brand);
  --sage-soft: var(--brand-soft);
  --sage-line: var(--brand-border);
  --amber: var(--kb-accent);
  --amber-soft: var(--kb-soft);
  --amber-line: var(--kb-border);
  --danger-line: var(--danger-border);
  --overlay: rgba(10, 20, 16, 0.48);

  /* Radii & Shadows */
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius: 14px;
  --radius-card: 14px;
  --shadow-sm: 0 1px 4px rgba(18, 33, 27, 0.05);
  --shadow-md: 0 6px 24px rgba(18, 33, 27, 0.08);
  --shadow-lg: 0 16px 48px rgba(18, 33, 27, 0.18);
  --shadow-composer: 0 2px 12px rgba(18, 33, 27, 0.06);
  --shadow-popover: 0 8px 30px rgba(18, 33, 27, 0.14);

  --max-col-width: 720px;
  --hdr-h: 58px;

  /* v5.9 SOTA layer */
  --brand-grad: linear-gradient(135deg, #0e7d57 0%, #0b6e4f 55%, #075e42 100%);
  --hero-grad: linear-gradient(135deg, #eef7f2 0%, #ffffff 58%, #f2f8f5 100%);
  --thread-grad: linear-gradient(180deg, #f7f9f8 0%, #f2f5f3 100%);
  --radius-xl: 20px;
  --shadow-bubble: 0 1px 2px rgba(18,33,27,.05), 0 8px 24px rgba(18,33,27,.05);
  --shadow-float: 0 4px 14px rgba(18,33,27,.08), 0 16px 40px rgba(11,110,79,.12);
  --touch: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  /* Motion durations (SOTA mobile-first scale) */
  --dur-instant: 80ms;
  --dur-fast: 140ms;
  --dur-med: 220ms;
  --dur-slow: 340ms;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }
::selection { background: rgba(11, 110, 79, 0.2); }
html { scroll-behavior: smooth; }
/* iOS inflates text after a rotation unless told not to. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, input, select, textarea, .doc-item, .kpi-card { touch-action: manipulation; }
* { scrollbar-width: thin; scrollbar-color: #c3d2cb transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: #c3d2cb; border-radius: 99px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
:focus-visible { outline: 3px solid rgba(11, 110, 79, 0.5); outline-offset: 2px; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }

/* ==========================================================================
   SOTA mobile-first motion + polish system (vanilla CSS, no build step)
   Tokens above (--dur-*, --ease-*, --shadow-*) drive every transition below.
   All show/hide motion uses transform + opacity only (GPU, no layout thrash).
   ========================================================================== */

/* ---- Keyframes (shared names; dashboard.css mirrors them standalone) ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* GPU hint for overlay primitives (concrete components live in their files) */
.sheet, .pop, .toast, .modal, .modal-card {
  will-change: transform, opacity;
}

/* Coarse-pointer floor: icon buttons + pills never drop below 44px */
@media (pointer: coarse) {
  .icon-btn, .btn.icon, .msg-more, .pill, .pillbtn, .send-pill, .chip {
    min-height: var(--touch, 44px);
  }
  .icon-btn, .btn.icon, .msg-more {
    min-width: var(--touch, 44px);
  }
}

/* Reduced motion: hard stop on every keyframe + transition in this system */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-name: none !important;
    transition-property: none !important;
  }
}
