/**
 * OSM Flow Design System — foundation layer.
 *
 * Source of truth: OSM_FLOW_DESIGN_BIBLE.md (§3 tokens, §8 components,
 * §9 motion, §11 accessibility). This file is intentionally IDENTICAL in
 * barber-master-platform/assets/css/ and barber-client-platform/assets/css/;
 * tools/run-tests.ps1 enforces byte parity. Change both copies together.
 *
 * Scope discipline: every rule is namespaced under .osm-* (plus :root tokens
 * and @font-face) so loading this file can never restyle WordPress admin or
 * an existing surface by accident. Adoption is opt-in per element.
 */

/* ---------- §3.2 Typography: self-hosted Instrument family (OFL) ---------- */

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/instrument-serif.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;
}

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/instrument-serif-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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/instrument-sans.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;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/instrument-sans-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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* -------------------------- §3.1 / §3.3 / §9 tokens ------------------------ */

:root {
  /* Color — Master / application palette (§3.1). */
  --osm-ink-950: #101112;
  --osm-ink-800: #2a2c2e;
  --osm-bone-100: #f5f0e8;
  --osm-surface-0: #fffdf9;
  --osm-mist-200: #e7e3dc;
  --osm-mist-300: #d8d3cb;
  --osm-teal-600: #0b6b63;
  --osm-teal-700: #064c47;
  --osm-teal-100: #dff1ed;
  --osm-brass-500: #b4864e;
  --osm-umber-600: #75563a;
  --osm-success-600: #16804b;
  --osm-warning-700: #a56300;
  --osm-error-700: #b42318;
  --osm-info-700: #2e5aac;
  --osm-muted-text: #64615d;
  --osm-app-canvas: #f5f5f3;

  /* Type (§3.2). Arabic admin falls back to high-quality system Arabic faces. */
  --osm-font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --osm-font-ui: 'Instrument Sans', 'Segoe UI', system-ui, -apple-system, Tahoma, sans-serif;

  /* Geometry (§3.3). */
  --osm-radius-input: 10px;
  --osm-radius-button: 12px;
  --osm-radius-card: 16px;
  --osm-radius-modal: 20px;
  --osm-border: 1px solid var(--osm-mist-200);
  --osm-border-strong: 1px solid var(--osm-mist-300);
  --osm-elevation-1: 0 8px 20px rgba(16, 17, 18, 0.06);
  --osm-elevation-2: 0 16px 40px rgba(16, 17, 18, 0.10);

  /* Motion (§9.1). */
  --osm-ease-out: cubic-bezier(0, 0, 0.2, 1);
  --osm-ease-panel: cubic-bezier(0.2, 0.8, 0.2, 1);
  --osm-time-hover: 150ms;
  --osm-time-tip: 180ms;
  --osm-time-tab: 220ms;
  --osm-time-modal: 280ms;
  --osm-time-section: 360ms;

  /* Focus (§11.1). */
  --osm-focus-ring: 0 0 0 2px var(--osm-surface-0), 0 0 0 4px var(--osm-teal-600);
}

/* ------------------------------ Base helpers ------------------------------ */

.osm-eyebrow {
  font-family: var(--osm-font-ui);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--osm-teal-600);
}

.osm-display {
  font-family: var(--osm-font-display);
  font-weight: 400;
  color: var(--osm-ink-950);
  line-height: 1.04;
}

.osm-body {
  font-family: var(--osm-font-ui);
  font-size: 17px;
  line-height: 1.55;
  color: var(--osm-ink-800);
}

.osm-muted { color: var(--osm-muted-text); }
.osm-num { font-variant-numeric: tabular-nums; }

/* Visible focus everywhere the system is adopted (§11.1). */
.osm-btn:focus-visible,
.osm-input:focus-visible,
.osm-tab:focus-visible,
.osm-card--interactive:focus-visible,
.osm-icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--osm-focus-ring);
}

