/* ✅ Cargar Ulm Grotesk SOLO para el título "Adray" */
@font-face {
  font-family: "UlmGrotesk";
  src: url("/fonts/UlmGrotesk-Bold.otf") format("opentype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

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

/* ================== BASE (DESKTOP FIRST) ================== */
html, body { height: 100%; }

body {
  font-family: "Inter", sans-serif;
  background: #0a0a12;
  color: #F4F2FF;

  /* Desktop: usamos “app shell” con scroll interno */
  display: block;
  overflow: hidden; /* el scroll lo maneja main-content en desktop */
}

/* Contenedor principal */
.onboarding-container {
  display: flex;
  width: min(1200px, calc(100% - 2rem));
  height: 90vh;
  max-height: 800px;
  margin: 1rem auto;
  background: rgba(16, 14, 26, 0.98);
  border-radius: 18px;
  box-shadow: 0 8px 40px 0 rgba(85, 34, 145, 0.20);
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: rgba(15, 15, 25, 1);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  border-right: 1.5px solid #23143A;
}

.logo { margin-bottom: 3rem; }

.logo h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: #A96BFF;
  letter-spacing: -1px;
  display: inline-flex;
  align-items: center;
  font-family: "UlmGrotesk","Ulm Grotesk","UlmGrotesk-Bold","Inter",sans-serif !important;
}

.emoji { margin-left: .5rem; }

.steps {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.step {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-radius: 9px;
  position: relative;
  transition: all .3s ease;
  background: transparent;
}

.step::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 100%;
  bottom: -1.5rem;
  width: 2px;
  background: #382058;
}

.step:last-child::after { display: none; }

.step-indicator {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(169, 107, 255, 0.13);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  color: #A96BFF;
  transition: all .3s ease;
  font-size: 1.1rem;
}

.step-text h3 {
  font-size: 1.08rem;
  margin-bottom: .22rem;
  font-weight: 700;
  color: #F4F2FF;
}

.step-text p {
  font-size: .91rem;
  color: #B6A7E8;
}

.step.active { background: rgba(169, 107, 255, 0.10); }

.step.active .step-indicator,
.step.completed .step-indicator {
  background: linear-gradient(90deg, #A96BFF 0%, #9333ea 100%);
  color: #fff;
}

.step.completed .step-indicator::after {
  content: "✓";
  color: #fff;
  font-size: 1.2rem;
}

/* ================== MAIN CONTENT (DESKTOP SCROLL) ================== */
.main-content {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto; /* ✅ aquí scrollea en desktop */
  background: none;
  position: relative;
  z-index: 2;

  scrollbar-width: thin;
  scrollbar-color: #3b2a5a #05040a;
}

.main-content::-webkit-scrollbar { width: 10px; }
.main-content::-webkit-scrollbar-track { background: #05040a; }
.main-content::-webkit-scrollbar-thumb {
  background: #2d2340;
  border-radius: 999px;
  border: 2px solid #05040a;
}
.main-content::-webkit-scrollbar-thumb:hover { background: #4b3c75; }

.hidden { display: none !important; }
.content-panel.hidden { display: none !important; }

.content-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.content-panel:not(.hidden) {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative;
  z-index: 3;
}

.content-panel h2 {
  font-size: 1.9rem;
  font-weight: 800;
  margin-bottom: .85rem;
  color: #A96BFF;
}

.panel-description {
  font-size: 1.06rem;
  color: #B6A7E8;
  margin-bottom: 2rem;
}

/* Cards */
.connection-cards {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  margin-top: 1.5rem;
  flex: 1;
}

.connection-card {
  background: rgba(169, 107, 255, 0.09);
  border-radius: 13px;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  border: 1px solid #382058;
}

.connection-card:hover {
  background: rgba(169, 107, 255, 0.14);
  border-color: #A96BFF;
}

.connection-details {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.connection-icon {
  width: 48px;
  height: 48px;
  background: rgba(169, 107, 255, 0.13);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.connection-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.18rem;
  color: #F4F2FF;
}

.connection-info p {
  font-size: 0.91rem;
  color: #C5B8E6;
  margin-bottom: 0.5rem;
}

.required-badge {
  background: rgba(236, 72, 153, 0.15);
  color: #ec4899;
  font-size: 0.79rem;
  padding: 0.22rem 0.5rem;
  border-radius: 5px;
  font-weight: 600;
}

.optional-badge {
  background: rgba(255, 255, 255, 0.11);
  color: #B6A7E8;
  font-size: 0.79rem;
  padding: 0.22rem 0.5rem;
  border-radius: 5px;
  font-weight: 600;
}

.btn-connect {
  background: rgba(169, 107, 255, 0.09);
  border: 1.5px solid #382058;
  color: #A96BFF;
  font-weight: 700;
  padding: 0.5rem 1.25rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.17s;
  font-family: "Inter", sans-serif;
  font-size: 1rem;
}

.btn-connect:hover {
  background: #22122F;
  color: #fff;
  border-color: #A96BFF;
}

.btn-connect.connected {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
}

/* Bottom actions */
.bottom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
}

.btn-continue,
.btn-gradient {
  background: linear-gradient(90deg, #A96BFF 0%, #9333ea 100%);
  border: none;
  color: #fff;
  font-weight: 700;
  padding: 0.75rem 2.1rem;
  border-radius: 7px;
  cursor: pointer;
  transition: opacity 0.17s;
  font-family: "Inter", sans-serif;
  font-size: 1.07rem;
}

.btn-continue:hover,
.btn-gradient:hover { opacity: 0.93; }

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

.btn-secondary {
  background: #241d36;
  color: #E3D6FF;
  border: none;
  font-weight: 600;
  border-radius: 0.5rem;
  transition: background 0.3s;
}

.btn-secondary:hover {
  background: #382058;
  color: #A96BFF;
}

/* =================== Step 2 (permissions) =================== */
.permissions-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 2rem; }

.permission-item {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  background: rgba(169, 107, 255, 0.09);
  border-radius: 9px;
}

.permission-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(90deg, #A96BFF 0%, #9333ea 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.permission-text h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.18rem;
  color: #F4F2FF;
}

.permission-text p { font-size: 0.91rem; color: #C5B8E6; }

/* =================== Step 3 (analysis) =================== */
.analysis-progress { margin-top: 2rem; }
.progress-container { margin-bottom: 2rem; }

.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-indicator {
  height: 100%;
  background: linear-gradient(90deg, #A96BFF 0%, #9333ea 100%);
  width: 0%;
  transition: width 0.5s ease;
}

.progress-text { font-size: 0.91rem; color: #B6A7E8; }

.analysis-steps { display: flex; flex-direction: column; gap: 1rem; }

.analysis-step { display: flex; align-items: center; gap: 1rem; }

.analysis-step-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(169, 107, 255, 0.13);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.96rem;
  color: #A96BFF;
}

.analysis-step.active .analysis-step-icon { background: #22122F; color: #fff; }

.analysis-step.completed .analysis-step-icon {
  background: linear-gradient(90deg, #A96BFF 0%, #9333ea 100%);
  color: #fff;
}

.analysis-step-text { font-size: 0.91rem; color: #B6A7E8; }
.analysis-step.completed .analysis-step-text { color: #fff; }

/* Aviso sutil (step 3) */
.analysis-hint {
  margin: 14px 0 22px;
  padding: 8px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #e4d8ff;
  border: 1px solid rgba(181, 92, 255, 0.5);
}

.analysis-hint-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #f9efff;
  background: radial-gradient(circle at 30% 30%, #A96BFF, #b55cff);
}

.analysis-hint-text { font-size: 0.78rem; opacity: 0.92; }

/* =================== Step 4 (ready) =================== */
body[data-page="onboarding4"] .content-panel {
  max-width: 700px;
  min-width: 360px;
  margin: auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: center;
}

body[data-page="onboarding4"] .ready-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =================== Tooltip wrapper (Shopify) =================== */
.connection-card .btn-tooltip-wrapper {
  position: relative;
  display: inline-flex;
  margin-left: auto;
  flex: 0 0 auto;
}

.connection-card .btn-tooltip-wrapper .btn-connect,
.connection-card > .btn-connect {
  min-width: 160px;
  text-align: center;
}

/* =================== ASM MODAL =================== */
:root {
  --bg-elev: hsl(260 20% 10% / .85);
  --bg-card: hsl(260 25% 8% / .75);
  --border: hsl(260 30% 40% / .22);
  --border-strong: hsl(265 100% 70% / .35);
  --txt: hsl(260 14% 96%);
  --txt-dim: hsl(260 10% 78%);
  --brand: #9a5bff;
  --brand-2: #7e4aed;
  --err: #ef4444;
  --shadow: 0 15px 50px hsl(260 60% 2% / .6);
}

#account-select-modal.hidden { display: none; }

#account-select-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 9999;
}

#account-select-modal .asm-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, hsl(260 32% 3% / .65), hsl(260 38% 2% / .75));
  backdrop-filter: blur(6px);
  animation: asmFade .2s ease-out;
}

#account-select-modal .asm-panel {
  position: relative;
  width: min(980px, 92vw);
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px 22px 16px;
  color: var(--txt);
  animation: asmPop .18s ease-out;
  overflow: hidden;
}

#account-select-modal .asm-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 18px;
  background:
    radial-gradient(200px 120px at 8% -10%, hsl(265 100% 70% / .18), transparent 70%),
    radial-gradient(200px 120px at 100% 0%, hsl(280 100% 63% / .12), transparent 70%);
  mix-blend-mode: screen;
}

#account-select-modal .asm-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .2px;
  margin: 6px 2px 4px;
}

#account-select-modal .asm-sub {
  margin: 0 2px 14px;
  color: var(--txt-dim);
}

#account-select-modal .asm-section-title {
  margin: 18px 2px 10px;
  font-weight: 600;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#account-select-modal .asm-section-title small {
  color: var(--txt-dim);
  font-weight: 600;
  background: hsl(265 60% 20% / .35);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
}

#account-select-modal .asm-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

@media (max-width: 900px) { #account-select-modal .asm-list { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { #account-select-modal .asm-list { grid-template-columns: 1fr; } }

#account-select-modal .asm-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: hsl(260 22% 8% / .55);
  transition: transform .06s ease, border-color .15s, background-color .15s;
  cursor: pointer;
  user-select: none;
}

#account-select-modal .asm-chip:hover {
  border-color: var(--border-strong);
  background: hsl(260 28% 10% / .6);
}

#account-select-modal .asm-chip:has(input:checked) {
  background: linear-gradient(180deg, hsl(265 50% 18% / .55), hsl(265 55% 14% / .55));
  border-color: hsl(265 100% 70% / .55);
  box-shadow: inset 0 0 0 1px hsl(265 100% 70% / .18);
}

#account-select-modal .asm-chip input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  display: grid;
  place-items: center;
  transition: all .15s ease;
}

