/**
 * FlipZip PWA UI Styles
 * Paste this into your main stylesheet OR link as separate file
 * All components are namespaced with `fz-` to avoid conflicts
 */

/* ─── CSS VARIABLES ─────────────────────────────────────────────────────────── */
:root {
  --fz-primary: #FF5A1F;
  --fz-primary-dark: #E04010;
  --fz-primary-light: #FF7A45;
  --fz-bg: #ffffff;
  --fz-surface: #f8f8f8;
  --fz-border: #e8e8e8;
  --fz-text: #1a1a1a;
  --fz-text-muted: #888;
  --fz-success: #22c55e;
  --fz-warning: #f59e0b;
  --fz-error: #ef4444;
  --fz-nav-height: 64px;
  --fz-radius: 16px;
  --fz-shadow: 0 -2px 20px rgba(0,0,0,0.08);
  --fz-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --vh: 1vh; /* Set by pwa-init.js */
}

/* ─── GLOBAL MOBILE BASE ────────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  /* DO NOT put overscroll-behavior here — breaks page scroll on Android */
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* overscroll-behavior-y intentionally NOT set here — it breaks mobile scroll */
}

/* Padding for bottom nav — only on mobile, only when nav is visible */
@media (max-width: 768px) {
  body {
    /* Extra bottom padding so content isn't hidden behind the bottom nav.
       FlipZip already sets padding-bottom via its own CSS (!important),
       so we only nudge if that hasn't been applied. */
    padding-bottom: max(calc(58px + env(safe-area-inset-bottom)), var(--fz-nav-height, 64px)) !important;
  }
}

/* ─── BOTTOM NAVIGATION BAR ─────────────────────────────────────────────────── */
.fz-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--fz-nav-height);
  background: var(--fz-bg);
  border-top: 1px solid var(--fz-border);
  box-shadow: var(--fz-shadow);
  display: flex;
  align-items: stretch;
  z-index: 1000;
  /* Safe area for iPhone notch */
  padding-bottom: env(safe-area-inset-bottom);
  /* Only show on mobile */
  display: none;
  /* GPU acceleration */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

@media (max-width: 768px) {
  .fz-bottom-nav {
    display: flex;
  }
}

.fz-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--fz-text-muted);
  transition: color var(--fz-transition);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  border: none;
  background: none;
  padding: 8px 4px;
  font-family: inherit;
}

.fz-nav-item:active {
  transform: scale(0.92);
  transition: transform 0.1s;
}

.fz-nav-item.active {
  color: var(--fz-primary);
}

.fz-nav-item.active .fz-nav-icon {
  transform: translateY(-2px);
}

.fz-nav-icon {
  width: 24px;
  height: 24px;
  transition: transform var(--fz-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fz-nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fz-nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Active indicator dot */
.fz-nav-item.active::after {
  content: '';
  position: absolute;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fz-primary);
  animation: fz-dot-in 0.2s ease;
}

@keyframes fz-dot-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* Cart badge */
.fz-nav-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 18px);
  background: var(--fz-primary);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--fz-bg);
  animation: fz-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fz-badge-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ─── ONE-TAP CHECKOUT BUTTON ────────────────────────────────────────────────── */
.fz-one-tap-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--fz-bg);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 999;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fz-one-tap-bar.visible {
  transform: translateY(0);
}

/* On product pages, show above bottom nav */
.fz-pwa-product .fz-one-tap-bar {
  bottom: var(--fz-nav-height);
}

.fz-add-cart-btn {
  flex: 1;
  height: 50px;
  border: 2px solid var(--fz-primary);
  background: transparent;
  color: var(--fz-primary);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--fz-transition);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.fz-add-cart-btn:active {
  transform: scale(0.96);
  background: rgba(255, 90, 31, 0.08);
}

#fz-one-tap-btn {
  flex: 2;
  height: 50px;
  background: var(--fz-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--fz-transition);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(255, 90, 31, 0.35);
}

#fz-one-tap-btn:active {
  transform: scale(0.97);
  background: var(--fz-primary-dark);
  box-shadow: 0 2px 8px rgba(255, 90, 31, 0.25);
}

#fz-one-tap-btn.native-pay {
  background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.fz-pay-icon {
  font-size: 18px;
  line-height: 1;
}

/* ─── FAST CHECKOUT MODAL ─────────────────────────────────────────────────────── */
.fz-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fz-transition);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.fz-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.fz-checkout-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--fz-bg);
  border-radius: 20px 20px 0 0;
  z-index: 9001;
  padding: 8px 20px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  overflow-y: auto;
  /* overscroll-behavior: contain here is fine — scoped to modal only */
  overscroll-behavior-y: contain;
}

