/* ==========================================================================
   MyTruAdvantage Provider Portal — styles
   Theme colors are driven by CSS custom properties. Light is the default in
   :root; dark overrides live under :root[data-theme="dark"]. The data-theme
   attribute is set on <html> before first paint by the inline script in
   index.html (honors a saved choice, else the OS prefers-color-scheme).
   ========================================================================== */

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

:root {
  color-scheme: light;
  /* SIHO brand palette — exact values from the SIHO Brand Guide 2026 (p.16). */
  --brand:        #1e499e;   /* SIHO Blue — wordmark / nav bar */
  --brand-dark:   #092656;   /* SIHO dark navy — hover */
  --brand-light:  #e3e9f3;   /* SIHO Blue tint — badges */
  --accent:       #1e499e;   /* SIHO Blue — primary actions / links */
  --teal:         #7dcdcb;   /* SIHO light teal — top knot loop */
  --teal-deep:    #37a5aa;   /* SIHO deep teal — accent */
  --orange:       #ea9b55;   /* SIHO orange — bottom knot loop */
  --orange-dark:  #d36411;   /* SIHO dark orange — accent */
  --success-bg:   #dff6dd;
  --success-text: #1e6b1e;
  --success-bd:   #a8d5a2;
  --warn-bg:      #fff4ce;
  --warn-text:    #7a5c00;
  --warn-bd:      #f0d060;
  --err-bg:       #fde7e9;
  --err-text:     #a4262c;
  --err-bd:       #f1aeb0;
  --surface:      #ffffff;
  --surface-alt:  #f3f3f3;
  --border:       #d1d1d1;
  --text:         #1a1a1a;
  --text-muted:   #5a5a5a;
  --row:          #ffffff;   /* zebra rows: base */
  --row-alt:      #f6f7f9;   /* zebra rows: alternate (soft grey) */
  --radius:       6px;
  --mono:         'Consolas', 'Courier New', monospace;
}

/* Dark theme — overrides only; everything else inherits from :root. */
:root[data-theme="dark"] {
  color-scheme: dark;
  /* SIHO brand palette (guide values) lifted for contrast on dark surfaces. */
  --brand:        #2a57b0;   /* SIHO Blue (#1e499e) lifted for the dark header */
  --brand-dark:   #163c82;
  --brand-light:  #122a52;   /* dark badge bg */
  --accent:       #4c7bc9;   /* brighter SIHO-family blue for CTAs on dark */
  --teal:         #7dcdcb;
  --orange:       #ea9b55;
  --success-bg:   #10291a;
  --success-text: #6fdc8c;
  --success-bd:   #2ea043;
  --warn-bg:      #2b2400;
  --warn-text:    #e3b341;
  --warn-bd:      #8a6d00;
  --err-bg:       #351417;
  --err-text:     #ff8a80;
  --err-bd:       #c0392b;
  --surface:      #1e1e1e;
  --surface-alt:  #141414;
  --border:       #333333;
  --text:         #e9e9e9;
  --text-muted:   #a3a3a3;
  --row:          #1e1e1e;   /* zebra rows: base */
  --row-alt:      #262626;   /* zebra rows: alternate (subtle lighter) */
}
/* Badge text must stay light on the dark badge background. */
:root[data-theme="dark"] .badge { color: #8fb3ec; }

/* Smooth the transition when the theme flips. */
body, .card, .result-card, .result-header { transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-alt);
  min-height: 100vh;
}

header {
  position: relative;
  background: var(--brand);
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 12px;
}
/* Tricolor accent stripe echoing the SIHO logo knot (teal / blue / orange). */
header::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--accent) 50%, var(--orange) 100%);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sep { color: rgba(255,255,255,0.55); font-size: 20px; font-weight: 300; line-height: 1; }
.header-right { display: flex; align-items: center; gap: 10px; }
header h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }
header h1 span { font-size: 13px; opacity: 0.75; margin-left: 4px; }
.env-pill {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 99px;
  letter-spacing: 0.05em; white-space: nowrap;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px; cursor: pointer;
  color: #fff; font-size: 15px; line-height: 1;
  transition: background 0.15s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.28); }

