/* Variables */
:root {
  --gray-950: #020617;
  --gray-900: #0f172a;
  --gray-800: #1e293b;
  --gray-700: #334155;
  --base:     var(--gray-950);
  --surface:  #0b1220;
  --elevated: var(--gray-900);
  --overlay:  var(--gray-800);

  --primary:      #f2f4f7;
  --secondary:    #d1d8e6;
  --muted:        #9aa6b8;
  --border:       rgba(160,175,200,.14);
  --border-strong:rgba(160,175,200,.28);

  --accent:       #7c6bf0;
  --accent-rgb:   124,107,240;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #3b82f6;

  --shadow-console: 0 20px 70px rgba(2,6,23,.55), inset 0 1px 0 rgba(255,255,255,.045);
  --radius-ui: 12px;
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  min-width: 320px;
  background: var(--gray-950);
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at 50% -10%, rgba(var(--accent-rgb),.12), transparent 32rem),
    linear-gradient(180deg, var(--gray-950) 0%, var(--base) 46%, #050816 100%);
  color: var(--primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* Portal shell */
.portal-shell {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  background:
    radial-gradient(circle at 14% -12%, rgba(var(--accent-rgb),.16), transparent 28rem),
    radial-gradient(circle at 92% 8%, rgba(34,197,94,.055), transparent 22rem),
    linear-gradient(180deg, var(--gray-950) 0%, #050a14 46%, var(--gray-950) 100%);
}

.portal-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(rgba(148,163,184,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.018) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.72), transparent 78%);
}

.portal-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgba(255,255,255,.055), transparent 30rem);
  mix-blend-mode: screen;
  opacity: .7;
}

/* Header */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(148,163,184,.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent),
    rgba(2,6,23,.78);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  box-shadow: 0 18px 42px rgba(2,6,23,.28);
}

.modern-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  width: min(100%, 80rem);
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 32px);
}

.modern-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.modern-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 11px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(var(--accent-rgb),.22), inset 0 1px 0 rgba(255,255,255,.18);
  overflow: hidden;
}

.modern-avatar img { width: 100%; height: 100%; object-fit: contain; }

.modern-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.modern-brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modern-brand-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
}

.modern-header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  white-space: nowrap;
}

.modern-header-badge svg { color: var(--accent); }

/* Main content */
.portal-main {
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  padding: clamp(20px,2.5vw,40px) clamp(16px,3vw,48px) clamp(28px,3vw,56px);
}

.portal-title {
  font-size: clamp(22px,2.8vw,32px);
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: 0;
}

.portal-subtitle {
  margin: 8px 0 0;
  color: var(--secondary);
  font-size: clamp(14px,1.3vw,16px);
  line-height: 1.5;
  max-width: 500px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-row svg { color: var(--accent); flex-shrink: 0; }

/* Platform grid */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 88px), 1fr));
  gap: clamp(6px,1vw,12px);
  margin-top: clamp(16px,2vw,28px);
}

.platform-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 82px;
  padding: 4px;
  border: 1px solid rgba(148,163,184,.2);
  border-radius: var(--radius-ui);
  background:
    linear-gradient(180deg, rgba(255,255,255,.032), transparent 42%),
    linear-gradient(145deg, rgba(15,23,42,.94), rgba(2,6,23,.74));
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 14px 32px rgba(2,6,23,.28), inset 0 1px 0 rgba(255,255,255,.035);
  transition: transform 200ms cubic-bezier(.22,1,.36,1), border-color 200ms, background 200ms, box-shadow 200ms;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.platform-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb),.2), transparent 42%),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.08), transparent 65%);
  transition: opacity 300ms;
  pointer-events: none;
}

.platform-card.active::before { opacity: 1; }

.platform-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb),.46);
  box-shadow: 0 18px 44px rgba(2,6,23,.48), 0 0 0 1px rgba(var(--accent-rgb),.12);
}

.platform-card.active {
  animation: selectedGlow 3s ease-in-out infinite;
}

.platform-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  padding: 6px;
  border-radius: 10px;
}

/* Step sections */
.step-section {
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 44%),
    rgba(15,23,42,.74);
  padding: 18px 20px;
  backdrop-filter: blur(12px);
  transition: opacity .4s cubic-bezier(.22,1,.36,1),
              transform .4s cubic-bezier(.22,1,.36,1),
              filter .4s ease,
              max-height .4s cubic-bezier(.22,1,.36,1),
              margin .4s cubic-bezier(.22,1,.36,1),
              padding .4s cubic-bezier(.22,1,.36,1);
  transform-origin: top center;
}

