/**
 * Mediprev PWA - Estilos de los componentes de instalación y notificaciones
 * Encolado en WordPress via wp_enqueue_style()
 */

/* ─── BANNER DE INSTALACIÓN ─────────────────────────────────────────────── */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #ffffff;
  border-top: 3px solid #0077b6;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  font-family: inherit;
  animation: pwa-slide-up 0.3s ease-out;
}

#pwa-install-banner img {
  flex-shrink: 0;
  border-radius: 8px;
}

.pwa-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-install-text strong {
  font-size: 0.95rem;
  color: #0077b6;
}

.pwa-install-text span {
  font-size: 0.8rem;
  color: #555;
}

#pwa-install-btn {
  flex-shrink: 0;
  padding: 8px 18px;
  background: #0077b6;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#pwa-install-btn:hover,
#pwa-install-btn:focus {
  background: #005f8e;
  outline: 2px solid #005f8e;
  outline-offset: 2px;
}

#pwa-install-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
}

#pwa-install-dismiss:hover,
#pwa-install-dismiss:focus {
  color: #333;
  outline: 2px solid #0077b6;
  outline-offset: 2px;
}

/* ─── BANNER DE ACTUALIZACIÓN ───────────────────────────────────────────── */
#pwa-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: #0077b6;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: pwa-slide-down 0.3s ease-out;
}

#pwa-update-btn {
  padding: 6px 14px;
  background: #fff;
  color: #0077b6;
  border: none;
  border-radius: 5px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

#pwa-update-btn:hover,
#pwa-update-btn:focus {
  background: #e0f0fa;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#pwa-update-dismiss {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
}

#pwa-update-dismiss:hover,
#pwa-update-dismiss:focus {
  color: #fff;
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* ─── TOAST SIN CONEXIÓN ────────────────────────────────────────────────── */
#pwa-offline-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99998;
  padding: 10px 20px;
  background: #333;
  color: #fff;
  border-radius: 24px;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  animation: pwa-fade-in 0.3s ease-out;
}

/* ─── MODO STANDALONE ───────────────────────────────────────────────────── */
/* Ajustes cuando la app está instalada (sin barra del navegador) */
.pwa-standalone body {
  /* Espacio para la barra de estado en iOS */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── ANIMACIONES ───────────────────────────────────────────────────────── */
@keyframes pwa-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes pwa-slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@keyframes pwa-fade-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);    }
}

/* ─── BANNER iOS ────────────────────────────────────────────────────────── */
#pwa-ios-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  padding: 12px 16px 20px;
  background: #1c1c1e;
  color: #fff;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  border-radius: 16px 16px 0 0;
  animation: pwa-slide-up 0.35s ease-out;
  /* Espacio para la barra de inicio de iOS */
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.pwa-ios-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-ios-content img {
  flex-shrink: 0;
  border-radius: 10px;
}

.pwa-ios-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pwa-ios-text strong {
  font-size: 0.95rem;
  color: #fff;
}

.pwa-ios-text span {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.4;
}

.pwa-ios-share-icon {
  font-size: 1rem;
  vertical-align: middle;
}

#pwa-ios-dismiss {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.2s;
  align-self: flex-start;
}

#pwa-ios-dismiss:hover,
#pwa-ios-dismiss:focus {
  background: rgba(255, 255, 255, 0.25);
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Flechita apuntando hacia la barra inferior de Safari */
.pwa-ios-arrow {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #1c1c1e;
  margin: 6px auto 0;
}

/* ─── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #pwa-install-banner {
    flex-wrap: wrap;
  }

  .pwa-install-text {
    order: 2;
  }

  #pwa-install-btn {
    order: 3;
    width: 100%;
    text-align: center;
  }

  #pwa-install-dismiss {
    order: 1;
    margin-left: auto;
  }
}
