/**
 * FM-DS-001 — Core component primitives
 * Applied under body.fm-ds-001 / html.fm-ds-001
 */

/* Typography utilities */
.fm-text-display { font-family: var(--fm-font-display); font-size: var(--fm-text-display); font-weight: 700; letter-spacing: var(--fm-ls-title); line-height: 1.2; color: var(--fm-green-800); }
.fm-text-page-title { font-family: var(--fm-font-display); font-size: var(--fm-text-page-title); font-weight: 700; letter-spacing: var(--fm-ls-title); line-height: 1.2; color: var(--fm-green-800); margin: 0 0 var(--fm-space-1); }
.fm-text-section { font-family: var(--fm-font-display); font-size: var(--fm-text-section); font-weight: 650; color: var(--fm-green-800); margin: 0 0 var(--fm-space-2); }
.fm-text-card { font-family: var(--fm-font-body); font-size: var(--fm-text-card); font-weight: 650; color: var(--fm-neutral-900); }
.fm-text-body { font-family: var(--fm-font-body); font-size: var(--fm-text-body); line-height: var(--fm-lh-body); color: var(--fm-neutral-900); }
.fm-text-body-sm { font-size: var(--fm-text-body-sm); color: var(--fm-neutral-700); }
.fm-text-label { font-size: var(--fm-text-label); font-weight: 700; letter-spacing: var(--fm-ls-label); text-transform: uppercase; color: var(--fm-neutral-500); }
.fm-text-caption, .fm-text-meta { font-size: var(--fm-text-meta); color: var(--text-soft, #5c6b62); }
.fm-text-code { font-family: var(--fm-font-mono); font-size: var(--fm-text-code); }

/* Page anatomy */
.fm-page-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--fm-space-4); align-items: flex-end; padding: var(--fm-space-4) var(--fm-space-5) var(--fm-space-3); background: transparent; border: 0; box-shadow: none; }
.fm-page-header__title { font-family: var(--fm-font-display); font-size: var(--fm-text-page-title); font-weight: 700; color: var(--fm-green-800); margin: 0 0 var(--fm-space-1); letter-spacing: var(--fm-ls-title); }
.fm-page-header__purpose { font-size: 14px; color: var(--text-soft, #5c6b62); max-width: 56ch; margin: 0; line-height: 1.45; }
.fm-page-header__meta { font-size: var(--fm-text-meta); color: var(--fm-neutral-500); margin-top: var(--fm-space-1); }
.fm-page-header__actions { display: flex; gap: var(--fm-space-2); align-items: center; flex-wrap: wrap; }
.fm-page-header__actions .btn-ghost:not(.fm-btn-secondary) { opacity: .9; }

body.fm-ds-001 .illus-premium-header,
body.fm-ds-001 .apps-premium-header,
body.fm-ds-001 .policies-premium-header,
body.fm-ds-001 .tasks-premium-header,
body.fm-ds-001 .comm-premium-header,
body.fm-ds-001 .prod-banner,
body.fm-ds-001 .rc-head {
  background: transparent !important;
  box-shadow: none !important;
  color: inherit !important;
  padding: var(--fm-space-4) var(--fm-space-5) var(--fm-space-3) !important;
  border-radius: 0 !important;
}
body.fm-ds-001 .illus-premium-title,
body.fm-ds-001 .apps-premium-title,
body.fm-ds-001 .policies-premium-title,
body.fm-ds-001 .tasks-premium-title,
body.fm-ds-001 .comm-premium-title,
body.fm-ds-001 .prod-banner h2,
body.fm-ds-001 .rc-head h1 {
  font-family: var(--fm-font-display) !important;
  font-size: var(--fm-text-page-title) !important;
  color: var(--fm-green-800) !important;
  margin: 0 0 4px !important;
}
body.fm-ds-001 .illus-premium-gold-line,
body.fm-ds-001 .apps-premium-gold-line,
body.fm-ds-001 .policies-premium-gold-line,
body.fm-ds-001 .tasks-premium-gold-line,
body.fm-ds-001 .comm-premium-gold-line,
body.fm-ds-001 .dcc-gold-line {
  display: none !important;
}

/* Buttons */
.fm-btn,
body.fm-ds-001 .btn {
  min-height: var(--fm-control-compact);
  border-radius: var(--fm-radius-sm);
  font-family: var(--fm-font-body);
  font-weight: 600;
  font-size: 13px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.fm-btn-primary,
body.fm-ds-001 .btn-primary {
  background: var(--fm-green-700) !important;
  color: #fff !important;
  border: 1px solid transparent !important;
}
.fm-btn-secondary,
body.fm-ds-001 .btn-ghost {
  background: #fff !important;
  color: var(--fm-green-800) !important;
  border: 1px solid var(--fm-border) !important;
}
.fm-btn-tertiary {
  background: transparent;
  border: 0;
  color: var(--fm-green-700);
  text-decoration: underline;
  min-height: auto;
  padding: 4px 0;
}
.fm-btn-danger { background: #fff; color: var(--fm-danger); border: 1px solid rgba(180, 35, 42, .35); }
body.fm-ds-001 .btn:focus-visible,
body.fm-ds-001 .fm-btn:focus-visible {
  outline: 2px solid var(--fm-focus);
  outline-offset: 2px;
}

/* Status chips */
.fm-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: var(--fm-radius-pill);
  font-size: 11px;
  font-weight: 650;
  border: 1px solid var(--fm-border);
  background: var(--fm-neutral-25);
  color: var(--fm-neutral-900);
  text-transform: none;
}
.fm-chip--info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.fm-chip--success { background: #e5f4e9; border-color: #a7f3d0; color: var(--fm-success); }
.fm-chip--warning { background: #fff8e8; border-color: #fde68a; color: var(--fm-warning); }
.fm-chip--danger { background: #fde8e8; border-color: #fecaca; color: var(--fm-danger); }
.fm-chip--neutral { background: var(--fm-neutral-100); color: var(--fm-neutral-700); }
.fm-chip__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Metric inline / summary strip */
.fm-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fm-space-2);
  margin: 0 0 var(--fm-space-4);
}
.fm-metric-inline {
  border: 1px solid var(--fm-border);
  background: var(--fm-surface);
  border-radius: var(--fm-radius-md);
  padding: var(--fm-space-2) var(--fm-space-3);
  min-width: 96px;
  text-align: start;
}
.fm-metric-inline .n { display: block; font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--fm-green-800); }
.fm-metric-inline .l { font-size: 11px; color: var(--text-soft); }
.fm-metric-inline.is-alert .n { color: var(--fm-danger); }

/* Filter bar */
.fm-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fm-space-2);
  align-items: center;
  padding: var(--fm-space-3);
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-md);
  margin: 0 0 var(--fm-space-4);
}
.fm-filter-bar input,
.fm-filter-bar select {
  min-height: var(--fm-control-compact);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-sm);
  padding: 0 10px;
  background: #fff;
  font-size: 13px;
}