.step-section.collapsed {
  opacity: 0;
  transform: translateY(-12px) scale(.96);
  filter: blur(2px);
  pointer-events: none;
  max-height: 0;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden;
}

.step-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

/* Option pills */
.option-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-ui);
  border: 1px solid rgba(148,163,184,.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 50%),
    linear-gradient(145deg, rgba(15,23,42,.92), rgba(2,6,23,.82));
  color: var(--secondary);
  font-size: 14px;
  font-weight: 600;
  transition: all 180ms cubic-bezier(.22,1,.36,1);
  cursor: pointer;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.option-pill:hover {
  border-color: rgba(var(--accent-rgb),.38);
  transform: translateY(-1px);
  color: var(--primary);
  box-shadow: 0 10px 26px rgba(2,6,23,.32);
}

.option-pill.selected {
  font-weight: 700;
  color: var(--primary);
}

/* Email input */
.email-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 500px) {
  .email-row { flex-direction: row; align-items: flex-start; }
}

.input-wrap {
  position: relative;
  flex: 1;
}

.input-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input-field {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ui);
  background: rgba(2,6,23,.6);
  color: var(--primary);
  font-size: 15px;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}

.input-field::placeholder { color: var(--muted); }

.input-field:focus {
  border-color: rgba(var(--accent-rgb),.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.1);
}

.input-field.error {
  border-color: rgba(239,68,68,.5);
  box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}

.error-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(239,68,68,.2);
  background: rgba(239,68,68,.08);
  font-size: 13px;
  color: var(--secondary);
  line-height: 1.5;
}

.error-msg svg { flex-shrink: 0; margin-top: 2px; color: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 180ms cubic-bezier(.22,1,.36,1);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), rgba(var(--accent-rgb),.8));
  color: #fff;
  box-shadow: 0 8px 24px rgba(var(--accent-rgb),.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(var(--accent-rgb),.45);
}

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

.btn-secondary {
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  color: var(--secondary);
}

.btn-secondary:hover {
  background: var(--overlay);
  transform: translateY(-1px);
}

/* Result card */
.result-hero {
  animation: resultHeroEnter .6s cubic-bezier(.22,1,.36,1) both;
}

.result-card {
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.22);
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 42%),
    linear-gradient(145deg, rgba(15,23,42,.94), rgba(2,6,23,.86));
  box-shadow: var(--shadow-console);
}

.result-platform-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 20px;
}

.result-platform-header img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  padding: 6px;
  border-radius: 14px;
  margin-bottom: 12px;
}

.result-platform-header h3 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.result-platform-header p {
  margin-top: 4px;
  font-size: 13px;
  color: var(--secondary);
}

/* Code display */
.code-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.code-display {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px,1.4vw,6px);
  border-radius: 14px;
  padding: clamp(12px,3vw,20px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 42px rgba(2,6,23,.34);
  max-width: 100%;
}

.code-digit {
  display: inline-flex;
  width: clamp(32px,10vw,42px);
  height: clamp(44px,13vw,52px);
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #fff;
  font-size: clamp(22px,7vw,28px);
  font-weight: 900;
  line-height: 1;
}

.code-copy-btn {
  display: inline-grid;
  place-items: center;
  width: clamp(36px,10vw,42px);
  height: clamp(36px,10vw,42px);
  margin-left: clamp(2px,1vw,6px);
  border: 1px solid rgba(148,163,184,.2);
  border-radius: 11px;
  background: rgba(2,6,23,.5);
  transition: transform 180ms, border-color 180ms, background 180ms;
}

.code-copy-btn:hover {
  transform: translateY(-1px) scale(1.03);
  border-color: rgba(var(--accent-rgb),.42);
  background: rgba(15,23,42,.82);
}

/* Countdown */
.countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 300px;
}

.countdown-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.countdown-text svg { width: 14px; height: 14px; }

.countdown-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
}

.countdown-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 1s linear;
}

/* Link result */
.link-result {
  margin-bottom: 20px;
  border-radius: 14px;
  border: 1px solid rgba(59,130,246,.2);
  background: rgba(59,130,246,.05);
  padding: 20px;
  text-align: center;
}

.link-result svg { color: var(--info); }
.link-result p { font-size: 14px; color: var(--secondary); margin: 10px 0 14px; }

/* Action bar */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.action-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-ui);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(255,255,255,.04), transparent), var(--elevated);
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms;
  white-space: nowrap;
}

.action-bar-btn:hover {
  background: var(--overlay);
  transform: translateY(-1px);
}

.action-bar-whatsapp {
  border-color: rgba(34,197,94,.3);
  color: #22c55e;
  background: rgba(34,197,94,.08);
}

.action-bar-whatsapp:hover {
  background: rgba(34,197,94,.15);
  border-color: rgba(34,197,94,.5);
}

