/* ── BIDROI PWA Onboarding — bottom sheet ───────────────────────────────
   Usa exclusivamente CSS variables del proyecto.
   Compatible con dark/light mode (html.light override).
   No contiene colores hardcodeados.
──────────────────────────────────────────────────────────────────────── */

/* Overlay semitransparente detrás del sheet */
#pwa-ob-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: pwaFadeIn .25s ease both;
}

/* Bottom sheet contenedor */
#pwa-ob-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  /* Usa variables del proyecto — card bg + border */
  background: var(--card, #1A1A1A);
  border: 1px solid var(--border-s, rgba(255,255,255,.12));
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  box-shadow: 0 -8px 40px rgba(0,0,0,.45);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  color: var(--t1, #F0F0F0);
  max-width: 480px;
  /* Centrar en pantallas anchas */
  margin: 0 auto;
  /* Forzar que el position:fixed respete max-width */
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  animation: none;
}

/* Cuando se muestra — slide up */
#pwa-ob-sheet.pwa-ob-visible {
  display: block;
  animation: pwaSlideUp .32s cubic-bezier(.22, 1, .36, 1) both;
}

/* Cuando se cierra — slide down */
#pwa-ob-sheet.pwa-ob-closing {
  animation: pwaSlideDown .22s ease-in forwards;
}

@keyframes pwaFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pwaSlideUp {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0); }
}

@keyframes pwaSlideDown {
  from { transform: translateX(-50%) translateY(0); }
  to   { transform: translateX(-50%) translateY(110%); }
}

/* Handle / pill de arrastre visual */
#pwa-ob-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--t3, #666);
  margin: 12px auto 0;
  opacity: .4;
}

/* Contenido interno */
#pwa-ob-inner {
  padding: 16px 20px 20px;
}

/* Fila superior: logo + título + X */
#pwa-ob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#pwa-ob-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

#pwa-ob-brand-name {
  font-size: .9rem;
  font-weight: 900;
  letter-spacing: -.3px;
  color: var(--t1, #F0F0F0);
}

#pwa-ob-brand-sub {
  font-size: .7rem;
  color: var(--t2, #AAAAAA);
  margin-top: 1px;
}

#pwa-ob-close {
  background: var(--nav-pill-bg, rgba(255,255,255,.05));
  border: 1px solid var(--border, rgba(255,255,255,.07));
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--t2, #AAAAAA);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

#pwa-ob-close:hover {
  color: var(--t1, #F0F0F0);
  background: var(--logout-hover-bg, rgba(255,255,255,.1));
}

/* Cuerpo — instrucciones */
#pwa-ob-body {
  font-size: .82rem;
  line-height: 1.65;
  color: var(--t2, #AAAAAA);
}

#pwa-ob-body strong {
  color: var(--t1, #F0F0F0);
  font-weight: 600;
}

/* Pasos numerados para iOS */
.pwa-ob-steps {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pwa-ob-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.pwa-ob-step-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--mint-bg, rgba(46,224,164,.12));
  border: 1px solid var(--mint, #2EE0A4);
  color: var(--mint, #2EE0A4);
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.pwa-ob-step-text {
  font-size: .8rem;
  color: var(--t2, #AAAAAA);
  line-height: 1.5;
}

.pwa-ob-step-text strong {
  color: var(--t1, #F0F0F0);
}

/* Íconos SVG inline en instrucciones */
.pwa-ob-icon {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 2px;
  color: var(--mint, #2EE0A4);
}

/* Botón primario — instalar (Android Chrome) */
#pwa-ob-install-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: .65rem 1rem;
  border-radius: var(--r, 10px);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 700;
  background: var(--mint, #2EE0A4);
  color: #101010;
  transition: opacity .15s;
}

#pwa-ob-install-btn:hover {
  opacity: .88;
}

#pwa-ob-install-btn:active {
  opacity: .75;
}

/* Nota WebView */
#pwa-ob-webview-note {
  font-size: .78rem;
  color: var(--t2, #AAAAAA);
  line-height: 1.55;
  text-align: center;
  padding: 4px 0 2px;
}

#pwa-ob-webview-note strong {
  color: var(--mint, #2EE0A4);
}

/* Responsive: en desktop nunca se muestra (ver JS) */
@media (min-width: 768px) {
  #pwa-ob-overlay,
  #pwa-ob-sheet {
    display: none !important;
  }
}

/* ── iOS Safari Coach Marks — full-screen overlay ──────────────────────── */

#pwa-cm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.82);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  /* fade in */
  animation: pwaFadeIn .25s ease both;
}

#pwa-cm-overlay.pwa-cm-visible {
  display: flex;
  flex-direction: column;
}

