/*
 * Yes Madam — LTV Weight Studio
 * Theme aligned with Product Recommendation Engine (yesmadam.com):
 * magenta/pink primary, Poppins type, light surfaces.
 */

:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface2: #F7F8FA;
  --surface3: #F1F3F6;
  --border: #E7E9EE;
  --text: #1A1F2B;
  --sub: #4B5563;
  --muted: #6B7280;
  --dim: #9AA1AC;
  --brand: #E5006E;
  --brand-dark: #B80059;
  --brand-soft: rgba(229, 0, 110, 0.07);
  --green: #0E9F6E;
  --green-soft: rgba(14, 159, 110, 0.10);
  --red: #E02424;
  --red-soft: rgba(224, 36, 36, 0.08);
  --amber: #C27803;
  --blue: #2563EB;
  --blue-soft: rgba(37, 99, 235, 0.08);
  --ok: var(--green);
  --warn: var(--amber);
  --err: var(--red);
  --pos: var(--green);
  --neg: var(--red);
  --radius: 10px;
  font-family: "Poppins", system-ui, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header (matches ym-header from Prod Reco) ── */
.ym-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.ym-header img {
  height: 26px;
  flex-shrink: 0;
}

.ym-header-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

.ym-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.header-tabs {
  margin-left: auto;
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.header-tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.header-tab:hover {
  color: var(--text);
  background: var(--surface);
}

.header-tab.active {
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: 0 1px 2px rgba(26, 31, 43, 0.06);
}

.header-tab.has-active::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: middle;
}

.job-flyout {
  position: fixed;
  top: 55px;
  right: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(26, 31, 43, 0.12);
  padding: 14px;
  z-index: 90;
}

.job-flyout .job-box {
  margin-bottom: 0;
}

.job-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
}

.job-flyout .empty {
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
  text-align: center;
  padding: 0.75rem 0.5rem;
}

.job-flyout .job-muted,
.job-flyout .history-sub,
.job-flyout .job-meta {
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
}

.job-flyout .history-sub .job-status {
  font-size: inherit;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.job-flyout .history-main {
  font-size: 12px;
  font-weight: 500;
}

.job-flyout .history-main strong {
  font-weight: 600;
}

.job-flyout .job-detail-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.job-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface3);
  color: var(--muted);
}

.job-status.done { background: var(--green-soft); color: var(--green); }
.job-status.failed { background: var(--red-soft); color: var(--red); }
.job-status.running { background: var(--blue-soft); color: var(--blue); }

.job-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
}

.history-item:hover { border-color: var(--brand); }
.history-item.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.history-main { font-size: 12px; }
.history-sub {
  display: flex;
  gap: 8px;
  align-items: center;
}

.history-detail {
  margin-top: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  min-height: calc(100vh - 55px);
  background: var(--surface2);
}

aside, .main, .panel {
  padding: 1rem;
  overflow: auto;
}

aside {
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.main {
  background: var(--surface2);
}

.panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
}

label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  margin-bottom: 0.35rem;
}

select,
input[type="number"],
input[type="date"],
input[type="checkbox"] {
  font-family: inherit;
}

select,
input[type="number"],
input[type="date"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}

select:focus,
input[type="number"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.field { margin-bottom: 1rem; }

.feature-list {
  list-style: none;
  margin-top: 0.5rem;
}

.feature-list li button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
}

.feature-list li button:hover {
  background: var(--surface2);
}

.feature-list li button.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.feature-list .meta {
  display: block;
  font-size: 10.5px;
  color: var(--dim);
  font-weight: 400;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: var(--brand);
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn.danger {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-soft);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pending-bar {
  display: none;
}

.changes-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 1rem;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
}

.change-group {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.change-group:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.change-feat {
  font-weight: 600;
  font-size: 12px;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.change-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.change-group li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  color: var(--sub);
}

.change-label code {
  font-size: 10px;
}

.change-arrow {
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.sticky-actions {
  margin-bottom: 0;
}

.confirm-lead {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.hidden { display: none !important; }

.delta-input.invalid {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.feature-list li button.inactive {
  opacity: 0.65;
}

.feature-list li button.inactive .meta::before {
  content: "off · ";
  color: var(--amber);
}

.feature-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 1rem;
}

.feature-controls.hidden { display: none; }

.feature-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}

.feature-name {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  min-width: 120px;
}

.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}

.inline-label select {
  width: auto;
  min-width: 4rem;
}

.toggle-label input { width: auto; }


.apply-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 1.25rem;
}

.window-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hint {
  display: block;
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
  text-transform: none;
  font-weight: 400;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.delta-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 1rem;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.meta-row strong { color: var(--text); }

.main h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
}

table.weights {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table.weights th {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--dim);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface2);
  white-space: nowrap;
}

table.weights td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

table.weights tr:last-child td { border-bottom: none; }

table.weights tr:hover td {
  background: var(--brand-soft);
}

table.weights code {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
}

.delta-input {
  width: 4.5rem;
  text-align: center;
  font-weight: 600;
  font-family: "JetBrains Mono", monospace;
}

.delta-input.positive { color: var(--green); }
.delta-input.negative { color: var(--red); }

.panel h2 {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin-bottom: 0.75rem;
}

.job-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12.5px;
  margin-bottom: 1rem;
}

.job-box .step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  color: var(--sub);
}

.job-box .step .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
}

.job-box .step.ok .dot { background: var(--green); }
.job-box .step.fail .dot { background: var(--red); }

.log {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  margin-top: 0.5rem;
  background: var(--surface);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(26, 31, 43, 0.12);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
  animation: fadein 0.2s;
}

.toast.err {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.offline-banner {
  background: var(--amber);
  color: #1A1F2B;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

body.read-only .offline-banner {
  background: #E8EEF7;
  color: #1A1F2B;
}

body.read-only #applyChangesBtn,
body.read-only #runBtn {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
}

.empty {
  color: var(--dim);
  text-align: center;
  padding: 3rem;
}

.panel label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 820px) {
  .ym-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px 10px;
  }

  .ym-header-divider { display: none; }

  .header-tabs {
    margin-left: auto;
  }

  .job-flyout {
    right: 8px;
    left: 8px;
    width: auto;
  }

  .layout { grid-template-columns: 1fr; }
  aside, .panel { border: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 1100px) and (min-width: 821px) {
  .layout { grid-template-columns: 1fr; }
  aside, .panel { border: none; border-bottom: 1px solid var(--border); }
}
