/* WP PWA Studio v3 — App Shell */
#wppwa-shell { display: none; }
html.wppwa-app #wppwa-shell { display: block; }

html.wppwa-app {
  --wppwa-top-h: 52px;
  --wppwa-tab-h: 58px;
  --wppwa-safe-top: env(safe-area-inset-top, 0px);
  --wppwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  margin-top: 0 !important;
}
html.wppwa-app #wpadminbar,
html.wppwa-standalone #wppwa-install-btn,
html.wppwa-app #wppwa-ios-banner { display: none !important; }

html.wppwa-app body.wppwa-has-top  { padding-top: calc(var(--wppwa-top-h) + var(--wppwa-safe-top)) !important; }
html.wppwa-app body.wppwa-has-tabs { padding-bottom: calc(var(--wppwa-tab-h) + var(--wppwa-safe-bottom)) !important; }
html.wppwa-app body.wppwa-has-tabs #wppwa-install-btn { bottom: calc(var(--wppwa-tab-h) + var(--wppwa-safe-bottom) + 12px) !important; }

.wppwa-shell, .wppwa-shell * { box-sizing: border-box; }
.wppwa-shell { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
.wppwa-shell.no-select { -webkit-user-select: none; user-select: none; }
html.wppwa-app body:has(.wppwa-shell.no-select) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.wppwa-shell button { font: inherit; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; margin: 0; box-shadow: none; text-transform: none; letter-spacing: normal; }
.wppwa-shell a { text-decoration: none !important; }

/* Top bar */
.wppwa-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 99990;
  height: calc(var(--wppwa-top-h) + var(--wppwa-safe-top));
  padding: var(--wppwa-safe-top) 6px 0;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  background: var(--wppwa-top-bg, #6c63ff); color: var(--wppwa-top-fg, #fff);
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.wppwa-shell.is-blur .wppwa-topbar { background: color-mix(in srgb, var(--wppwa-top-bg) 86%, transparent); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
.wppwa-top-title { text-align: center; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.wppwa-shell .wppwa-top-btn { width: 44px; height: 44px; display: inline-flex !important; align-items: center; justify-content: center; border-radius: 12px; }
.wppwa-top-btn:active { background: rgba(255,255,255,.18); }
.wppwa-back.is-hidden { visibility: hidden; }

/* Bottom tab bar */
.wppwa-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 99990;
  height: calc(var(--wppwa-tab-h) + var(--wppwa-safe-bottom));
  padding: 4px 4px var(--wppwa-safe-bottom);
  display: grid; grid-template-columns: repeat(var(--wppwa-tabs, 4), 1fr);
  background: var(--wppwa-bar-bg, #fff); color: var(--wppwa-bar-fg, #6b7280);
  border-top: 1px solid rgba(0,0,0,.08);
}
.wppwa-shell.is-blur .wppwa-tabbar { background: color-mix(in srgb, var(--wppwa-bar-bg) 85%, transparent); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
.wppwa-shell .wppwa-tab-item {
  display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: inherit !important; font-size: 10.5px; font-weight: 500; line-height: 1.1; border-radius: 12px;
  transition: color .15s, transform .12s;
}
.wppwa-shell .wppwa-tab-item:active { transform: scale(.92); }
.wppwa-shell .wppwa-tab-item.is-active { color: var(--wppwa-bar-active, #6c63ff) !important; }
.wppwa-shell .wppwa-tab-item.is-active svg { stroke-width: 2.3; }
.wppwa-shell.no-labels .wppwa-tab-item span { display: none; }
.wppwa-shell.no-labels .wppwa-tab-item svg { width: 26px; height: 26px; }

/* Drawer */
.wppwa-drawer-scrim { position: fixed; inset: 0; z-index: 99991; background: rgba(0,0,0,.38); opacity: 0; pointer-events: none; transition: opacity .25s; }
.wppwa-shell.has-overlay .wppwa-drawer-scrim { opacity: 1; pointer-events: auto; }
.wppwa-drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 99992; width: min(84vw, 340px);
  background: var(--wppwa-bar-bg, #fff); color: #1a1a2e;
  transform: translateX(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  padding: calc(var(--wppwa-safe-top) + 12px) 0 calc(var(--wppwa-safe-bottom) + 12px);
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(0,0,0,.18);
}
.wppwa-drawer.open { transform: none; }
.wppwa-drawer-head { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px 18px; border-bottom: 1px solid rgba(0,0,0,.07); }
.wppwa-drawer-head img { border-radius: 11px; flex-shrink: 0; }
.wppwa-drawer-head div { flex: 1; min-width: 0; }
.wppwa-drawer-head strong { display: block; font-size: 16px; }
.wppwa-drawer-head span { display: block; font-size: 12px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wppwa-drawer-head .wppwa-top-btn:active { background: rgba(0,0,0,.06); }
.wppwa-drawer-list { overflow-y: auto; padding: 8px 0; }
.wppwa-shell .wppwa-drawer-item { display: flex !important; width: 100%; align-items: center; gap: 14px; padding: 13px 20px; color: #1a1a2e !important; font-size: 15px; text-align: left; }
.wppwa-shell .wppwa-drawer-item svg { color: var(--wppwa-bar-active, #6c63ff); flex-shrink: 0; }
.wppwa-shell .wppwa-drawer-item:active, .wppwa-shell .wppwa-drawer-item.is-active { background: color-mix(in srgb, var(--wppwa-bar-active) 10%, transparent); }

/* Search sheet */
.wppwa-search { position: fixed; top: 0; left: 0; right: 0; z-index: 99993; padding: calc(var(--wppwa-safe-top) + 10px) 12px 12px; background: var(--wppwa-bar-bg, #fff); transform: translateY(-110%); transition: transform .25s ease; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.wppwa-search.open { transform: none; }
.wppwa-search form { display: flex; align-items: center; gap: 10px; background: rgba(120,120,128,.12); border-radius: 12px; padding: 0 0 0 12px; color: #6b7280; margin: 0; }
.wppwa-search input[type=search] { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; height: 42px; font-size: 16px; color: #1a1a2e; outline: none; padding: 0 !important; margin: 0 !important; min-width: 0; }
.wppwa-search form button { color: var(--wppwa-bar-active, #6c63ff) !important; font-weight: 600; padding: 0 12px !important; height: 42px; }

/* Pull to refresh */
.wppwa-ptr { position: fixed; top: calc(var(--wppwa-top-h) + var(--wppwa-safe-top) + 8px); left: 50%; z-index: 99989; width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--wppwa-bar-active, #6c63ff); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(0,0,0,.18); opacity: 0; transform: translate(-50%, -40px); pointer-events: none; }
.wppwa-ptr.spin svg { animation: wppwa-ptr-spin .6s linear infinite; }
@keyframes wppwa-ptr-spin { to { transform: rotate(360deg); } }

/* Toast */
.wppwa-shell-toast { position: fixed; left: 50%; bottom: calc(var(--wppwa-tab-h) + var(--wppwa-safe-bottom) + 16px); transform: translate(-50%, 20px); z-index: 99994; background: rgba(26,26,46,.92); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap; }
.wppwa-shell-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Page transitions */
html.wppwa-app body { transition: opacity .18s ease; }
html.wppwa-app.wppwa-leaving body { opacity: .35; }

/* Larger screens: iPad / desktop keep the bar centred and roomier */
@media (min-width: 740px) {
  html.wppwa-app { --wppwa-tab-h: 64px; }
  .wppwa-tabbar { padding-left: max(4px, calc((100vw - 720px) / 2)); padding-right: max(4px, calc((100vw - 720px) / 2)); }
  .wppwa-shell .wppwa-tab-item { flex-direction: row; gap: 8px; font-size: 13px; }
}

@media (prefers-color-scheme: dark) {
  html.wppwa-native .wppwa-search input[type=search] { color: #f1f5f9; }
}
@media (prefers-reduced-motion: reduce) {
  .wppwa-drawer, .wppwa-search, html.wppwa-app body { transition: none; }
}
