/* OwnServe Web Push opt-in — responsive centered modal.
   All selectors are namespaced under .ro-push-modal so they cannot leak into
   or clash with the theme, the restaurant menu, or other OwnServe styles.
   This is a UI-only layer: it never changes push/permission/security logic. */

/* ---- Backdrop (dimmed + blurred) ------------------------------------- */
.ro-push-modal {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Respect mobile safe areas so the modal never sits under a notch/home bar. */
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(17, 24, 39, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s ease;
  /* Allow internal scrolling ONLY if the dialog is taller than the viewport. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ro-push-modal.is-visible {
  opacity: 1;
}

/* ---- Dialog ---------------------------------------------------------- */
.ro-push-modal__dialog {
  position: relative;
  width: calc(100% - 32px);
  max-width: 400px;
  margin: auto;
  background: #ffffff;
  color: #1f2937;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  padding: 26px 24px 20px;
  text-align: center;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  outline: none;
}

.ro-push-modal.is-visible .ro-push-modal__dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ---- Close (x) ------------------------------------------------------- */
.ro-push-modal__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #9ca3af;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}

.ro-push-modal__close:hover { background: rgba(0, 0, 0, 0.05); color: #4b5563; }
.ro-push-modal__close:focus-visible { outline: 2px solid #e23744; outline-offset: 2px; }

/* ---- Header / body --------------------------------------------------- */
.ro-push-modal__icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 8px;
}

.ro-push-modal__title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
  color: #111827;
}

.ro-push-modal__desc {
  margin: 0 0 16px;
  color: #4b5563;
}

/* ---- Benefits -------------------------------------------------------- */
.ro-push-modal__benefits {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}

.ro-push-modal__benefits li {
  background: #f9fafb;
  border-radius: 10px;
  padding: 9px 12px;
  color: #374151;
  font-size: 13.5px;
}

/* ---- Actions --------------------------------------------------------- */
.ro-push-modal__actions {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.ro-push-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.ro-push-btn--primary {
  background: #e23744;
  color: #ffffff;
}

.ro-push-btn--primary:hover { background: #c62f3b; }
.ro-push-btn--primary:disabled { opacity: 0.6; cursor: default; }

.ro-push-btn--ghost {
  background: transparent;
  color: #6b7280;
  font-weight: 600;
  padding: 8px 16px;
}

.ro-push-btn--ghost:hover { background: rgba(0, 0, 0, 0.04); }
.ro-push-btn:focus-visible { outline: 2px solid #e23744; outline-offset: 2px; }

/* ---- Trust line ------------------------------------------------------ */
.ro-push-modal__trust {
  color: #9ca3af;
  font-size: 12px;
}

/* ---- Success state --------------------------------------------------- */
.ro-push-modal__dialog.is-success { padding-top: 30px; padding-bottom: 26px; }

/* ---- Very small screens (<= 360px): tighten spacing & type ----------- */
@media (max-width: 360px) {
  .ro-push-modal__dialog { padding: 22px 18px 18px; }
  .ro-push-modal__title { font-size: 17px; }
  .ro-push-modal__icon { font-size: 30px; }
  .ro-push-modal__benefits li { padding: 8px 10px; font-size: 13px; }
  .ro-push-btn { padding: 11px 14px; font-size: 14px; }
}

/* ---- Tablet: slightly wider comfortable modal ------------------------ */
@media (min-width: 768px) {
  .ro-push-modal__dialog { max-width: 420px; padding: 28px 26px 22px; }
}

/* ---- Desktop --------------------------------------------------------- */
@media (min-width: 1024px) {
  .ro-push-modal__dialog { max-width: 420px; padding: 30px 28px 24px; }
  .ro-push-modal__title { font-size: 20px; }
}

/* ---- Reduced motion -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ro-push-modal,
  .ro-push-modal__dialog {
    transition: none;
  }
  .ro-push-modal__dialog { transform: none; }
}

/* ---- Short viewports (e.g. landscape phones): never clip -------------
   When the dialog is taller than the viewport, align to the top and let the
   BACKDROP scroll internally (the dialog height stays natural — never fixed).
   This guarantees every control (incl. the CTA) is reachable and prevents any
   viewport overflow. */
@media (max-height: 520px) {
  .ro-push-modal {
    align-items: flex-start;
  }
  .ro-push-modal__dialog {
    margin-top: 12px;
    margin-bottom: 12px;
  }
}

/* ---- Dark mode ------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  .ro-push-modal__dialog {
    background: #1f2430;
    color: #e5e7eb;
  }
  .ro-push-modal__title { color: #f3f4f6; }
  .ro-push-modal__desc { color: #b6bcc7; }
  .ro-push-modal__benefits li { background: #262c3a; color: #d1d5db; }
  .ro-push-btn--ghost { color: #b6bcc7; }
  .ro-push-btn--ghost:hover { background: rgba(255, 255, 255, 0.06); }
  .ro-push-modal__close:hover { background: rgba(255, 255, 255, 0.08); color: #e5e7eb; }
  .ro-push-modal__trust { color: #8b93a1; }
}