/* Queue / table */
.fm-queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--fm-space-2); }
.fm-queue__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--fm-space-3);
  padding: var(--fm-space-3) var(--fm-space-4);
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-md);
}
.fm-queue__title { font-size: 14.5px; font-weight: 650; color: var(--fm-green-800); margin: 0 0 2px; }
.fm-queue__sub { font-size: 12.5px; color: var(--text-soft); margin: 0 0 4px; }
.fm-table { width: 100%; border-collapse: collapse; background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-md); overflow: hidden; }
.fm-table th, .fm-table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--fm-border); font-size: 13px; }
.fm-table th { background: var(--fm-neutral-25); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--fm-neutral-500); }
.fm-table tr:hover td { background: var(--fm-neutral-25); }
.fm-table tr:focus-within td { outline: 2px solid var(--fm-focus); outline-offset: -2px; }

/* States */
.fm-empty, .fm-loading, .fm-error {
  padding: var(--fm-space-6) var(--fm-space-5);
  text-align: center;
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-md);
}
.fm-empty h3, .fm-error h3 { font-family: var(--fm-font-display); margin: 0 0 6px; color: var(--fm-green-800); }
.fm-empty p, .fm-error p, .fm-loading p { margin: 0 0 12px; color: var(--text-soft); font-size: 13.5px; }
.fm-skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eef4f0, #f7faf8, #eef4f0); background-size: 200% 100%; animation: fm-skel 1.2s ease infinite; }
@keyframes fm-skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Drawer / modal primitives */
.fm-drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(420px, 100vw);
  background: #fff; box-shadow: var(--fm-shadow-overlay); z-index: 80;
  transform: translateX(105%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
html[dir="rtl"] .fm-drawer { transform: translateX(-105%); }
.fm-drawer.is-open { transform: translateX(0); }
.fm-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 35, 24, .35); z-index: 90; }
.fm-modal { position: fixed; inset: 0; margin: auto; width: min(520px, calc(100vw - 32px)); max-height: min(80vh, 720px); overflow: auto; background: #fff; border-radius: var(--fm-radius-lg); box-shadow: var(--fm-shadow-overlay); z-index: 91; padding: var(--fm-space-5); }

/* Tabs / stepper */
.fm-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--fm-space-3); }
.fm-tabs button { border: 1px solid var(--fm-border); background: #fff; border-radius: var(--fm-radius-pill); padding: 5px 12px; font-size: 12px; cursor: pointer; }
.fm-tabs button[aria-selected="true"], .fm-tabs button.active { background: var(--fm-green-700); color: #fff; border-color: transparent; }
.fm-stepper { display: flex; gap: 8px; flex-wrap: wrap; }
.fm-stepper__step { font-size: 12px; padding: 4px 10px; border-radius: var(--fm-radius-pill); background: var(--fm-neutral-100); color: var(--fm-neutral-700); }
.fm-stepper__step.is-current { background: var(--fm-green-700); color: #fff; }
.fm-stepper__step.is-complete { background: #e5f4e9; color: var(--fm-success); }

/* Shell refinements */
body.fm-ds-001 #sidebar {
  background: linear-gradient(180deg, var(--fm-green-900) 0%, var(--fm-green-800) 100%);
}
body.fm-ds-001 #sidebar .sb-section-label {
  padding: 14px 12px 4px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .55;
  font-weight: 700;
}
body.fm-ds-001 #sidebar .sb-item { min-height: var(--fm-control-compact); border-radius: 8px; margin: 1px 8px; }
body.fm-ds-001 #sidebar .sb-item.active {
  background: rgba(116, 198, 157, .14);
  box-shadow: inset 3px 0 0 var(--fm-green-500);
}
html[dir="rtl"] body.fm-ds-001 #sidebar .sb-item.active { box-shadow: inset -3px 0 0 var(--fm-green-500); }
body.fm-ds-001 #tb-role-badge,
body.fm-ds-001 .fm-demo-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px;
  border-radius: var(--fm-radius-pill); background: var(--fm-gold-100);
  border: 1px solid rgba(201, 184, 130, .55); color: #6a5414;
}
body.fm-ds-001 .tb-mode { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }

/* No marketing after login */
body.fm-ds-001.fma-agent-workspace #fma-applicant-shell-header,
body.fm-ds-001.fma-agent-workspace #fma-applicant-entry-banner,
body.fm-ds-001.fma-agent-workspace .fma-applicant-status-block,
body.fm-ds-001.fma-agent-workspace [data-testid="fma-applicant-title"] {
  display: none !important;
}

/* Specimen helpers */
.fm-specimen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.fm-specimen-card { background: #fff; border: 1px solid var(--fm-border); border-radius: var(--fm-radius-md); padding: 16px; }
.fm-swatch { height: 40px; border-radius: 8px; border: 1px solid rgba(0,0,0,.08); margin-bottom: 6px; }

@media (max-width: 900px) {
  .fm-page-header { padding: var(--fm-space-3); }
  .fm-queue__item { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  body.fm-ds-001 #sidebar { /* drawer handled by existing shell */ }
  .fm-table { display: block; overflow-x: auto; }
}
