/* Shared skeleton shimmer (YouTube-like) for all pages */

:root {
  --skel-base: rgba(255, 255, 255, 0.06);
  --skel-border: rgba(185, 202, 203, 0.12);
  --skel-hi: rgba(0, 219, 233, 0.08);

  /* Scrollbar (match wallet page look) */
  --scroll-track: #0a0a0a;
  --scroll-thumb: #222222;
}

/* Hard stop for any accidental horizontal overflow on mobile (common with blurred/absolute elements). */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

.skel {
  position: relative;
  overflow: hidden;
  background: var(--skel-base);
  border: 1px solid var(--skel-border);
  transform: translateZ(0);
}

.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(90deg, transparent, var(--skel-hi), transparent);
  animation: skel-shimmer 1.15s ease-in-out infinite;
}

@keyframes skel-shimmer {
  100% {
    transform: translateX(120%);
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .skel::after {
    animation: none;
  }
}

/* Soft content reveal to avoid "popping" */
.soft-reveal {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.soft-reveal.show {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .soft-reveal {
    transition: none;
    transform: none;
    opacity: 1;
  }
}

/* Scrollbar styling (WebKit) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scroll-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 10px;
}

/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* Hide scrollbars on specific horizontal scrollers (keep scroll working). */
.no-scrollbar {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* old Edge */
}
.no-scrollbar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Sidebar-only navigation indicator (2.5s) */
.sb-nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.sb-nav-bar.show {
  opacity: 1;
}

.sb-nav-bar::before {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(0, 219, 233, 0) 0%,
    rgba(0, 219, 233, 0.95) 20%,
    rgba(78, 222, 163, 0.85) 50%,
    rgba(0, 219, 233, 0.95) 80%,
    rgba(0, 219, 233, 0) 100%
  );
  box-shadow: 0 10px 30px rgba(0, 219, 233, 0.16);
}

.sb-nav-bar.run::before {
  animation: sb-bar-run 0ms ease-in-out forwards;
}

@keyframes sb-bar-run {
  0% {
    transform: scaleX(0);
  }
  70% {
    transform: scaleX(0.92);
  }
  100% {
    transform: scaleX(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-nav-bar.run::before {
    animation: none;
    transform: scaleX(1);
  }
}

/* Mobile app shell (sidebar drawer + compact topbar/content) */
/* For pages that have the internal sidebar layout. */
.app-shell {
  overflow-x: hidden;
}

/* Admin pages stay blank until Firebase confirms the admin account. */
body.admin-auth-gate:not(.admin-auth-ready) {
  background: #131313 !important;
  overflow: hidden !important;
}

body.admin-auth-gate:not(.admin-auth-ready) > * {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Sidebar gating (main app): show NO links until async nav config loads.
   This prevents hidden links from flashing briefly on first paint. */
html.sb-nav-gate:not(.sb-nav-ready) aside nav {
  display: none !important;
}

html.sb-nav-gate.sb-nav-ready aside nav {
  display: block;
}

/* Hide the whole sidebar content until ready (prevents logo/user box/hidden items flash). */
html.sb-nav-gate:not(.sb-nav-ready) aside {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html.sb-nav-gate.sb-nav-ready aside {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 140ms ease;
}

/* Prevent the fixed desktop sidebar from flashing on mobile before JS enhances it into a drawer. */
@media (max-width: 767px) {
  html.sb-nav-gate:not(.sb-nav-ready) aside {
    width: min(82vw, 320px) !important;
    z-index: 5200 !important;
    transform: translateX(110%);
    transition: none !important;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    height: 100vh;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  }
  @supports (height: 100svh) {
    html.sb-nav-gate:not(.sb-nav-ready) aside {
      height: 100svh;
    }
  }
}

#sbBackdrop {
  position: fixed;
  inset: 0;
  z-index: 5100;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(4px);
}

/* Tablet support (iPad): use the same drawer shell as mobile, without changing phone styling. */
.sb-menu-btn {
  display: none !important;
}

@media (max-width: 1023px) {
  .sb-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .app-shell main.mr-64 {
    margin-right: 0 !important;
  }

  .app-shell aside.app-sidebar {
    width: min(82vw, 360px) !important;
    z-index: 5200 !important;
    transform: translateX(110%);
    transition: transform 260ms ease;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    height: 100vh;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  }
  @supports (height: 100svh) {
    .app-shell aside.app-sidebar {
      height: 100svh;
    }
  }

  .app-shell.sb-open aside.app-sidebar {
    transform: translateX(0);
  }

  .app-shell.sb-open {
    overflow: hidden;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .app-shell header.px-8 {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }
  .app-shell section.p-8 {
    padding: 1.25rem !important;
  }
  .app-shell footer.p-8 {
    padding: 1.25rem !important;
  }

  .app-shell #productGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }
}

@media (max-width: 767px) {
  /* Remove the desktop right gutter on mobile */
  .app-shell main.mr-64 {
    margin-right: 0 !important;
  }

  /* Sidebar becomes an off-canvas drawer on mobile */
  .app-shell aside.app-sidebar {
    width: min(82vw, 320px) !important;
    z-index: 5200 !important;
    transform: translateX(110%);
    transition: transform 260ms ease;
    /* Make the drawer scrollable so last items (Lessons/Logout) are reachable */
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    height: 100vh; /* fallback */
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  }
  @supports (height: 100svh) {
    .app-shell aside.app-sidebar {
      height: 100svh;
    }
  }

  .app-shell.sb-open aside.app-sidebar {
    transform: translateX(0);
  }

  /* Backdrop visibility is controlled by JS via `hidden` class */
  .app-shell.sb-open {
    overflow: hidden;
  }

  /* Compact paddings for the standard layout (most pages use px-8/p-8) */
  .app-shell header.px-8 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .app-shell section.p-8 {
    padding: 1rem !important;
  }
  .app-shell footer.p-8 {
    padding: 1rem !important;
  }

  /* Hide the user box in topbar on mobile (name + avatar) */
  .app-shell .app-userbox {
    display: none !important;
  }
  .app-shell header .w-px {
    display: none !important;
  }

  /* Inventory grid: force 2 columns on mobile */
  .app-shell #productGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
}

/* Hex country flags (used in inventory + wholesale country pickers) */
.hex-flag {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 12px; /* fallback if clip-path unsupported */
  overflow: hidden;
  border: 1px solid rgba(185, 202, 203, 0.16);
  background: rgba(53, 53, 52, 0.35);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

@media (min-width: 1024px) {
  .hex-flag {
    width: 62px;
    height: 62px;
  }
}

/* Banner slider */
.banner-slider {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(185, 202, 203, 0.12);
  background: rgba(32, 31, 31, 0.4);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
}

.banner-slider::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(1200px 260px at 50% 0%, rgba(0, 219, 233, 0.12), transparent 60%);
}

.banner-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 420ms ease, transform 620ms ease;
}

.banner-slide.active {
  opacity: 1;
  transform: scale(1);
}

.banner-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.banner-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(185, 202, 203, 0.18);
  background: rgba(19, 19, 19, 0.55);
  backdrop-filter: blur(10px);
  color: rgba(229, 226, 225, 0.92);
}

.banner-nav-btn:hover {
  border-color: rgba(0, 219, 233, 0.32);
}

.banner-nav-btn:active {
  transform: translateY(-50%) scale(0.96);
}

.banner-dots {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  z-index: 6;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(185, 202, 203, 0.22);
  background: rgba(229, 226, 225, 0.14);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.banner-dot.active {
  background: rgba(0, 219, 233, 0.7);
  border-color: rgba(0, 219, 233, 0.9);
  transform: scale(1.25);
}

@supports (clip-path: polygon(0 0)) {
  .hex-flag {
    border-radius: 0;
    clip-path: polygon(25% 6%, 75% 6%, 98% 50%, 75% 94%, 25% 94%, 2% 50%);
  }
}

.hex-flag img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hex-flag-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transform: translateZ(0);
}

.hex-flag-btn:focus-visible {
  outline: 2px solid rgba(0, 219, 233, 0.55);
  outline-offset: 4px;
  border-radius: 14px;
}

.hex-flag-ring {
  display: none; /* user requested: no selection highlight + prevents overflow scrollbars */
}

/* Subtle hover without "active" highlight */
.hex-flag-btn:hover .hex-flag {
  transform: translateY(-1px);
  border-color: rgba(0, 219, 233, 0.22);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}
.hex-flag-btn:active .hex-flag {
  transform: translateY(0) scale(0.98);
}

/* Small country badge for product cards (warehouse/wholesale) */
.country-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(185, 202, 203, 0.12);
  background: rgba(19, 19, 19, 0.55);
  backdrop-filter: blur(10px);
  font-weight: 800;
  font-size: 11px;
  color: rgba(229, 226, 225, 0.9);
}

.country-badge img {
  width: 18px;
  height: 12px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(185, 202, 203, 0.16);
}
