/* ── OP Shared Components ────────────────────────────────────────────────────
 * All reusable UI components for OP dashboards.
 * Requires variables.css to be loaded first.
 * ─────────────────────────────────────────────────────────────────────────── */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
}
body.modal-open { overflow: hidden; }

/* ── Sticky header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand               { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand img           { height: 30px; width: auto; display: block; }
.brand-divider       { width: 1px; height: 24px; background: rgba(255,255,255,0.2); }
.brand-title         { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.9); letter-spacing: 0.01em; }
.header-sep          { flex: 1; }
.header-meta         { display: flex; align-items: center; gap: 12px; }
.header-range        { font-size: 12px; color: rgba(255,255,255,0.55); }
.header-date         { font-size: 12px; color: rgba(255,255,255,0.85); font-weight: 500; }

/* ── Header buttons ── */
.btn-header {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-header:hover { background: rgba(255,255,255,0.15); color: #fff; }
.btn-header.loading { opacity: 0.6; pointer-events: none; }

/* Alias — practice-actions uses .btn-feedback for these */
.btn-feedback {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-feedback:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── User profile chip + dropdown ── */
.user-profile-wrap { position: relative; }
.user-profile-dropdown {
  display: none; position: absolute; right: 0; top: 100%;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 14px 16px; min-width: 230px;
  box-shadow: 0 6px 20px rgba(0,0,0,.14); z-index: 300;
}
.user-profile-wrap:hover .user-profile-dropdown { display: block; }

/* ── Tab navigation ── */
.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 30;
}
.tab-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
}
.tab-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab-btn:hover      { color: var(--navy); }
.tab-btn-active     { color: var(--navy); border-bottom-color: var(--cyan); font-weight: 600; }

/* ── Main content container ── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.tab-panel { display: block; }

/* ── Section label ── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── KPI cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 1024px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  position: relative;
}

.kpi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kpi-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  letter-spacing: -0.5px;
}

.kpi-divider { width: 100%; height: 1px; background: var(--gray-lt); margin-bottom: 10px; }

.kpi-prior       { display: flex; gap: 20px; }
.kpi-prior-item  { display: flex; flex-direction: column; gap: 1px; }
.kpi-prior-label { font-size: 10px; color: var(--gray-md); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-prior-val   { font-size: 13px; font-weight: 500; color: #374151; }

/* ── Trend badges ── */
.kpi-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge-up   { background: var(--green-bg); color: var(--green-txt); }
.badge-down { background: var(--red-bg);   color: var(--red-txt);   }
.badge-flat { background: #F3F4F6;          color: var(--gray-md);   }

/* ── Info button (definition tooltip trigger) ── */
.info-btn {
  width: 16px; height: 16px; border-radius: 50%;
  background: none; border: 1px solid var(--gray-lt);
  color: var(--gray-md); font-size: 10px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; line-height: 1; flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.info-btn:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── Skeleton loaders ── */
.skeleton {
  background: linear-gradient(90deg, #e9ecef 25%, #dee2e6 50%, #e9ecef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* ── State indicators ── */
.state-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}
.state-error {
  color: #c0392b;
  font-size: 13px;
  padding: 12px 16px;
  background: var(--red-bg);
  border-radius: 6px;
  border: 1px solid #fca5a5;
}
/* legacy alias used in practice-actions */
.bh-state { color: var(--text-muted); font-size: 13px; padding: 20px; }

/* ── Data freshness banner ── */
.data-freshness-banner {
  font-size: 12px;
  color: #6b7280;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 7px 14px;
}

/* ── Metric cell (used in data tables) ── */
.mc           { display: flex; flex-direction: column; gap: 2px; }
.mc-val       { font-size: 14px; font-weight: 600; color: var(--text); }
.mc-row       { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mc-yoy       { font-size: 11px; font-weight: 600; }
.mc-yoy.up    { color: var(--green-txt); }
.mc-yoy.dn    { color: var(--red-txt); }
.mc-yoy.fl    { color: var(--gray-md); }
.mc-y2        { font-size: 10px; color: var(--gray-md); }
.prod-bar      { height: 3px; background: var(--gray-lt); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.prod-bar-fill { height: 100%; background: var(--cyan); border-radius: 2px; }

/* ── Data table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--gray-md); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.data-table th:hover  { color: var(--navy); }
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid #f1f5f9;
  color: var(--text); vertical-align: middle;
}
.data-table tr:last-child td  { border-bottom: none; }
.data-table tbody tr:hover    { background: #f8fafc; }

/* sortable header active state */
.ks      { cursor: pointer; user-select: none; }
.ks-on   { color: var(--navy); }
.ks-on::after    { content: ' ▼'; font-size: 9px; }
.ks-asc::after   { content: ' ▲'; font-size: 9px; }

/* ── Card wrapper (generic surface) ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

/* ── Chart placeholder ── */
.chart-placeholder {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ── Feedback modal ── */
.fb-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.45);
  align-items: flex-end; justify-content: flex-end;
  padding: 80px 24px 24px;
}
.fb-modal-overlay.open { display: flex; }
.fb-modal {
  background: var(--white); border-radius: 12px;
  width: 360px; max-width: calc(100vw - 48px);
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.fb-header {
  background: var(--navy); color: var(--white);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.fb-title  { font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.fb-close  { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 2px; }
.fb-close:hover { color: #fff; }
.fb-body   { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.fb-sub    { font-size: 12px; color: var(--gray-md); line-height: 1.5; }
.fb-textarea {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 13px; font-family: inherit;
  color: #374151; resize: vertical; min-height: 100px;
  transition: border-color 0.15s; outline: none;
}
.fb-textarea:focus { border-color: var(--cyan); }
.fb-footer { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.fb-char   { font-size: 11px; color: var(--gray-md); flex: 1; }
.fb-send {
  background: var(--navy); color: var(--white);
  border: none; border-radius: 6px;
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.fb-send:hover    { background: #004f80; }
.fb-send:disabled { opacity: 0.5; pointer-events: none; }
.fb-status { font-size: 12px; padding: 8px 12px; border-radius: 6px; display: none; }
.fb-status.ok  { background: var(--green-bg); color: var(--green-txt); display: block; }
.fb-status.err { background: var(--red-bg);   color: var(--red-txt);   display: block; }

/* ── Definition / FAQ modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,57,90,0.35); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--white); border-radius: 10px;
  padding: 24px 28px; max-width: 480px;
  width: calc(100% - 32px); box-shadow: 0 8px 32px rgba(0,57,90,0.18);
  max-height: 80vh; overflow-y: auto; min-width: 320px;
}
.modal-box::-webkit-scrollbar       { width: 5px; }
.modal-box::-webkit-scrollbar-track { background: transparent; }
.modal-box::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.modal-box::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.modal-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 12px;
}
.modal-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.modal-close {
  background: none; border: none; font-size: 18px;
  color: var(--gray-md); cursor: pointer; line-height: 1;
  padding: 0 2px; transition: color 0.15s;
}
.modal-close:hover { color: var(--navy); }
.modal-text { font-size: 13px; color: #374151; line-height: 1.7; }
.modal-text strong { color: var(--navy); }

/* ── FAQ items ── */
.faq-item  { margin-bottom: 18px; }
.faq-q     { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.faq-a     { font-size: 13px; color: #374151; line-height: 1.6; }

/* ── Definition formula highlight ── */
.def-formula {
  display: block; background: #f8fafc; border-left: 3px solid var(--cyan);
  padding: 6px 10px; margin: 6px 0; border-radius: 3px;
  font-family: 'Courier New', monospace; font-size: 12px; color: var(--navy);
}
