/*
 * Open-Air — Design Tokens
 * Generated from docs/design_concept.md (§2 Typography, §3 Color System).
 * Every app consumes these CSS variables — never hard-code a hex value or font-family
 * in app-level CSS (design_concept.md §8 Governance).
 */

@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/Heebo-Hebrew.de80852899c5.woff2") format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/Heebo-Latin.480b1d24f2aa.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Typography (design_concept.md §2) */
  --font-family-base: 'Heebo', -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-size-display: 2rem;
  --font-size-h1: 1.5rem;
  --font-size-h2: 1.25rem;
  --font-size-h3: 1rem;
  --font-size-body: 0.9375rem;
  --font-size-caption: 0.8125rem;
  --line-height-base: 1.6;

  /* Neutrals & surfaces (design_concept.md §3.1) */
  --color-ink: #1C1B1F;
  --color-ink-muted: #5B5868;
  --color-paper: #FAF8F5;
  --color-surface: #FFFFFF;
  --color-border: #E4DFD8;

  /* Brand (design_concept.md §3.2) */
  --color-primary: #2B2A4C;
  --color-primary-hover: #3A3966;
  --color-accent: #9C6F0F;

  /* Semantic status (design_concept.md §3.3) */
  --color-success: #2E7D4F;
  --color-warning: #B8860B;
  --color-danger: #B3261E;
  --color-info: #2B5F9E;

  /* Org-chart node-category identity colors (design_concept.md §3.7) — used only for the
     Org Chart's per-box top strip, never reused for status/semantic meaning elsewhere */
  --color-node-division: #1F6F78;
  --color-node-field: #5C6B2F;

  /* Task priority colors (design_concept.md §3.8) — used only for ActionItem priority
     badges, a distinct dimension from status (§3.3/§3.4); LOW/MEDIUM stay neutral
     outlines, HIGH gets this one new token, CRITICAL deliberately reuses --color-danger */
  --color-priority-high: #B5651D;

  /* Role / Training-Gate badges (design_concept.md §3.4) — reuse these, never new colors */
  --color-badge-readonly: var(--color-info);
  --color-badge-untrained: var(--color-warning);
  --color-badge-certified: var(--color-success);
  --color-badge-blocked: var(--color-danger);

  /* Audit diff tints (design_concept.md §3.5) */
  --color-diff-added: var(--color-success);
  --color-diff-removed: var(--color-danger);
  --color-diff-changed: var(--color-warning);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
  line-height: var(--line-height-base);
}

h1 { font-size: var(--font-size-display); font-weight: 700; }
h2 { font-size: var(--font-size-h1); font-weight: 700; }
h3 { font-size: var(--font-size-h2); font-weight: 600; }