/* Nueva consulta */
.new-query-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  animation: fadeSlideUp .5s .3s cubic-bezier(.22,1,.36,1) both;
}

.new-query-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-ui);
  border: 1px solid rgba(var(--accent-rgb),.34);
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 48%),
    linear-gradient(145deg, var(--elevated), rgba(var(--accent-rgb),.12));
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms cubic-bezier(.22,1,.36,1);
  box-shadow: 0 14px 30px rgba(2,6,23,.42), inset 0 1px 0 rgba(255,255,255,.06);
}

.new-query-btn:hover {
  border-color: rgba(var(--accent-rgb),.5);
  box-shadow: 0 18px 38px rgba(2,6,23,.48), 0 0 26px rgba(var(--accent-rgb),.16);
  transform: translateY(-1px);
}

/* Error state */
.error-state {
  border-radius: 16px;
  border: 1px solid rgba(239,68,68,.2);
  background: rgba(239,68,68,.05);
  padding: 24px;
  text-align: center;
}

.error-state h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 12px 0 8px;
}

.error-state p {
  font-size: 14px;
  color: var(--secondary);
  max-width: 420px;
  margin: 0 auto 16px;
  line-height: 1.5;
}

.error-state svg { color: var(--danger); }

/* Aviso de mantenimiento (opcional) */
.status-notice {
  border-radius: 16px;
  border: 1px solid rgba(245,158,11,.2);
  background: rgba(245,158,11,.05);
  padding: 24px;
  text-align: center;
}

.status-notice h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 12px 0 8px;
}

.status-notice p {
  font-size: 14px;
  color: var(--secondary);
  max-width: 420px;
  margin: 0 auto;
}

.status-notice svg { color: var(--warning); }

/* Help panel */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (min-width: 900px) {
  .content-grid { grid-template-columns: minmax(0,1fr) 300px; }
  .content-grid.full { grid-template-columns: 1fr; max-width: 720px; margin-inline: auto; }
}

.help-panel {
  position: sticky;
  top: 80px;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.18);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 44%),
    rgba(15,23,42,.74);
  padding: 20px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-console);
  display: none;
}

@media (min-width: 900px) {
  .help-panel { display: block; }
}

.help-panel h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}

.help-panel h3 svg { color: var(--accent); }

.help-steps {
  list-style: none;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.help-step {
  display: flex;
  gap: 12px;
}

.help-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.help-step p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--secondary);
  padding-top: 4px;
}

.help-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
  color: var(--secondary);
}

.help-footer strong { color: var(--primary); }
.help-footer .brand-accent { font-weight: 600; color: var(--accent); }

/* Layout */
.steps-stack { display: flex; flex-direction: column; gap: 20px; }

/* Animations */
.spin { animation: spin .8s linear infinite; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes resultHeroEnter {
  0%   { opacity: 0; transform: translateY(24px) scale(.97); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes selectedGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(var(--accent-rgb),.3), 0 16px 38px rgba(2,6,23,.48), 0 0 24px rgba(var(--accent-rgb),.15); }
  50%       { box-shadow: 0 0 0 1px rgba(var(--accent-rgb),.5), 0 18px 44px rgba(2,6,23,.52), 0 0 34px rgba(var(--accent-rgb),.3); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.animate-enter    { animation: fadeSlideUp .55s cubic-bezier(.22,1,.36,1) both; }
.animate-enter-d1 { animation-delay: .06s; }
.animate-enter-d2 { animation-delay: .14s; }

/* Mobile */
@media (max-width: 640px) {
  .portal-shell { overflow-x: hidden; }

  .modern-header { min-height: 52px; padding-inline: 16px; }
  .modern-brand-name { font-size: 15px; max-width: 200px; }
  .modern-brand-tag  { font-size: 11px; }
  .modern-header-badge span { display: none; }

  .portal-main {
    padding: 20px 16px 28px;
    width: calc(100vw - 0px);
    max-width: 100vw;
    overflow-x: hidden;
  }

  .platform-grid {
    grid-template-columns: repeat(3, minmax(0,1fr)) !important;
    gap: 8px;
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }

  .platform-card {
    min-height: 76px;
    border-radius: 11px;
    font-size: 12px;
    gap: 3px;
  }

  .option-pill {
    padding: 8px 14px;
    font-size: 12px;
    min-width: 100px;
  }

  .result-card { padding: 16px; }

  .action-bar-btn {
    padding: 9px 16px;
    font-size: 12px;
  }
}

@media (max-width: 460px) {
  .option-pill {
    padding: 7px 12px;
    font-size: 11px;
    min-width: 90px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
  }
}
