@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono&display=swap');

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

/* ══════════════════════════════════════════════
   MD3 LIGHT — Much Media brand palette
   Primary: Magenta #9E005D  Secondary: Gold #6B5B00
══════════════════════════════════════════════ */
:root {
  --md-sys-color-primary: #9E005D;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #FFD8F0;
  --md-sys-color-on-primary-container: #3D0025;
  --md-sys-color-secondary: #6B5B00;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #FFF0A0;
  --md-sys-color-on-secondary-container: #211B00;
  --md-sys-color-surface: #FFFBFF;
  --md-sys-color-surface-variant: #FCEAF4;
  --md-sys-color-on-surface: #1F1A1C;
  --md-sys-color-on-surface-variant: #514349;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #FEF1F8;
  --md-sys-color-surface-container: #FCE8F3;
  --md-sys-color-surface-container-high: #F6DEED;
  --md-sys-color-surface-container-highest: #F0D4E7;
  --md-sys-color-outline: #84737A;
  --md-sys-color-outline-variant: #D5BFC8;
  --md-sys-color-error: #B3261E;
  --md-sys-color-success: #146C2E;
  --md-sys-color-on-success: #FFFFFF;
  --md-sys-color-success-container: #C6EFD3;

  /* brand accent for gradients */
  --brand-yellow: #FFCC00;
  --brand-magenta: #E5007A;

  --md-elevation-1: 0 1px 2px rgba(0,0,0,.12), 0 1px 3px 1px rgba(0,0,0,.08);
  --md-elevation-2: 0 1px 2px rgba(0,0,0,.12), 0 2px 6px 2px rgba(0,0,0,.08);
  --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.12);

  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 100px;
}

/* ══════════════════════════════════════════════
   MD3 DARK — Much Media brand palette
   Primary: light magenta  Secondary: golden yellow
══════════════════════════════════════════════ */
[data-theme="dark"] {
  --md-sys-color-primary: #FFB2D9;
  --md-sys-color-on-primary: #620039;
  --md-sys-color-primary-container: #8A0052;
  --md-sys-color-on-primary-container: #FFD8F0;
  --md-sys-color-secondary: #E8C44C;
  --md-sys-color-on-secondary: #3A2F00;
  --md-sys-color-secondary-container: #544400;
  --md-sys-color-on-secondary-container: #FFF0A0;
  --md-sys-color-surface: #1A1118;
  --md-sys-color-surface-variant: #3E2F38;
  --md-sys-color-on-surface: #EDE0E7;
  --md-sys-color-on-surface-variant: #C9B8C2;
  --md-sys-color-surface-container-lowest: #140C12;
  --md-sys-color-surface-container-low: #221820;
  --md-sys-color-surface-container: #271D25;
  --md-sys-color-surface-container-high: #32272F;
  --md-sys-color-surface-container-highest: #3D313A;
  --md-sys-color-outline: #9A8891;
  --md-sys-color-outline-variant: #4D3D46;
  --md-sys-color-error: #F2B8B8;
  --md-sys-color-success: #6DD58C;
  --md-sys-color-on-success: #0A3818;
  --md-sys-color-success-container: #0A3818;

  --md-elevation-1: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px 1px rgba(0,0,0,.2);
  --md-elevation-2: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px 2px rgba(0,0,0,.2);
  --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,.2), 0 1px 3px rgba(0,0,0,.4);
}

/* ══════════════════════════════════════════════
   BASE
══════════════════════════════════════════════ */
body {
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  min-height: 100vh;
  padding: 24px 16px 80px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

/* ══════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════ */
header {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 8px;
  position: relative;
}

.header-logo {
  height: 90px;
  width: auto;
  max-width: 320px;
  object-fit: contain;
  transition: filter 0.3s;
}
/* En dark mode el texto negro del logo no se ve — lo ponemos sobre píldora blanca */
[data-theme="dark"] .header-logo-wrap {
  display: inline-block;
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  padding: 8px 20px;
}
.header-logo-wrap {
  display: inline-block;
}

.subtitle {
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 10px;
  font-size: 0.92rem;
  font-weight: 400;
}

/* ── Theme toggle ── */
.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-toggle-label {
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  user-select: none;
}

/* MD3-style switch */
.md-switch {
  position: relative;
  width: 52px;
  height: 32px;
  cursor: pointer;
}
.md-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.md-switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-variant);
  border: 2px solid var(--md-sys-color-outline);
  transition: background 0.25s, border-color 0.25s;
}
.md-switch input:checked ~ .md-switch-track {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}
.md-switch-thumb {
  position: absolute;
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), width 0.15s, height 0.15s, background 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.md-switch input:checked ~ .md-switch-thumb {
  transform: translateY(-50%) translateX(20px);
  width: 24px;
  height: 24px;
  left: 2px;
  background: var(--md-sys-color-on-primary);
}
/* Icon inside thumb */
.md-switch-thumb::after {
  content: '☀️';
  font-size: 10px;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.md-switch input:checked ~ .md-switch-thumb::after {
  content: '🌙';
  opacity: 1;
}

/* ══════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════ */
main {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════════════════════════════════════════
   CARD
══════════════════════════════════════════════ */
.card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 28px 24px;
  box-shadow: var(--md-elevation-1);
  border: 1px solid var(--md-sys-color-outline-variant);
  transition: box-shadow 0.2s, background 0.3s, border-color 0.3s;
}
.card:hover { box-shadow: var(--md-elevation-2); }

/* ══════════════════════════════════════════════
   TYPOGRAPHY
══════════════════════════════════════════════ */
.step-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.step-desc {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.88rem;
  margin-bottom: 24px;
  line-height: 1.55;
}

/* ══════════════════════════════════════════════
   FIELDS
══════════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.field.grow { flex: 1; margin-bottom: 0; }

/* ══════════════════════════════════════════════
   INPUTS & SELECTS (MD3 Outlined)
══════════════════════════════════════════════ */
select,
input[type="text"],
input[type="email"],
input[type="tel"] {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-small);
  color: var(--md-sys-color-on-surface);
  font-family: 'Roboto', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  padding: 14px 16px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s, background 0.3s;
}
select:hover,
input:hover { border-color: var(--md-sys-color-on-surface); }
select:focus,
input:focus {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  padding: 13px 15px;
}
select option { background: var(--md-sys-color-surface-container-high); }