main { max-width: 860px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.card h2 {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input,
.form-group select {
  height: 36px; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 10px;
  font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--surface);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,73,155,0.22);
}
.advanced-toggle {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--accent);
  padding: 4px 0; margin-bottom: 0.75rem;
}
.advanced-toggle .chevron-sm {
  font-size: 15px; line-height: 1; transition: transform 0.2s;
}
.advanced-toggle.open .chevron-sm { transform: rotate(90deg); }
.advanced-panel {
  display: none;
  border-top: 1px dashed var(--border);
  padding-top: 1rem; margin-top: -0.25rem; margin-bottom: 1rem;
}
.advanced-panel.open { display: block; }
.advanced-panel .form-grid { margin-bottom: 0; }
.field-note { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.checkbox-row { display: flex; align-items: center; gap: 6px; height: 36px; }
.checkbox-row input[type="checkbox"] { width: 15px; height: 15px; }
.checkbox-row label { font-size: 13px; color: var(--text); font-weight: 500; }

.form-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  height: 36px; padding: 0 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-alt); }
.hint { font-size: 12px; color: var(--text-muted); margin-left: 4px; }

.status {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 1rem; border: 1px solid;
}
.status-loading { background: var(--warn-bg);    color: var(--warn-text);    border-color: var(--warn-bd); }
.status-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-bd); }
.status-error   { background: var(--err-bg);     color: var(--err-text);     border-color: var(--err-bd); }
.spin { animation: spin 0.9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Non-prod-only display of the exact request URL built from the form. */
.debug-url-card {
  background: var(--surface); border: 1px dashed var(--accent);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 1rem;
}
.debug-url-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.debug-url-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent);
}
.debug-url-value {
  display: block; margin-top: 6px; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.5; color: var(--text);
  word-break: break-all; white-space: pre-wrap;
}
.debug-url-copy {
  height: 26px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px; font-weight: 600;
  cursor: pointer; background: var(--surface); color: var(--text-muted);
  flex-shrink: 0;
}
.debug-url-copy:hover { background: var(--surface-alt); }

.results-meta {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 10px;
}
.results-meta h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.badge {
  background: var(--brand-light); color: var(--brand);
  font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 99px;
}

.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer;
  background: var(--surface); border-bottom: 1px solid var(--border); gap: 12px;
}
.result-header:hover { background: var(--surface-alt); }
.result-header.collapsed { border-bottom: none; }
.result-title { min-width: 0; }
.provider-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.provider-meta { font-size: 12px; color: var(--text-muted); font-family: var(--mono); margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.copy-btn {
  height: 28px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px; font-weight: 600;
  cursor: pointer; background: var(--surface); color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.copy-btn:hover { background: var(--surface-alt); }
.chevron { color: var(--text-muted); font-size: 18px; transition: transform 0.2s; line-height: 1; }
.collapsed .chevron { transform: rotate(-90deg); }

/* The JSON viewer keeps its own dark palette in both themes by design. */
.json-wrap { padding: 12px 16px; background: #1e1e2e; overflow-x: auto; }
.json-wrap pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.65; color: #cdd6f4; white-space: pre; margin: 0; }
.jk  { color: #89b4fa; }
.js  { color: #a6e3a1; }
.jn  { color: #fab387; }
.jb  { color: #f38ba8; }
.jnu { color: #6c7086; }
.collapsed .json-wrap { display: none; }

footer { text-align: center; font-size: 12px; color: var(--text-muted); padding: 2rem 1rem 1.5rem; }
footer a { color: var(--accent); text-decoration: none; display: inline-block; margin-top: 6px; }
footer a:hover { text-decoration: underline; }

@media (max-width: 540px) {
  header h1 { font-size: 15px; }
  header h1 span { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Data tables & striped rows (zebra) — theme-aware via --row / --row-alt.
   Use <table class="data-table"> for tabular data, or add class="striped" to
   any list/grid container to alternate-shade its direct children. Light mode
   alternates white / soft grey; dark mode uses a subtle lighter stripe.
   -------------------------------------------------------------------------- */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--row); color: var(--text);
  font-size: 14px; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.data-table thead th {
  text-align: left; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); background: var(--surface-alt);
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.data-table tbody tr { background: var(--row); }
.data-table tbody tr:nth-child(even) { background: var(--row-alt); }
.data-table tbody tr:hover { background: var(--brand-light); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Generic striping for non-table lists/grids: alternate direct children. */
.striped > *:nth-child(odd)  { background: var(--row); }
.striped > *:nth-child(even) { background: var(--row-alt); }
