/* Universal PWA Builder – Frontend */

/* Header / floating install icon – phone icon */
.upwa-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin: 0 4px;
  color: var(--upwa-icon-color, #0f172a);
  line-height: 1;
  vertical-align: middle;
  transition: opacity 0.2s ease;
}
.upwa-header-icon:hover {
  opacity: 0.75;
}
.upwa-header-icon svg {
  width: var(--upwa-icon-size, 24px);
  height: var(--upwa-icon-size, 24px);
  display: block;
}

/* Floating install icon – centre of the right edge */
#upwa-header-install-btn:not(.upwa-menu-icon) {
  position: fixed;
  top: 50%;
  right: max(8px, env(safe-area-inset-right));
  transform: translateY(-50%);
  z-index: 99990;
  background: #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  padding: 0;
  margin: 0;
}
#upwa-header-install-btn:not(.upwa-menu-icon) svg {
  width: calc(var(--upwa-icon-size, 24px) * 0.75);
  height: calc(var(--upwa-icon-size, 24px) * 0.75);
}
.upwa-menu-item {
  list-style: none;
  display: inline-flex;
  align-items: center;
}

.upwa-mobile-only {
  display: none;
}
@media (max-width: 782px) {
  .upwa-mobile-only {
    display: inline-flex;
  }
  .upwa-desktop-only {
    display: none !important;
  }
}
@media (min-width: 783px) {
  .upwa-desktop-only {
    display: inline-flex;
  }
}

/* Popup */
.upwa-popup {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.upwa-popup[hidden] {
  display: none !important;
}

.upwa-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.upwa-popup-card {
  position: relative;
  background: #fff;
  border-radius: 16px 16px 12px 12px;
  padding: 24px 20px 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
  animation: upwa-slide-up 0.3s ease;
}

@keyframes upwa-slide-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.upwa-popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
}
.upwa-popup-close:hover {
  color: #0f172a;
}

.upwa-popup-icon-wrap {
  margin-bottom: 12px;
}
.upwa-popup-icon-wrap img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.upwa-popup-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.upwa-popup-text {
  margin: 0 0 20px;
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.45;
}

.upwa-popup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.upwa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  min-width: 110px;
}
.upwa-btn:active {
  transform: scale(0.97);
}

.upwa-btn-primary {
  background: #0f172a;
  color: #fff;
}
.upwa-btn-primary:hover {
  background: #1e293b;
}

.upwa-btn-secondary {
  background: #f1f5f9;
  color: #334155;
}
.upwa-btn-secondary:hover {
  background: #e2e8f0;
}

.upwa-instructions {
  margin-top: 16px;
  text-align: left;
  font-size: 0.875rem;
  color: #475569;
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.5;
}
.upwa-instructions ol {
  margin: 6px 0 0 1.1em;
  padding: 0;
}
.upwa-instructions li {
  margin-bottom: 4px;
}

/* Shortcode / block button default */
.upwa-install-btn {
  cursor: pointer;
}

/* Prevent body scroll when popup open */
body.upwa-popup-open {
  overflow: hidden;
}

/* Desktop: center the card instead of bottom sheet feel */
@media (min-width: 600px) {
  .upwa-popup {
    align-items: center;
  }
  .upwa-popup-card {
    border-radius: 16px;
  }
}

/* ========== Launcher Screen ========== */
.upwa-launcher {
  position: fixed;
  inset: 0;
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--upwa-bg, #ffffff);
  padding: 24px 16px;
  box-sizing: border-box;
}
.upwa-launcher[hidden] {
  display: none !important;
}

.upwa-launcher-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.upwa-launcher-icon-wrap {
  margin-bottom: 16px;
}
.upwa-launcher-icon-wrap img {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.upwa-launcher-title {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.upwa-launcher-subtitle {
  margin: 0 0 28px;
  font-size: 0.95rem;
  color: #64748b;
  line-height: 1.4;
}

.upwa-launcher-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upwa-launcher-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--upwa-theme, #0f172a);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  box-sizing: border-box;
}
.upwa-launcher-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  color: #fff;
  text-decoration: none;
}
.upwa-launcher-btn:active {
  transform: scale(0.98);
}

body.upwa-launcher-open {
  overflow: hidden;
}

/* Author display rules (e.g. .upwa-btn) otherwise override the [hidden] attribute */
.upwa-btn[hidden],
.upwa-instructions[hidden],
.upwa-launcher-btn[hidden] {
  display: none !important;
}

/* Play Store button (third action, full width under Install / Not Now) */
.upwa-btn-playstore {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  gap: 10px;
  margin-top: 12px;
  background: #0f172a;
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
}
.upwa-btn-playstore:hover {
  background: #1e293b;
  color: #fff;
}

.upwa-btn-playstore[hidden] {
  display: none !important;
}

/* Keep the icon hidden until its installed state has been checked. */
#upwa-header-install-btn[hidden],
.upwa-menu-item[hidden] {
  display: none !important;
}