.oa-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-primary);
  color: #fff;
}
.oa-nav a { color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
.oa-nav a:hover { text-decoration: underline; }
.oa-nav__brand a { font-weight: 700; font-size: var(--font-size-h2); }
.oa-nav__links { display: flex; gap: 1rem; flex: 1; }
.oa-nav__user { display: flex; align-items: center; gap: 0.5rem; font-size: var(--font-size-caption); }
.oa-nav__logout { display: inline; margin: 0; }
.oa-nav .btn--ghost { color: #fff; border: 1px solid rgba(255, 255, 255, 0.5); min-height: auto; padding: 0.3rem 0.7rem; font-size: var(--font-size-caption); }
.oa-nav .btn--ghost:hover { background: rgba(255, 255, 255, 0.15); }
.oa-main { padding: 1.5rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  margin-block: 0.2rem;
  border-radius: 999px;
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: #fff;
}
.badge--readonly { background: var(--color-badge-readonly); }
.badge--untrained { background: var(--color-badge-untrained); }
.badge--certified { background: var(--color-badge-certified); }
.badge--blocked { background: var(--color-badge-blocked); }

/* Priority badges (design_concept.md §3.8) — outlined, not filled, so they read as a
   secondary signal next to a status badge rather than competing with it for attention. */
.badge--priority-low,
.badge--priority-medium,
.badge--priority-high,
.badge--priority-critical {
  background: transparent;
  border: 1px solid currentColor;
  font-weight: 700;
}
.badge--priority-low { color: var(--color-ink-muted); }
.badge--priority-medium { color: var(--color-ink); }
.badge--priority-high { color: var(--color-priority-high); }
.badge--priority-critical { color: var(--color-danger); }

.card ul { margin: 0; padding-inline-start: 1.1rem; }
.card li { margin-bottom: 0.5rem; line-height: 1.8; }
.card li:last-child { margin-bottom: 0; }

/* Cards (design_concept.md §4) */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.card + .card { margin-top: 0; }
.card__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem 0;
  font-size: var(--font-size-h2);
  font-weight: 600;
  color: var(--color-primary);
}
.card__title .oa-icon { color: var(--color-accent); }

/* Buttons (design_concept.md §4) — Primary / Secondary / Ghost / Destructive */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--secondary { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn--secondary:hover { background: var(--color-paper); }
.btn--ghost { background: transparent; color: var(--color-ink); border-color: transparent; }
.btn--ghost:hover { background: var(--color-paper); }
.btn--destructive { background: var(--color-danger); color: #fff; }
.btn--destructive:hover { filter: brightness(0.9); }

/* Icons (design_concept.md §3.6) — self-hosted Lucide SVGs, sized via the {% icon %} tag;
   color always inherited via currentColor, never hard-coded per icon. */
.oa-icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.oa-icon--muted { color: var(--color-ink-muted); }

/* Tables (design_concept.md §4) */
.oa-table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
.oa-table th {
  text-align: start;
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-ink-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
}
.oa-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-body);
}
.oa-table tbody tr:nth-child(even) { background: var(--color-paper); }

/* Graphic stat bars (e.g. System Status §10.1) — thresholds reuse the semantic status
   colors (§3.3) rather than inventing new ones, per "color carries meaning" (§1.2). */
.stat-grid { display: flex; flex-direction: column; gap: 1rem; }
.stat-bar__label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-body);
  margin-bottom: 0.35rem;
}
.stat-bar__label span:last-child { color: var(--color-ink-muted); font-size: var(--font-size-caption); }
.stat-bar__track {
  height: 10px;
  border-radius: 999px;
  background: var(--color-paper);
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.stat-bar__fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.stat-bar__fill--ok { background: var(--color-success); }
.stat-bar__fill--warn { background: var(--color-warning); }
.stat-bar__fill--danger { background: var(--color-danger); }
.stat-bar__fill--info { background: var(--color-info); }
.stat-bar--plain .stat-bar__label { margin-bottom: 0; }

/* Aligned key/value service list (e.g. System Status §10.1) — flex rows instead of a
   plain <ul>, so names and badges line up regardless of text length. */
.service-list { list-style: none; margin: 0; padding: 0; }
.service-list__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}
.service-list__row:last-child { border-bottom: none; }

/* Three-column dashboard layout (e.g. System Status §10.1) — a wide primary column
   (people/data), a fixed-width "widget" column (compact stat panels shouldn't stretch
   full-bleed), and a flexible third column. Collapses to one column on narrow screens. */
.oa-dashboard-grid {
  display: grid;
  grid-template-columns: 50% 400px 1fr;
  gap: 1rem;
  align-items: start;
}
.oa-dashboard-grid__fixed { max-width: 400px; }
@media (max-width: 900px) {
  .oa-dashboard-grid { grid-template-columns: 1fr; }
  .oa-dashboard-grid__fixed { max-width: none; }
}

/* Modal (native <dialog>) — used by any in-app editing UI (e.g. Org Chart §6.2 live
   editing). One implementation, shared across apps; don't hand-roll another modal. */
.oa-modal {
  width: min(480px, 92vw);
  padding: 0;
  border: none;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.oa-modal::backdrop { background: rgba(28, 27, 31, 0.5); }
.oa-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary);
  color: #fff;
  border-radius: 10px 10px 0 0;
}
.oa-modal__header h2 { margin: 0; font-size: var(--font-size-h2); }
.oa-modal__header .btn--ghost { color: #fff; }
.oa-modal__body { padding: 1rem; max-height: 70vh; overflow-y: auto; }

/* Form fields — used inside modals and any other in-app (non-admin) edit form. */
.oa-form-field { margin-bottom: 1rem; text-align: start; }
.oa-form-field label { display: block; font-size: var(--font-size-caption); font-weight: 600; margin-bottom: 0.25rem; }
.oa-form-input,
.oa-form-field input[type="text"],
.oa-form-field input[type="number"],
.oa-form-field select,
.oa-form-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
}
.oa-form-field input[type="checkbox"] { margin-inline-end: 0.4rem; }
.oa-form-help { color: var(--color-ink-muted); font-size: var(--font-size-caption); margin: 0.25rem 0 0; }
.oa-form-error { color: var(--color-danger); font-size: var(--font-size-caption); margin: 0.25rem 0 0; }
.oa-edit-form__actions { display: flex; gap: 0.5rem; justify-content: flex-start; }

.oa-login {
  max-width: 320px;
  margin: 10vh auto;
  padding: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-align: center;
}
.oa-login h1 { color: var(--color-primary); }
.oa-login__field { text-align: start; margin-bottom: 1rem; }
.oa-login__field label { display: block; font-size: var(--font-size-caption); margin-bottom: 0.25rem; }
.oa-login__field input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-family-base);
}
.oa-login .btn { width: 100%; justify-content: center; }