.fz-checkout-sheet.open {
  transform: translateY(0);
}

.fz-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--fz-border);
  margin: 0 auto 20px;
}

.fz-sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--fz-text);
  margin: 0 0 20px;
}

.fz-product-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--fz-surface);
  border-radius: 12px;
  margin-bottom: 20px;
}

.fz-product-summary img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--fz-border);
}

.fz-product-info {
  flex: 1;
}

.fz-product-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fz-text);
  margin: 0 0 4px;
}

.fz-product-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--fz-primary);
  margin: 0;
}

.fz-form-group {
  margin-bottom: 14px;
}

.fz-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fz-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.fz-form-group input,
.fz-form-group select,
.fz-form-group textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--fz-border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--fz-text);
  background: var(--fz-bg);
  box-sizing: border-box;
  transition: border-color var(--fz-transition);
  font-family: inherit;
  -webkit-appearance: none;
}

.fz-form-group input:focus,
.fz-form-group select:focus {
  outline: none;
  border-color: var(--fz-primary);
  box-shadow: 0 0 0 3px rgba(255, 90, 31, 0.1);
}

.fz-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fz-confirm-btn {
  width: 100%;
  height: 54px;
  background: var(--fz-primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
  transition: all var(--fz-transition);
  box-shadow: 0 4px 20px rgba(255, 90, 31, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.fz-confirm-btn:active {
  transform: scale(0.98);
}

.fz-secure-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--fz-text-muted);
}

/* ─── INSTALL PROMPT ─────────────────────────────────────────────────────────── */
#fz-install-prompt {
  position: fixed;
  bottom: calc(var(--fz-nav-height) + 12px);
  left: 12px;
  right: 12px;
  background: #1a1a1a;
  color: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  z-index: 2000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: translateY(120%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#fz-install-prompt.visible {
  transform: translateY(0);
}

.fz-install-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fz-install-icon img {
  border-radius: 12px;
  display: block;
}

.fz-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fz-install-text strong {
  font-size: 13px;
  font-weight: 700;
}

.fz-install-text span {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}

.fz-install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fz-btn-install {
  background: var(--fz-primary);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.fz-btn-dismiss {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── TOAST NOTIFICATIONS ────────────────────────────────────────────────────── */
#fz-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  white-space: nowrap;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

#fz-toast.visible {
  transform: translateX(-50%) translateY(0);
}

#fz-toast.fz-toast--success { background: var(--fz-success); }
#fz-toast.fz-toast--warning { background: var(--fz-warning); color: #1a1a1a; }
#fz-toast.fz-toast--error { background: var(--fz-error); }

/* ─── PULL TO REFRESH ────────────────────────────────────────────────────────── */
#fz-pull-refresh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--fz-text-muted);
  font-weight: 500;
  z-index: 5000;
  background: var(--fz-bg);
}

#fz-pull-refresh.ready {
  color: var(--fz-primary);
}

/* ─── UPDATE BANNER ──────────────────────────────────────────────────────────── */
#fz-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #1a1a1a;
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 9999;
  font-size: 13px;
  animation: fz-slide-down 0.3s ease;
}

@keyframes fz-slide-down {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

#fz-update-btn {
  background: var(--fz-primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ─── OFFLINE INDICATOR ──────────────────────────────────────────────────────── */
body.fz-offline::before {
  content: '📡 Offline mode';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--fz-warning);
  color: #1a1a1a;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  z-index: 9998;
}

/* ─── PAGE TRANSITIONS ───────────────────────────────────────────────────────── */
@keyframes fz-page-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fz-page-animate {
  animation: fz-page-in 0.3s ease forwards;
}

/* ─── SKELETON LOADING ───────────────────────────────────────────────────────── */
.fz-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: fz-shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes fz-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── SMOOTH SCROLL SNAP (for product image carousels) ───────────────────────── */
.fz-scroll-snap {
  scroll-snap-type: x mandatory;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.fz-scroll-snap::-webkit-scrollbar { display: none; }
.fz-scroll-snap > * { scroll-snap-align: start; }

/* ─── SAFE AREA UTILITIES ────────────────────────────────────────────────────── */
.fz-safe-top { padding-top: env(safe-area-inset-top); }
.fz-safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ─── RIPPLE EFFECT FOR BUTTONS ─────────────────────────────────────────────── */
.fz-ripple {
  position: relative;
  overflow: hidden;
}

.fz-ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  transition: opacity 0.3s;
}

.fz-ripple:active::after {
  opacity: 0.1;
}