#account-select-modal .asm-chip input[type="checkbox"]::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  transform: scale(0);
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  transition: transform .12s ease;
}

#account-select-modal .asm-chip input[type="checkbox"]:checked {
  border-color: hsl(265 100% 70% / .55);
  box-shadow: 0 0 0 3px hsl(265 100% 70% / .10);
}

#account-select-modal .asm-chip input[type="checkbox"]:checked::after { transform: scale(1); }

#account-select-modal .asm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

#account-select-modal .asm-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, opacity .2s;
}
#account-select-modal .asm-btn:active { transform: translateY(1px); }

#account-select-modal .asm-btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: white;
  box-shadow: 0 8px 28px hsl(265 90% 60% / .25);
}
#account-select-modal .asm-btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

@keyframes asmPop { from { transform: translateY(6px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes asmFade { from { opacity: 0; } to { opacity: 1; } }

/* =========================================================
   ✅ MOBILE E2E (iOS Safari)
   - Sin duplicados
   - Scroll natural (body)
   - Sidebar OFF (evita duplicar mobile-header)
   - Botones full width
   - Bottom-actions NO tapa CTAs
   ========================================================= */
@media (max-width: 1024px), (pointer: coarse) {
  html, body {
    height: auto !important;
    overflow-x: hidden !important;
  }

  body {
    overflow-y: auto !important;   /* ✅ scroll real en móvil */
    overflow-x: hidden !important;
  }

  .onboarding-container {
    flex-direction: column !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;

    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
  }

  /* ✅ elimina duplicado de steps/barra: el header móvil manda */
  .sidebar { display: none !important; }

  .main-content {
    padding: 16px !important;
    overflow: visible !important;  /* ✅ evita “no hay scroll” por contenedor */
    height: auto !important;
  }

  .content-panel {
    height: auto !important;
    min-height: 0 !important;
  }

  .connection-cards {
    flex: 0 0 auto !important;
    gap: 14px !important;
    margin-top: 14px !important;
  }

  .connection-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
    padding: 14px !important;
  }

  .connection-details { width: 100% !important; }

  /* Botones siempre full width */
  .connection-card > .btn-connect,
  .connection-card .btn-tooltip-wrapper {
    width: 100% !important;
    margin-left: 0 !important;
    align-self: stretch !important;
  }

  .connection-card .btn-tooltip-wrapper .btn-connect,
  .connection-card > .btn-connect {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Ajuste tooltip para no salirse del viewport */
  .connection-card .btn-tooltip {
    left: 0;
    right: auto;
    width: min(340px, 92vw);
  }

  /* Overrides para tus cards con estilos inline */
  #google-card,
  #meta-card {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  #google-card #connect-google-btn,
  #meta-card  #connect-meta-btn {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* ✅ Botón continuar: NO fixed/sticky (no tapa Facebook/Meta) */
  .bottom-actions {
    position: static !important;
    inset: auto !important;
    background: none !important;
    border: 0 !important;
    padding: 0 !important;
    margin-top: 16px !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }

  .btn-continue,
  .btn-gradient,
  .btn-secondary {
    width: 100% !important;
    min-height: 52px !important;
    border-radius: 14px !important;
    font-size: 18px !important;
  }

  /* Onboarding4: evita min-width que causa overflow horizontal */
  body[data-page="onboarding4"] .content-panel {
    min-width: 0 !important;
    padding: 0 16px !important;
    height: auto !important;
    justify-content: flex-start !important;
  }
}

/* Extra: iPhones muy chicos */
@media (max-width: 360px) {
  .content-panel h2 { font-size: 1.55rem; }
  .panel-description { font-size: 0.98rem; }
  .logo h1 { font-size: 1.6rem; }
}