/* ------------------------------ §8.1 Buttons ------------------------------ */

.osm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding-block: 0;
  padding-inline: 16px;
  border-radius: var(--osm-radius-button);
  border: 1px solid transparent;
  font-family: var(--osm-font-ui);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--osm-time-hover) var(--osm-ease-out),
              color var(--osm-time-hover) var(--osm-ease-out),
              transform var(--osm-time-hover) var(--osm-ease-out);
}

.osm-btn:active { transform: translateY(1px); }
.osm-btn[disabled], .osm-btn.is-disabled { opacity: 0.45; pointer-events: none; }

.osm-btn--primary { background: var(--osm-teal-600); color: #fff; }
.osm-btn--primary:hover { background: var(--osm-teal-700); color: #fff; }

.osm-btn--secondary { background: transparent; border-color: var(--osm-teal-600); color: var(--osm-teal-600); }
.osm-btn--secondary:hover { background: var(--osm-teal-100); color: var(--osm-teal-700); }

.osm-btn--tertiary { background: transparent; color: var(--osm-teal-600); min-height: 40px; padding-inline: 4px; }
.osm-btn--tertiary:hover { text-decoration: underline; }

.osm-btn--destructive { background: var(--osm-error-700); color: #fff; }
.osm-btn--destructive:hover { background: #8f1c13; color: #fff; }

.osm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--osm-radius-input);
  border: var(--osm-border);
  background: var(--osm-surface-0);
  color: var(--osm-ink-800);
  cursor: pointer;
}

/* Loading state keeps width and swaps label for a spinner (§8.1). */
.osm-btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.osm-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: osm-spin 700ms linear infinite;
}
.osm-btn--secondary.is-loading::after { border-color: rgba(11, 107, 99, 0.3); border-top-color: var(--osm-teal-600); }

@keyframes osm-spin { to { transform: rotate(360deg); } }

/* --------------------------- §8.2 Form controls --------------------------- */

.osm-field { display: block; margin-block-end: 16px; }

.osm-field > .osm-label {
  display: block;
  font-family: var(--osm-font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--osm-ink-950);
  margin-block-end: 6px;
}

.osm-input,
.osm-select,
.osm-textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: var(--osm-border-strong);
  border-radius: var(--osm-radius-input);
  background: var(--osm-surface-0);
  font-family: var(--osm-font-ui);
  font-size: 15px;
  color: var(--osm-ink-950);
}

.osm-textarea { min-height: 112px; resize: vertical; }

.osm-input:focus, .osm-select:focus, .osm-textarea:focus {
  outline: none;
  border-color: var(--osm-teal-600);
  box-shadow: 0 0 0 1px var(--osm-teal-600);
}

.osm-help { font-size: 13px; color: var(--osm-muted-text); margin-block-start: 6px; }

.osm-field.has-error .osm-input,
.osm-field.has-error .osm-select,
.osm-field.has-error .osm-textarea { border: 2px solid var(--osm-error-700); }

.osm-error-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--osm-error-700);
  margin-block-start: 6px;
}

/* --------------------------- §8.3 Cards & metrics -------------------------- */

.osm-card {
  background: var(--osm-surface-0);
  border: var(--osm-border);
  border-radius: var(--osm-radius-card);
  padding: 20px;
}

.osm-card--interactive { cursor: pointer; transition: transform var(--osm-time-hover) var(--osm-ease-out), box-shadow var(--osm-time-hover) var(--osm-ease-out); }
.osm-card--interactive:hover { transform: translateY(-2px); box-shadow: var(--osm-elevation-2); }

.osm-metric { min-height: 116px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.osm-metric .osm-metric-value { font-family: var(--osm-font-ui); font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--osm-ink-950); }
.osm-metric .osm-metric-label { font-size: 14px; color: var(--osm-ink-800); }
.osm-metric .osm-metric-compare { font-size: 13px; color: var(--osm-muted-text); }