/* ══════════════════════════════════════════════
   SEARCH ROW
══════════════════════════════════════════════ */
.search-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.search-row .grow { flex: 1; }
.search-row input[type="text"] { flex: 1; width: auto; }

/* ══════════════════════════════════════════════
   BUTTONS (MD3)
══════════════════════════════════════════════ */
.btn-primary,
.btn-secondary {
  font-family: 'Roboto', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
  padding: 0 24px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn-primary::after,
.btn-secondary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: inherit;
  pointer-events: none;
}
.btn-primary:hover::after { opacity: 0.08; }
.btn-primary:active::after { opacity: 0.12; }
.btn-secondary:hover::after { opacity: 0.08; }
.btn-secondary:active::after { opacity: 0.12; }

/* Filled */
.btn-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  width: 100%;
  margin-top: 8px;
  box-shadow: var(--md-elevation-1);
}
.btn-primary:hover:not(:disabled) { box-shadow: var(--md-elevation-2); }
.btn-primary:active:not(:disabled) { box-shadow: none; }
.btn-primary:disabled {
  background: rgba(28,27,31,.12);
  color: rgba(28,27,31,.38);
  box-shadow: none;
  cursor: not-allowed;
}
[data-theme="dark"] .btn-primary:disabled {
  background: rgba(230,225,229,.12);
  color: rgba(230,225,229,.38);
}

/* Tonal */
.btn-secondary {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  width: 100%;
  margin-top: 8px;
}
.btn-secondary:hover:not(:disabled) { box-shadow: var(--md-elevation-1); }
.btn-secondary:disabled {
  background: rgba(28,27,31,.12);
  color: rgba(28,27,31,.38);
  cursor: not-allowed;
}
[data-theme="dark"] .btn-secondary:disabled {
  background: rgba(230,225,229,.12);
  color: rgba(230,225,229,.38);
}

.btn-small {
  width: auto !important;
  min-width: 88px;
  max-width: 110px;
  padding: 0 16px;
  margin-top: 0;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════
   PHONE ROW
══════════════════════════════════════════════ */
.phone-row { display: flex; gap: 8px; align-items: stretch; }
.phone-row select { width: auto; flex-shrink: 0; }
.phone-row input { flex: 1; }

/* ══════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════
   RESULTS
══════════════════════════════════════════════ */
.results-label {
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface-variant);
  margin: 20px 0 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.results-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.results-list li::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-primary);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.results-list li:hover::after { opacity: 0.08; }
.results-list li:hover { border-color: var(--md-sys-color-primary); }

.r-icon {
  width: 40px;
  height: 40px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--md-sys-shape-corner-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.r-name { font-weight: 500; font-size: 0.95rem; color: var(--md-sys-color-on-surface); }
.r-id { font-size: 0.72rem; color: var(--md-sys-color-on-surface-variant); margin-top: 2px; font-family: 'Roboto Mono', monospace; }

/* ══════════════════════════════════════════════
   SELECTED PILL (MD3 Input chip)
══════════════════════════════════════════════ */
.selected-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  background: var(--md-sys-color-secondary-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 0.88rem;
  color: var(--md-sys-color-on-secondary-container);
  margin-top: 12px;
  font-weight: 500;
}
.selected-pill .remove-btn {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  font-size: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  margin-left: 8px;
  flex-shrink: 0;
}
.selected-pill .remove-btn:hover {
  background: rgba(179,38,30,.12);
  color: var(--md-sys-color-error);
}

/* ══════════════════════════════════════════════
   COMPETITOR BLOCKS
══════════════════════════════════════════════ */
.competitor-block {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.competitor-block:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.competitor-block > label {
  display: block;
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  margin-bottom: 12px;
}
.optional { font-size: 0.72rem; opacity: 0.6; }

/* ══════════════════════════════════════════════
   LOADING
══════════════════════════════════════════════ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 0;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid var(--md-sys-color-surface-container-highest);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(.4,0,.6,1) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-msg {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9rem;
}

/* ══════════════════════════════════════════════
   LEAD FORM
══════════════════════════════════════════════ */
#lead-form { display: flex; flex-direction: column; gap: 4px; }
#lead-form .field { margin-bottom: 8px; }

/* ══════════════════════════════════════════════
   CONFIRMATION
══════════════════════════════════════════════ */
.confirmation { text-align: center; padding: 24px 0; }
.check-icon {
  width: 72px;
  height: 72px;
  background: var(--md-sys-color-success-container);
  border: 2px solid var(--md-sys-color-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--md-sys-color-success);
  margin: 0 auto 24px;
}
.confirmation h2 { margin-bottom: 10px; font-size: 1.4rem; }
.confirmation .step-desc { margin-bottom: 32px; }
