/* WUA Remix Phase 3 — shared styles for MTEREx marketplace, matcher,
   violation detector, curtailment optimizer, drought-contingency, climate-baseline. */

/* ── Shared form scaffolding ────────────────────────────────────────────── */
.mwx-form fieldset, .mmx-form fieldset, .vd-form fieldset,
.co-form fieldset, .dc-form fieldset, .cb-form fieldset {
  border: 1px solid var(--guide-color-border-default, rgba(0,0,0,0.1)); border-radius: 8px;
  padding: 12px 14px 6px; margin-bottom: 14px;
}
.mwx-form legend, .mmx-form legend, .vd-form legend,
.co-form legend, .dc-form legend, .cb-form legend {
  font-size: var(--guide-fs-2xs); text-transform: var(--guide-label-case, uppercase); letter-spacing: 0.05em;
  color: var(--text-muted, rgba(0,0,0,0.6)); font-weight: 600; padding: 0 6px;
}
.mwx-form label, .mmx-form label, .vd-form label,
.co-form label, .dc-form label, .cb-form label {
  display: block; font-size: var(--guide-fs-xs); font-weight: 600;
  color: var(--text-muted, rgba(0,0,0,0.7)); margin-bottom: 10px;
}
.mwx-form input, .mwx-form select, .mwx-form textarea,
.mmx-form input, .mmx-form select, .mmx-form textarea,
.vd-form input, .vd-form select, .vd-form textarea,
.co-form input, .co-form select, .co-form textarea,
.dc-form input, .dc-form select, .dc-form textarea,
.cb-form input, .cb-form select, .cb-form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px;
  border: 1px solid rgba(var(--guide-wash-rgb, 0, 0, 0), 0.15); border-radius: 5px;
  font-size: var(--guide-fs-sm); font-family: inherit;
}
.mwx-row, .mmx-row, .co-row, .dc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mwx-intro, .mmx-intro, .vd-intro, .co-intro, .dc-intro, .cb-intro {
  font-size: var(--guide-fs-xs); color: var(--text-muted, rgba(0,0,0,0.6));
  line-height: 1.5; margin: 0 0 12px;
  padding: 10px 12px; background: rgba(15,118,110,0.05);
 border-radius: 4px;
}
.mwx-actions, .mmx-actions, .vd-actions, .co-actions, .dc-actions, .cb-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap;
}
.mwx-attest {
  display: flex; align-items: flex-start; gap: 8px;
  font-weight: 400; font-size: var(--guide-fs-xs); line-height: 1.5;
  color: var(--text-primary, #1a1a1f); padding: 10px 0;
}
.mwx-attest input { width: auto; margin-top: 2px; }

/* ── MTEREx marketplace grid ────────────────────────────────────────────── */
.mwx-browse-actions {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.mwx-meta { font-size: var(--guide-fs-xs); color: var(--text-muted, rgba(0,0,0,0.55)); }
.mwx-empty { text-align: center; padding: 30px; color: var(--text-muted, rgba(0,0,0,0.5)); }
.mwx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.mwx-card {
  border: 1px solid var(--guide-color-border-default, rgba(0,0,0,0.1)); border-radius: 8px;
  padding: 14px; background: #fff;
  display: flex; flex-direction: column; gap: 6px;
}
.mwx-card-head { display: flex; justify-content: space-between; font-size: var(--guide-fs-2xs); text-transform: var(--guide-label-case, uppercase); letter-spacing: 0.04em; }
.mwx-type { background: var(--guide-color-paper-2); color: var(--guide-color-ink); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.mwx-basin { background: rgba(var(--guide-wash-rgb, 0, 0, 0), 0.06); padding: 2px 8px; border-radius: 999px; }
.mwx-card-title { margin: 0; font-size: var(--guide-fs-base); }
.mwx-card-flow, .mwx-card-source { font-size: var(--guide-fs-xs); color: rgba(0,0,0,0.65); }
.mwx-card-price { font-weight: 700; font-size: var(--guide-fs-md); color: var(--guide-color-status-ok, #157347); }
.mwx-eoi-btn { margin-top: 4px; }

/* ── Matcher / detector / optimizer tables ──────────────────────────────── */
.mmx-table, .vd-table, .co-table {
  width: 100%; border-collapse: collapse; font-size: var(--guide-fs-sm); margin-top: 10px;
}
.mmx-table th, .vd-table th, .co-table th {
  text-align: left; padding: 6px 10px;
  font-size: var(--guide-fs-2xs); text-transform: var(--guide-label-case, uppercase); letter-spacing: 0.05em;
  color: var(--text-muted, rgba(0,0,0,0.55));
  border-bottom: 1px solid rgba(var(--guide-wash-rgb, 0, 0, 0), 0.08);
}
.mmx-table td, .vd-table td, .co-table td {
  padding: 6px 10px; border-top: 1px solid rgba(var(--guide-wash-rgb, 0, 0, 0), 0.05);
}
.mmx-empty { text-align: center; padding: 16px; color: var(--text-muted, rgba(0,0,0,0.5)); }

/* ── Violation tier chips ───────────────────────────────────────────────── */
.vd-tier {
  display: inline-block; color: var(--guide-color-text-on-accent, #fff); font-weight: 600; font-size: var(--guide-fs-2xs);
  padding: 2px 10px; border-radius: 999px; text-transform: var(--guide-label-case, uppercase); letter-spacing: 0.04em;
}
.vd-row--severe { background: color-mix(in srgb, var(--guide-color-status-crit) 6%, transparent); }
.vd-row--moderate { background: color-mix(in srgb, var(--guide-color-ochre) 6%, transparent); }
.vd-row--minor { background: color-mix(in srgb, var(--guide-color-ochre-fill) 5%, transparent); }
.vd-summary { font-size: var(--guide-fs-sm); margin-bottom: 8px; }
.vd-pending, .mmx-pending, .co-pending, .dc-pending, .cb-pending {
  padding: 10px 12px; background: rgba(15,118,110,0.05);
 border-radius: 4px;
  color: #0f766e; font-size: var(--guide-fs-sm);
}
.vd-error, .co-error, .dc-error, .cb-error {
  padding: 10px 12px; background: color-mix(in srgb, var(--guide-color-status-crit) 8%, transparent);
  border: 1px solid var(--guide-color-line); border-radius: 4px;
  color: var(--guide-color-status-crit); font-size: var(--guide-fs-sm);
}

/* ── Curtailment optimizer verdict ─────────────────────────────────────── */
.co-verdict {
  padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--guide-color-line); margin: 8px 0; font-size: var(--guide-fs-sm);
}
.co-verdict--ok {  background: color-mix(in srgb, var(--guide-color-moss) 6%, transparent); color: #166534; }
.co-verdict--warn {  background: color-mix(in srgb, var(--guide-color-ochre) 6%, transparent); color: #9a3412; }
.co-skipped { margin: 4px 0 0 18px; font-size: var(--guide-fs-xs); color: rgba(0,0,0,0.65); }
.co-authority { margin-top: 10px; color: var(--text-muted, rgba(0,0,0,0.55)); }

/* ── Drought contingency preview ───────────────────────────────────────── */
.dc-verdict { padding: 10px 12px; background: rgba(15,118,110,0.06); border-radius: 4px; font-size: var(--guide-fs-sm); }
.dc-preview {
  margin-top: 10px; max-height: 320px; overflow-y: auto;
  background: rgba(var(--guide-wash-rgb, 0, 0, 0), 0.03); padding: 12px; border-radius: 6px;
  font-family: var(--guide-font-mono); font-size: var(--guide-fs-2xs); line-height: 1.4;
  white-space: pre-wrap;
}

/* ── Climate baseline verdict ──────────────────────────────────────────── */
.cb-verdict { padding: 10px 12px; background: rgba(15,118,110,0.06); border-radius: 4px; font-size: var(--guide-fs-sm); }
.cb-interp { font-size: var(--guide-fs-sm); margin-top: 8px; }
.cb-source { color: var(--text-muted, rgba(0,0,0,0.55)); }

@media (max-width: 640px) {
  .mwx-row, .mmx-row, .co-row, .dc-row { grid-template-columns: 1fr; }
}

/* ── Dark-theme overrides ── */
[data-theme="dark"] .mwx-form fieldset, [data-theme="dark"] .mmx-form fieldset,
[data-theme="dark"] .vd-form fieldset, [data-theme="dark"] .co-form fieldset,
[data-theme="dark"] .dc-form fieldset, [data-theme="dark"] .cb-form fieldset {
  border-color: rgba(255,255,255,0.10);
}
[data-theme="dark"] .mwx-form input, [data-theme="dark"] .mwx-form select, [data-theme="dark"] .mwx-form textarea,
[data-theme="dark"] .mmx-form input, [data-theme="dark"] .mmx-form select,
[data-theme="dark"] .vd-form input, [data-theme="dark"] .vd-form select, [data-theme="dark"] .vd-form textarea,
[data-theme="dark"] .co-form input, [data-theme="dark"] .co-form select,
[data-theme="dark"] .dc-form input, [data-theme="dark"] .dc-form select,
[data-theme="dark"] .cb-form input, [data-theme="dark"] .cb-form select { border-color: rgba(255,255,255,0.12); }
[data-theme="dark"] .mwx-card {
  background: var(--bg-2, #1E2229);
  border-color: rgba(255,255,255,0.10);
}
[data-theme="dark"] .mwx-card-flow, [data-theme="dark"] .mwx-card-source { color: var(--text-secondary, #A8A8B3); }
[data-theme="dark"] .mwx-basin { background: rgba(255,255,255,0.08); }
[data-theme="dark"] .mwx-card-price { color: #4ADE80; }
[data-theme="dark"] .mmx-table th, [data-theme="dark"] .vd-table th, [data-theme="dark"] .co-table th {
  border-bottom-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .mmx-table td, [data-theme="dark"] .vd-table td, [data-theme="dark"] .co-table td {
  border-top-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .vd-error, [data-theme="dark"] .co-error,
[data-theme="dark"] .dc-error, [data-theme="dark"] .cb-error { color: #F87171; }
[data-theme="dark"] .co-verdict--ok { color: #4ADE80; }
[data-theme="dark"] .co-verdict--warn { color: var(--guide-color-status-watch); }
[data-theme="dark"] .co-skipped { color: var(--text-secondary, #A8A8B3); }
[data-theme="dark"] .dc-preview { background: rgba(255,255,255,0.04); }
