/* ═══════════════════════════════════════════════════
   Eczema Tracker v2 — Frontend
   Refined medical aesthetic, inherits site colours
   Typography: Lora (display) + DM Sans (body)
═══════════════════════════════════════════════════ */

:root {
  --et-primary:      var(--wp--preset--color--primary,      #1b5e7b);
  --et-primary-dk:   var(--wp--preset--color--primary-dark, #134658);
  --et-accent:       var(--wp--preset--color--secondary,    #2a8fa8);
  --et-fg:           var(--wp--preset--color--foreground,   #18293a);
  --et-fg-muted:     #5e7280;
  --et-bg:           var(--wp--preset--color--background,   #f4f7fa);
  --et-surface:      #ffffff;
  --et-border:       #dce4ec;
  --et-border-light: #ecf0f4;
  --et-r:            10px;
  --et-r-sm:         7px;
  --et-shadow:       0 1px 8px rgba(24,41,58,.07);
  --et-shadow-md:    0 4px 18px rgba(24,41,58,.11);
  --et-font:         'DM Sans', system-ui, sans-serif;
  --et-font-d:       'Lora', Georgia, serif;
}

/* ── Reset ──────────────────────────────────────── */
.et-app *, .et-app *::before, .et-app *::after { box-sizing: border-box; }
.et-app { font-family: var(--et-font); color: var(--et-fg); line-height: 1.5; }
.et-app button { font-family: var(--et-font); cursor: pointer; }
.et-app input, .et-app textarea { font-family: var(--et-font); }

/* ── App shell ──────────────────────────────────── */
.et-app {
  max-width: 1080px;
  margin: 0 auto;
  background: var(--et-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--et-shadow-md);
}

/* ── Header ─────────────────────────────────────── */
.et-header {
  background: var(--et-primary);
  color: #fff;
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.et-header-left { display: flex; align-items: center; gap: 14px; }
.et-header-icon {
  width: 42px; height: 42px;
  background: rgba(255,255,255,.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.et-header-title {
  font-family: var(--et-font-d);
  font-size: 1.3rem;
  font-weight: 400;
  margin: 0; line-height: 1.2;
}
.et-header-sub { font-size: .8rem; opacity: .72; margin: 0; }
.et-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.et-date-badge {
  font-size: .8rem; opacity: .8;
  background: rgba(255,255,255,.1);
  padding: 5px 12px; border-radius: 20px;
}
.et-saved-badge {
  font-size: .78rem; font-weight: 600;
  background: rgba(74,222,128,.25);
  color: #bbf7d0;
  padding: 5px 12px; border-radius: 20px;
}
.et-prefill-badge {
  font-size: .78rem;
  background: rgba(251,191,36,.2);
  color: #fde68a;
  padding: 5px 12px; border-radius: 20px;
}

/* ── Grid ────────────────────────────────────────── */
.et-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 640px;
}

/* ── Map Panel ───────────────────────────────────── */
.et-map-panel {
  background: var(--et-surface);
  border-right: 1px solid var(--et-border);
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.et-map-header { text-align: center; width: 100%; }
.et-map-header h2 {
  font-family: var(--et-font-d);
  font-size: 1rem; font-weight: 600;
  color: var(--et-primary); margin: 0 0 2px;
}
.et-map-header p { font-size: .75rem; color: var(--et-fg-muted); margin: 0; }

/* View tabs */
.et-view-tabs { display: flex; gap: 6px; width: 100%; }
.et-tab {
  flex: 1; padding: 7px 0;
  border: 1.5px solid var(--et-border);
  background: #fff; border-radius: var(--et-r-sm);
  font-size: .82rem; font-weight: 500;
  color: var(--et-fg-muted);
  transition: all .18s;
}
.et-tab.active {
  background: var(--et-primary); border-color: var(--et-primary);
  color: #fff; box-shadow: 0 2px 8px rgba(27,94,123,.25);
}

/* SVG map */
.et-map-wrap { width: 100%; position: relative; }
.et-map-svg { width: 100%; }
.et-map-hidden { display: none; }
.et-body-svg { width: 100%; height: auto; display: block; }

/* Zone hover/active */
.et-zone { cursor: pointer; transition: opacity .15s; }
.et-zone:hover .et-zone-overlay { fill: rgba(27,94,123,.08) !important; }
.et-zone.et-zone-active > path:first-child,
.et-zone.et-zone-active > ellipse:first-child {
  stroke: var(--et-accent); stroke-width: 2.5;
}
.et-zone.et-zone-dimmed { opacity: .35; }
.et-zone-overlay { pointer-events: all; }
.et-overlay-layer { pointer-events: none; }
.et-rep-layer { pointer-events: none; }

/* Neck shared button */
.et-shared-zone-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 7px 12px;
  background: var(--et-bg); border: 1.5px solid var(--et-border);
  border-radius: var(--et-r-sm);
  font-size: .82rem; font-weight: 500; color: var(--et-fg);
  cursor: pointer; transition: all .18s;
}
.et-shared-zone-btn:hover { border-color: var(--et-accent); color: var(--et-accent); background: #fff; }
.et-shared-zone-btn.et-zone-active { border-color: var(--et-accent); background: rgba(42,143,168,.07); }

/* Genitals row */
.et-genitals-row { width: 100%; }
.et-genitals-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 6px 12px;
  background: transparent; border: 1px dashed var(--et-border);
  border-radius: var(--et-r-sm);
  font-size: .78rem; color: var(--et-fg-muted);
  transition: all .18s;
}
.et-genitals-btn:hover { border-color: var(--et-accent); color: var(--et-accent); }
.et-genitals-btn.et-zone-active { border-color: var(--et-accent); color: var(--et-accent); background: rgba(42,143,168,.05); }

/* Shared dot indicator */
.et-shared-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; border: 1.5px solid var(--et-border);
  display: inline-block; flex-shrink: 0; transition: background .2s;
}
.et-shared-dot.has-data { background: var(--et-accent); border-color: var(--et-accent); }

/* Legend */
.et-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center; width: 100%;
}
.et-legend-item { display: flex; align-items: center; gap: 5px; font-size: .7rem; color: var(--et-fg-muted); }
.et-legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

/* Assessed panel */
.et-assessed-panel { width: 100%; }
.et-assessed-panel h4 {
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--et-fg-muted); margin: 0 0 8px;
}
.et-assessed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.et-assessed-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 10px; background: var(--et-bg); border-radius: 6px;
  font-size: .76rem;
}
.et-assessed-item-label { color: var(--et-fg); }
.et-assessed-item-score {
  font-weight: 600; padding: 2px 7px; border-radius: 12px; font-size: .72rem;
}
.et-assessed-item-score.s0 { background: #f1f5f9; color: var(--et-fg-muted); }
.et-assessed-item-score.s1 { background: rgba(251,191,36,.2); color: #92400e; }
.et-assessed-item-score.s2 { background: rgba(251,146,60,.2); color: #9a3412; }
.et-assessed-item-score.s3 { background: rgba(239,68,68,.2); color: #991b1b; }

/* ── Form Panel ──────────────────────────────────── */
.et-form-panel {
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
}

/* Cards */
.et-card {
  background: var(--et-surface);
  border: 1px solid var(--et-border);
  border-radius: var(--et-r);
  padding: 18px 20px;
  box-shadow: var(--et-shadow);
}
.et-card-title {
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--et-fg-muted); margin: 0 0 14px;
}
.et-optional {
  font-weight: 400; text-transform: none; letter-spacing: 0;
  font-size: .72rem; opacity: .7; margin-left: 6px;
}

/* Score card */
.et-score-card {
  background: var(--et-primary);
  color: #fff; border-radius: var(--et-r);
  padding: 20px 22px;
  box-shadow: 0 6px 22px rgba(27,94,123,.28);
}
.et-score-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.et-score-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; opacity: .7; margin-bottom: 4px; }
.et-score-row { display: flex; align-items: baseline; gap: 5px; }
.et-score-num { font-family: var(--et-font-d); font-size: 3.2rem; line-height: 1; font-weight: 400; }
.et-score-denom { font-size: .95rem; opacity: .55; }
.et-severity-pill {
  padding: 4px 12px; border-radius: 20px; font-size: .78rem; font-weight: 600;
  background: rgba(255,255,255,.15); margin-left: 4px; align-self: center;
}
.et-severity-pill.mild     { background: rgba(74,222,128,.3); color: #bbf7d0; }
.et-severity-pill.moderate { background: rgba(251,146,60,.3); color: #fed7aa; }
.et-severity-pill.severe   { background: rgba(239,68,68,.3);  color: #fecaca; }
.et-score-breakdown { display: flex; flex-direction: column; gap: 5px; }
.et-breakdown-item { display: flex; justify-content: space-between; gap: 16px; font-size: .78rem; opacity: .75; }
.et-breakdown-val { font-weight: 600; opacity: 1; }
.et-score-track { height: 5px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.et-score-fill { height: 100%; background: #fff; border-radius: 3px; transition: width .5s ease; width: 0; }
.et-rep-notice {
  display: flex; align-items: center; gap: 6px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: .78rem; opacity: .85;
  flex-wrap: wrap;
}
.et-rep-change {
  margin-left: auto; padding: 3px 10px;
  background: rgba(255,255,255,.15); border: none;
  border-radius: 12px; font-size: .72rem; color: #fff; font-family: var(--et-font);
  cursor: pointer; transition: background .15s;
}
.et-rep-change:hover { background: rgba(255,255,255,.28); }

/* Sliders */
.et-slider-wrap { margin-bottom: 16px; }
.et-slider-wrap:last-child { margin-bottom: 0; }
.et-slider-header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.et-slider-header label { font-size: .88rem; font-weight: 600; color: var(--et-fg); flex-shrink: 0; }
.et-slider-desc { font-size: .76rem; color: var(--et-fg-muted); flex: 1; line-height: 1.4; }
.et-slider-val { font-size: .88rem; font-weight: 700; color: var(--et-primary); flex-shrink: 0; margin-left: auto; }
.et-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 3px; background: var(--et-border); outline: none; cursor: pointer;
}
.et-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--et-primary); border: 2.5px solid #fff;
  box-shadow: 0 2px 7px rgba(27,94,123,.3); cursor: pointer;
}
.et-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--et-primary); border: 2.5px solid #fff; cursor: pointer;
}
.et-slider-ticks { display: flex; justify-content: space-between; font-size: .68rem; color: var(--et-fg-muted); margin-top: 3px; }

/* Notes */
.et-notes {
  width: 100%; min-height: 74px;
  border: 1.5px solid var(--et-border); border-radius: var(--et-r-sm);
  padding: 10px 12px; font-size: .88rem; color: var(--et-fg);
  resize: vertical; outline: none; transition: border-color .18s;
  background: var(--et-bg);
}
.et-notes:focus { border-color: var(--et-accent); background: #fff; }

/* Save button */
.et-save-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px;
  background: var(--et-accent); color: #fff; border: none;
  border-radius: var(--et-r); font-size: .95rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(42,143,168,.3);
  transition: all .2s;
}
.et-save-btn:hover { background: var(--et-primary); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(27,94,123,.35); }
.et-save-btn:active { transform: translateY(0); }
.et-save-msg { text-align: center; font-size: .84rem; min-height: 20px; }
.et-save-msg.success { color: #16a34a; }
.et-save-msg.error   { color: #dc2626; }

/* Report card */
.et-report-desc { font-size: .84rem; color: var(--et-fg-muted); margin: 0 0 12px; }
.et-report-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.et-report-btn {
  flex: 1; padding: 9px 12px;
  background: var(--et-bg); border: 1.5px solid var(--et-border);
  border-radius: var(--et-r-sm); font-size: .82rem; font-weight: 500;
  color: var(--et-fg); transition: all .18s;
}
.et-report-btn:hover { border-color: var(--et-primary); color: var(--et-primary); background: #fff; }

/* Chart card */
.et-empty { text-align: center; color: var(--et-fg-muted); font-size: .84rem; padding: 16px 0; }

/* ── Modals ───────────────────────────────────────── */
.et-modal-bg {
  position: fixed; inset: 0;
  background: rgba(18,30,42,.5);
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
  animation: et-fadein .15s ease;
}
@keyframes et-fadein { from { opacity: 0; } to { opacity: 1; } }
.et-modal-box {
  background: #fff; border-radius: 14px;
  width: 92%; max-width: 500px; max-height: 92vh;
  overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,.22);
  animation: et-slideup .2s ease;
}
.et-rep-modal-box { max-width: 420px; }
@keyframes et-slideup { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.et-modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--et-border-light);
  gap: 12px;
}
.et-modal-head h3 {
  font-family: var(--et-font-d); font-size: 1.1rem; font-weight: 600;
  color: var(--et-primary); margin: 0 0 3px;
}
.et-modal-sub { font-size: .78rem; color: var(--et-fg-muted); margin: 0; line-height: 1.5; }
.et-modal-x {
  background: none; border: none; font-size: 1.4rem; color: var(--et-fg-muted);
  cursor: pointer; width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.et-modal-x:hover { background: var(--et-border-light); }

.et-modal-body { padding: 18px 22px; }

/* Hand rule callout */
.et-hand-rule {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 13px; background: rgba(27,94,123,.06);
  border-left: 3px solid var(--et-primary);
  border-radius: 0 var(--et-r-sm) var(--et-r-sm) 0;
  font-size: .78rem; color: var(--et-primary); line-height: 1.5;
  margin-bottom: 16px;
}
.et-hand-rule svg { flex-shrink: 0; margin-top: 1px; }

/* Extent slider */
.et-extent-wrap { margin-bottom: 18px; }
.et-extent-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.et-extent-header label { font-size: .86rem; font-weight: 600; }
.et-extent-val { font-size: .86rem; font-weight: 700; color: var(--et-primary); }
.et-extent-slider { accent-color: var(--et-primary); }

/* Criteria divider */
.et-criteria-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--et-fg-muted); margin-bottom: 14px;
}
.et-criteria-divider::before,
.et-criteria-divider::after { content: ''; flex: 1; height: 1px; background: var(--et-border); }

/* Criteria list */
.et-criteria-list { display: flex; flex-direction: column; gap: 12px; }
.et-criterion {}
.et-criterion-info { margin-bottom: 6px; }
.et-criterion-label { font-size: .86rem; font-weight: 600; color: var(--et-fg); display: block; }
.et-criterion-desc { font-size: .74rem; color: var(--et-fg-muted); line-height: 1.4; }

.et-int-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.et-int {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; border: 1.5px solid var(--et-border);
  border-radius: 8px; background: #fff;
  font-size: .9rem; font-weight: 700; color: var(--et-fg-muted);
  transition: all .15s; line-height: 1; gap: 3px;
}
.et-int-lbl { font-size: .6rem; font-weight: 400; text-transform: uppercase; letter-spacing: .04em; }
.et-int:hover:not(.active) { border-color: var(--et-accent); color: var(--et-accent); }
.et-int.active { background: var(--et-primary); border-color: var(--et-primary); color: #fff; box-shadow: 0 3px 10px rgba(27,94,123,.25); }
.et-int.active .et-int-lbl { color: rgba(255,255,255,.75); }
.et-int[data-val="1"].active { background: #d97706; border-color: #d97706; }
.et-int[data-val="2"].active { background: #dc2626; border-color: #dc2626; }
.et-int[data-val="3"].active { background: #7f1d1d; border-color: #7f1d1d; }

.et-modal-foot {
  display: flex; gap: 10px;
  padding: 14px 22px 20px; border-top: 1px solid var(--et-border-light);
}
.et-btn-ghost {
  flex: 1; padding: 10px;
  background: #fff; border: 1.5px solid var(--et-border);
  border-radius: var(--et-r-sm); font-size: .88rem;
  color: var(--et-fg-muted); transition: all .15s;
}
.et-btn-ghost:hover { background: var(--et-bg); border-color: var(--et-fg-muted); }
.et-btn-primary {
  flex: 2; padding: 10px;
  background: var(--et-primary); border: none;
  border-radius: var(--et-r-sm); font-size: .88rem; font-weight: 600;
  color: #fff; transition: all .15s;
}
.et-btn-primary:hover { background: var(--et-accent); }

/* Rep site modal */
.et-rep-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.et-rep-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1.5px solid var(--et-border);
  border-radius: var(--et-r-sm); cursor: pointer; transition: all .15s;
}
.et-rep-item:hover { border-color: var(--et-accent); background: rgba(42,143,168,.04); }
.et-rep-item.selected { border-color: var(--et-primary); background: rgba(27,94,123,.06); }
.et-rep-item-label { flex: 1; font-size: .86rem; font-weight: 500; }
.et-rep-item-score {
  font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 12px;
}
.et-rep-item-score.s0 { background: #f1f5f9; color: var(--et-fg-muted); }
.et-rep-item-score.s1 { background: rgba(251,191,36,.2); color: #92400e; }
.et-rep-item-score.s2 { background: rgba(251,146,60,.2); color: #9a3412; }
.et-rep-item-score.s3 { background: rgba(239,68,68,.2); color: #991b1b; }
.et-rep-radio { width: 16px; height: 16px; accent-color: var(--et-primary); }

/* ── Print Report ─────────────────────────────────── */
.et-report { display: none; }
.et-report.et-report-hidden { display: none !important; }
.et-report.et-report-ready  { display: block; }

@media print {
  /* Hide everything on the page except the report */
  body * { visibility: hidden; }
  #et-report,
  #et-report * { visibility: visible; }
  #et-report {
    display: block !important;
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    background: white;
    z-index: 999999;
  }

  .et-report {
    font-family: 'DM Sans', sans-serif;
    color: #18293a; padding: 0; max-width: 100%;
  }
  .et-report-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding-bottom: 18px; border-bottom: 2px solid #1b5e7b; margin-bottom: 22px;
  }
  .et-report-logo-img { max-height: 50px; width: auto; }
  .et-report-site-name { font-family: 'Lora', Georgia, serif; font-size: 1.4rem; color: #1b5e7b; }
  .et-report-title { font-family: 'Lora', Georgia, serif; font-size: 1.3rem; color: #1b5e7b; margin: 0 0 6px; font-weight: 600; }
  .et-report-meta p { font-size: .82rem; margin: 2px 0; color: #5e7280; }
  .et-report-meta strong { color: #18293a; }

  .et-report-summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px;
  }
  .et-report-stat {
    padding: 12px 14px; background: #f4f7fa; border-radius: 8px;
    border: 1px solid #dce4ec;
  }
  .et-rs-label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #5e7280; margin-bottom: 4px; }
  .et-rs-val { display: block; font-family: 'Lora', Georgia, serif; font-size: 1.5rem; color: #1b5e7b; font-weight: 600; }

  .et-report-chart-wrap { margin-bottom: 22px; }

  .et-report-guidance {
    padding: 16px 20px; border-radius: 8px; border-left: 4px solid #1b5e7b;
    page-break-inside: avoid;
  }
  .et-report-guidance.mild     { background: #f0fdf4; border-color: #16a34a; }
  .et-report-guidance.moderate { background: #fff7ed; border-color: #ea580c; }
  .et-report-guidance.severe   { background: #fef2f2; border-color: #dc2626; }
  .et-guidance-title { font-size: 1rem; font-weight: 700; margin: 0 0 6px; }
  .et-guidance-title.mild     { color: #15803d; }
  .et-guidance-title.moderate { color: #c2410c; }
  .et-guidance-title.severe   { color: #b91c1c; }
  .et-guidance-body { font-size: .84rem; color: #374151; line-height: 1.6; margin: 0; }
}

/* ── Login notice ─────────────────────────────────── */
.et-login-notice {
  padding: 40px; text-align: center; background: var(--et-surface);
  border-radius: var(--et-r); border: 1px solid var(--et-border);
}
.et-login-notice p { color: var(--et-fg-muted); }
.et-login-notice a { color: var(--et-accent); font-weight: 600; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 720px) {
  .et-grid { grid-template-columns: 1fr; }
  .et-map-panel { border-right: none; border-bottom: 1px solid var(--et-border); }
  .et-form-panel { padding: 18px 16px; }
  .et-score-top { flex-direction: column; gap: 12px; }
  .et-score-num { font-size: 2.4rem; }
  .et-header { padding: 14px 18px; }
  .et-report-summary { grid-template-columns: repeat(2, 1fr); }
}