/* ------------------------------- §8.4 Tables ------------------------------- */

.osm-table { width: 100%; border-collapse: collapse; background: var(--osm-surface-0); border: var(--osm-border); border-radius: var(--osm-radius-card); overflow: hidden; }
.osm-table thead th {
  height: 44px;
  padding-inline: 14px;
  text-align: start;
  font-family: var(--osm-font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--osm-muted-text);
  border-block-end: var(--osm-border);
  background: var(--osm-surface-0);
}
.osm-table tbody td { height: 56px; padding-inline: 14px; border-block-end: var(--osm-border); font-size: 14px; color: var(--osm-ink-800); }
.osm-table tbody tr:last-child td { border-block-end: none; }
.osm-table tbody tr:hover { background: rgba(11, 107, 99, 0.04); }
.osm-table .osm-td-num { text-align: end; font-variant-numeric: tabular-nums; }

/* -------------------------- §8.5 Tabs & badges ----------------------------- */

.osm-tabs { display: flex; gap: 20px; border-block-end: var(--osm-border); }
.osm-tab {
  appearance: none;
  background: none;
  border: none;
  border-block-end: 2px solid transparent;
  padding: 10px 2px 12px;
  font-family: var(--osm-font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--osm-muted-text);
  cursor: pointer;
}
.osm-tab[aria-selected='true'], .osm-tab.is-active { color: var(--osm-ink-950); border-color: var(--osm-teal-600); }

.osm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
}
.osm-badge--success { background: #e6f4ea; color: var(--osm-success-600); }
.osm-badge--warning { background: #fff4e0; color: var(--osm-warning-700); }
.osm-badge--error { background: #fdecea; color: var(--osm-error-700); }
.osm-badge--info { background: #eef2ff; color: var(--osm-info-700); }
.osm-badge--neutral { background: var(--osm-mist-200); color: var(--osm-ink-800); }

/* --------------------- §8.5 Dialog & drawer shells ------------------------- */

.osm-backdrop { position: fixed; inset: 0; background: rgba(16, 17, 18, 0.36); z-index: 100000; }

.osm-dialog {
  position: fixed;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--osm-surface-0);
  border-radius: var(--osm-radius-modal);
  box-shadow: var(--osm-elevation-2);
  padding: 24px;
  z-index: 100001;
}
[dir='rtl'] .osm-dialog { transform: translate(50%, -50%); }
.osm-dialog--wide { width: min(760px, calc(100vw - 32px)); }

.osm-drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(480px, 100vw);
  background: var(--osm-surface-0);
  box-shadow: var(--osm-elevation-2);
  z-index: 100001;
  overflow: auto;
  padding: 24px;
  transform: translateX(0);
}

/* -------------------- Skeleton / empty state (§9.2, D.1) ------------------- */

.osm-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--osm-mist-200);
  border-radius: var(--osm-radius-input);
  min-height: 14px;
}
.osm-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: osm-shimmer 1.4s var(--osm-ease-out) infinite;
}
@keyframes osm-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.osm-empty {
  text-align: center;
  padding: 40px 24px;
  border: 1px dashed var(--osm-mist-300);
  border-radius: var(--osm-radius-card);
  background: var(--osm-surface-0);
}
.osm-empty .osm-empty-title { font-family: var(--osm-font-ui); font-weight: 600; font-size: 16px; color: var(--osm-ink-950); margin: 0 0 6px; }
.osm-empty .osm-empty-body { font-size: 14px; color: var(--osm-muted-text); margin: 0 0 16px; }

/* ---------------------- §9 / §11 reduced-motion guard ---------------------- */

@media (prefers-reduced-motion: reduce) {
  .osm-btn,
  .osm-card--interactive,
  .osm-skeleton::after,
  .osm-btn.is-loading::after {
    transition: none !important;
    animation: none !important;
  }
  .osm-card--interactive:hover { transform: none; }
}