/* Step fade transition */
.pwa-cm-step {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity .3s ease;
}

.pwa-cm-step.pwa-cm-step-active {
  display: flex;
  opacity: 1;
}

/* Close button top-right */
.pwa-cm-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 16px));
  right: 16px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,.7);
  padding: 0;
  z-index: 10;
  transition: background .15s, color .15s;
}

.pwa-cm-close:hover,
.pwa-cm-close:active {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* Text block — centered vertically ~40% from top */
.pwa-cm-text {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: min(320px, calc(100vw - 48px));
  pointer-events: none;
}

.pwa-cm-title {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  margin: 0 0 10px;
  letter-spacing: -.3px;
}

.pwa-cm-subtitle {
  font-size: 15px;
  font-weight: 400;
  color: rgba(255,255,255,.78);
  line-height: 1.55;
  margin: 0;
}

.pwa-cm-subtitle strong {
  color: #fff;
  font-weight: 700;
}

.pwa-cm-subtitle .pwa-cm-icon-inline {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 3px -2px;
  color: var(--mint, #2EE0A4);
}

/* Progress dots */
.pwa-cm-dots {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 24px) + 28px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.pwa-cm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.28);
  transition: background .25s, transform .25s;
}

.pwa-cm-dot.active {
  background: var(--mint, #2EE0A4);
  transform: scale(1.2);
}

/* "Listo" button — step 3 only */
.pwa-cm-done-btn {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 24px) + 64px);
  left: 50%;
  transform: translateX(-50%);
  padding: .7rem 2.2rem;
  border: none;
  border-radius: 50px;
  background: var(--mint, #2EE0A4);
  color: #101010;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}

.pwa-cm-done-btn:active {
  opacity: .8;
}

/* Arrow container — absolute positioned per step */
.pwa-cm-arrow-wrap {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Step 1: arrow bottom-right pointing down-right toward ··· */
.pwa-cm-arrow-br {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  right: 20px;
  width: 56px;
  height: 56px;
  animation: pwaBounceDownRight 1.1s ease-in-out infinite;
}

/* Step 2: arrow bottom-center pointing down toward share sheet */
.pwa-cm-arrow-bc {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  animation: pwaBounceDown 1.1s ease-in-out infinite;
}

/* Step 3: no arrow needed (action is in appeared sheet — we just show text) */

@keyframes pwaBounceDown {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(8px); }
}

@keyframes pwaBounceDownRight {
  0%, 100% { transform: translate(0, 0); }
  50%       { transform: translate(5px, 8px); }
}

/* Tap hint pulse ring */
.pwa-cm-tap-hint {
  font-size: 12px;
  color: rgba(255,255,255,.45);
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 24px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: .3px;
}

/* Step 3 has a done button so push tap hint above it */
.pwa-cm-step:last-child .pwa-cm-tap-hint {
  display: none;
}

/* Light mode — overlay invertido: fondo claro, texto oscuro */
html.light #pwa-cm-overlay {
  background: rgba(250, 250, 252, 0.96);
}

html.light .pwa-cm-close {
  background: rgba(0,0,0,.07);
  border-color: rgba(0,0,0,.12);
  color: rgba(0,0,0,.55);
}

html.light .pwa-cm-close:hover,
html.light .pwa-cm-close:active {
  background: rgba(0,0,0,.13);
  color: rgba(0,0,0,.85);
}

html.light .pwa-cm-title {
  color: #0a0a0a;
}

html.light .pwa-cm-subtitle {
  color: rgba(0,0,0,.6);
}

html.light .pwa-cm-subtitle strong {
  color: #0a0a0a;
}

html.light .pwa-cm-dot {
  background: rgba(0,0,0,.18);
}

html.light .pwa-cm-tap-hint {
  color: rgba(0,0,0,.35);
}

@media (min-width: 768px) {
  #pwa-cm-overlay {
    display: none !important;
  }
}
