/* ============================================================
   Overlay shared shell
   Applies a single coherent modal language across cart, checkout,
   profile, orders, and admin overlays. Loaded AFTER each
   *-overlay.css so source-order wins resolve in this file's
   favor — no per-overlay edits required.

   Design direction (sets these overlays apart from the page):
   - Atmospheric scrim: deep navy vignette with heavy backdrop blur
     + saturate, so the page behind feels behind frosted glass.
   - Lifted modal: three-layer shadow (outer halo + closer cast +
     1px outline ring) plus an inner top highlight to simulate
     light catching a real surface edge.
   - Quiet white header: drops the old navy gradient bands. Replaces
     with eyebrow-style hairline divider so each overlay feels like
     an extension of the marketing surfaces, not a different app.
   - Cinematic entry: 480ms ease-out scale + translate. Slow enough
     to feel intentional, fast enough not to drag.
   ============================================================ */

/* ----------------------------------------------------------
   Scrim / wrapper
   ---------------------------------------------------------- */

.cart-wrapper,
.checkout-wrapper,
.profile-wrapper,
.orders-wrapper,
.admin-wrapper,
.product-details-backdrop,
.product-details-wrapper,
.order-details-wrapper {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center,
      rgba(11, 19, 64, 0.48) 0%,
      rgba(5, 8, 24, 0.78) 100%);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
  z-index: 10000;
  opacity: 0;
  transition: opacity 380ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 24px;
}

/* Sub-modal stacking. Order detail view opens on top of the orders list,
   and product details opens on top of either the cart or the order detail. */
.order-details-wrapper {
  z-index: 10010;
}

.product-details-backdrop,
.product-details-wrapper {
  z-index: 10020;
}

.cart-wrapper.active,
.checkout-wrapper.active,
.profile-wrapper.active,
.orders-wrapper.active,
.admin-wrapper.active,
.product-details-backdrop.active,
.product-details-wrapper.active,
.order-details-wrapper.active {
  display: flex;
  opacity: 1;
}

/* ----------------------------------------------------------
   Modal shell
   ---------------------------------------------------------- */

.cart-overlay,
.checkout-overlay,
.profile-overlay,
.orders-overlay,
.admin-overlay,
.product-details-modal,
.product-details-overlay,
.order-details-overlay {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFCFE 100%);
  border-radius: 24px;
  box-shadow:
    0 60px 120px -20px rgba(11, 19, 64, 0.32),
    0 28px 56px -12px rgba(11, 19, 64, 0.20),
    0 0 0 1px rgba(11, 19, 64, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transform: scale(0.94) translateY(24px);
  transition: transform 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Per-overlay max widths — set here so source order beats per-overlay files */
.cart-overlay            { max-width: 760px; }
.checkout-overlay        { max-width: 880px; }
.profile-overlay         { max-width: 920px; }
.orders-overlay          { max-width: 1000px; }
.admin-overlay           { max-width: 800px; }
.product-details-modal   { max-width: 600px; }   /* cart sub-modal */
.product-details-overlay { max-width: 700px; }   /* orders sub-modal */
.order-details-overlay   { max-width: 940px; }   /* order detail view */

.cart-wrapper.active     .cart-overlay,
.checkout-wrapper.active .checkout-overlay,
.profile-wrapper.active  .profile-overlay,
.orders-wrapper.active   .orders-overlay,
.admin-wrapper.active    .admin-overlay,
.product-details-backdrop.active .product-details-modal,
.product-details-wrapper.active  .product-details-overlay,
.order-details-wrapper.active    .order-details-overlay {
  transform: scale(1) translateY(0);
}

/* ----------------------------------------------------------
   Close button
   Sits over the white header now (no longer over a navy band).
   Default: hairline-bordered neutral pill. Hover: red destructive.
   ---------------------------------------------------------- */

/* Visual styling — applies to every overlay close button across main
   overlays and sub-modals. */
.cart-close-btn,
.checkout-close-btn,
.profile-close-btn,
.orders-close-btn,
.admin-close-btn,
.product-details-close-btn,
.order-details-close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--pb-muted, #5B6478);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--pb-hairline, #E5E7EB);
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cart-close-btn:hover,
.checkout-close-btn:hover,
.profile-close-btn:hover,
.orders-close-btn:hover,
.admin-close-btn:hover,
.product-details-close-btn:hover,
.order-details-close-btn:hover {
  color: #B91C1C;
  background: rgba(185, 28, 28, 0.06);
  border-color: rgba(185, 28, 28, 0.32);
  transform: scale(1.04);
}

/* Positioning — every absolutely-positioned close button (main overlays,
   order detail sub-modal, and orders' product-details sub-modal whose
   markup keeps the close button as a sibling of the header rather than
   inside it). */
.cart-close-btn,
.checkout-close-btn,
.profile-close-btn,
.orders-close-btn,
.admin-close-btn,
.product-details-close-btn,
.order-details-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 10;
}

/* ----------------------------------------------------------
   Header band
   Replaces navy gradient with clean white + hairline divider.
   Mirrors the marketing-site section-header pattern.
   ---------------------------------------------------------- */

.cart-header,
.checkout-header,
.profile-header,
.orders-header,
.admin-header,
.product-details-header,
.order-details-header {
  /* !important on background overrides the legacy navy gradient that
     orders-overlay.css sets on .product-details-header. */
  background: transparent !important;
  color: var(--pb-ink, #0A0F1F);
  padding: 28px 80px 22px 32px;
  border-bottom: 1px solid var(--pb-hairline, #E5E7EB);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-shrink: 0;
}

.cart-header h2,
.checkout-header h2,
.profile-header h2,
.orders-header h2,
.admin-header h2,
.product-details-header h2,
.product-details-header h3,
.order-details-header h2 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  /* !important needed because profile/orders had `color: white !important`
     baked in for the old navy header background. */
  color: var(--pb-ink, #0A0F1F) !important;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.2;
}

.cart-header h2 span,
.checkout-header h2 span,
.profile-header h2 span,
.orders-header h2 span,
.admin-header h2 span,
.product-details-header h2 span,
.product-details-header h3 span,
.order-details-header h2 span {
  color: var(--pb-ink, #0A0F1F) !important;
}

/* Header icon: small accent-colored mark next to the title */
.cart-header h2 i,
.checkout-header h2 i,
.profile-header h2 i,
.orders-header h2 i,
.admin-header h2 i,
.product-details-header h2 i,
.product-details-header h3 i,
.order-details-header h2 i {
  color: var(--pb-accent, #1D4ED8);
  font-size: 0.85em;
  opacity: 0.9;
}

/* Subtitle inside admin header (admin is the only one using <p>) */
.admin-header p {
  margin: 6px 0 0;
  font-size: 0.875rem;
  color: var(--pb-muted, #5B6478);
  line-height: 1.5;
}

/* ----------------------------------------------------------
   Header refresh button (currently used by cart only) — restyle
   so it works on the new white header instead of the old navy one.
   ---------------------------------------------------------- */

.cart-refresh-btn {
  background: var(--pb-tint, #F4F7FB);
  border: 1px solid var(--pb-hairline, #E5E7EB);
  color: var(--pb-ink-2, #1F2937);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.cart-refresh-btn:hover {
  background: #FFFFFF;
  border-color: var(--pb-muted-2, #8A93A6);
  color: var(--pb-ink, #0A0F1F);
  transform: translateY(-1px);
}

.cart-refresh-btn i {
  color: var(--pb-accent, #1D4ED8);
}

/* ----------------------------------------------------------
   Mobile shell
   ---------------------------------------------------------- */

@media (max-width: 768px) {
  .cart-wrapper,
  .checkout-wrapper,
  .profile-wrapper,
  .orders-wrapper,
  .admin-wrapper,
  .product-details-backdrop,
  .product-details-wrapper,
  .order-details-wrapper {
    padding: 12px;
  }

  .cart-overlay,
  .checkout-overlay,
  .profile-overlay,
  .orders-overlay,
  .admin-overlay,
  .product-details-modal,
  .product-details-overlay,
  .order-details-overlay {
    border-radius: 20px;
    max-height: 96vh;
  }

  .cart-close-btn,
  .checkout-close-btn,
  .profile-close-btn,
  .orders-close-btn,
  .admin-close-btn,
  .product-details-close-btn,
  .order-details-close-btn {
    top: 14px;
    right: 14px;
  }

  .cart-header,
  .checkout-header,
  .profile-header,
  .orders-header,
  .admin-header,
  .product-details-header,
  .order-details-header {
    padding: 20px 64px 16px 22px;
  }

  .cart-header h2,
  .checkout-header h2,
  .profile-header h2,
  .orders-header h2,
  .admin-header h2,
  .product-details-header h2,
  .product-details-header h3,
  .order-details-header h2 {
    font-size: 1.1875rem;
  }
}

/* ----------------------------------------------------------
   Reduced motion
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .cart-wrapper,
  .checkout-wrapper,
  .profile-wrapper,
  .orders-wrapper,
  .admin-wrapper,
  .product-details-backdrop,
  .product-details-wrapper,
  .order-details-wrapper,
  .cart-overlay,
  .checkout-overlay,
  .profile-overlay,
  .orders-overlay,
  .admin-overlay,
  .product-details-modal,
  .product-details-overlay,
  .order-details-overlay,
  .cart-close-btn,
  .checkout-close-btn,
  .profile-close-btn,
  .orders-close-btn,
  .admin-close-btn,
  .product-details-close-btn,
  .order-details-close-btn,
  .cart-refresh-btn {
    transition-duration: 0ms !important;
  }
}
