/* ============================================================
   BricoDiscount PWA Styles
   - Top navigation progress bar
   - Install banner (Android)
   - iOS install tip
   - Update banner
   - Mobile UX polish
   ============================================================ */

/* ── Top page-load progress bar ─────────────────────────────── */
#bd-page-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: #c0392b;
  z-index: 99999;
  transition: width .1s ease, opacity .4s ease;
  pointer-events: none;
  opacity: 0;
}

#bd-page-bar.bd-page-bar--loading {
  animation: bdBarProgress 2.5s cubic-bezier(.25,.1,.25,1) forwards;
  opacity: 1;
}

@keyframes bdBarProgress {
  0%   { width: 0; }
  30%  { width: 50%; }
  70%  { width: 75%; }
  90%  { width: 90%; }
  100% { width: 95%; }
}

/* ── Update available banner ─────────────────────────────────── */
#bd-update-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #1a1a2e;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  z-index: 99998;
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  animation: bdSlideUp .35s cubic-bezier(.34,1.56,.64,1) forwards;
  max-width: calc(100vw - 2rem);
}

#bd-update-banner span {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
}

#bd-update-btn {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .4rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .2s;
}
#bd-update-btn:hover { opacity: .85; }

#bd-update-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  font-size: 1rem;
  padding: .2rem;
  line-height: 1;
  transition: color .2s;
}
#bd-update-dismiss:hover { color: #fff; }

/* ── Android install banner ──────────────────────────────────── */
#bd-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -8px 32px rgba(0,0,0,.1);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  z-index: 99997;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.34,1.2,.64,1);
}

[data-theme="dark"] #bd-install-banner {
  background: #1f2937;
  border-top-color: #374151;
}

#bd-install-banner.bd-install-banner--visible {
  transform: translateY(0);
}

.bd-install-banner__icon img {
  border-radius: 10px;
  display: block;
}

.bd-install-banner__text {
  flex: 1;
  min-width: 0;
}

.bd-install-banner__text strong {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  color: #111827;
}

[data-theme="dark"] .bd-install-banner__text strong { color: #f9fafb; }

.bd-install-banner__text span {
  display: block;
  font-size: .78rem;
  color: #6b7280;
  margin-top: .1rem;
}

.bd-install-banner__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

#bd-install-btn {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}
#bd-install-btn:hover { opacity: .85; }

#bd-install-dismiss {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 1.1rem;
  padding: .2rem;
  line-height: 1;
  transition: color .2s;
}
#bd-install-dismiss:hover { color: #374151; }

/* ── iOS install tip ─────────────────────────────────────────── */
#bd-ios-tip {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  background: #1a1a2e;
  color: #fff;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
  z-index: 99997;
  transform: translateY(120%);
  transition: transform .4s cubic-bezier(.34,1.2,.64,1);
}

#bd-ios-tip.bd-ios-tip--visible {
  transform: translateY(0);
}

.bd-ios-tip__content {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-top: .5rem;
}

.bd-ios-tip__content img { border-radius: 10px; flex-shrink: 0; }

.bd-ios-tip__content strong {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.bd-ios-tip__content p {
  font-size: .8rem;
  color: rgba(255,255,255,.75);
  line-height: 1.5;
  margin: 0;
}

.bd-ios-tip__content p svg {
  display: inline;
  vertical-align: middle;
}

.bd-ios-tip__arrow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 8px;
  background: #1a1a2e;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

#bd-ios-tip-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: none;
  border: none;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  font-size: 1rem;
  padding: .2rem;
  line-height: 1;
}

/* ── Shared animation ────────────────────────────────────────── */
@keyframes bdSlideUp {
  from { transform: translateX(-50%) translateY(120%); }
  to   { transform: translateX(-50%) translateY(0); }
}

/* ── PWA standalone mode adjustments ────────────────────────── */
@media (display-mode: standalone) {
  /* Safe area for notch / home indicator */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Remove top bar when in app mode — more screen space */
  .top-bar {
    display: none;
  }

  /* Adjust header top in standalone */
  .header {
    padding-top: env(safe-area-inset-top);
  }
}

/* ── Mobile UX polish ────────────────────────────────────────── */

/* Prevent 300ms tap delay everywhere */
* { touch-action: manipulation; }

/* Smooth scroll globally */
html { scroll-behavior: smooth; }

/* Remove tap highlight on iOS */
a, button { -webkit-tap-highlight-color: transparent; }

/* Better button press states on mobile */
.btn:active,
button:active,
.header__action-btn:active,
.mobile-menu__link:active {
  transform: scale(.97);
  opacity: .85;
  transition: transform .08s, opacity .08s;
}

/* Skeleton loader for cards during loading state */
.bd-skeleton {
  position: relative;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 8px;
  color: transparent !important;
  pointer-events: none;
}

[data-theme="dark"] .bd-skeleton {
  background: #374151;
}

.bd-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,.4) 50%,
    transparent 100%
  );
  animation: bdShimmer 1.4s infinite;
}

[data-theme="dark"] .bd-skeleton::after {
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,.08) 50%,
    transparent 100%
  );
}

@keyframes bdShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Page navigation fade — subtle, not jarring */
body.bd-navigating .main-content {
  opacity: .6;
  transition: opacity .15s ease;
}

/* Improve mobile tap target sizes */
@media (max-width: 768px) {
  .nav-list__link,
  .mobile-menu__link,
  .footer__links a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .header__action-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Better product card on mobile */
  .product-card {
    border-radius: 12px;
  }
}

/* Offline indicator pill — shown when navigator.onLine = false */
#bd-offline-pill {
  position: fixed;
  top: .75rem;
  left: 50%;
  transform: translateX(-50%) translateY(-200%);
  background: #1f2937;
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  padding: .4rem 1rem;
  border-radius: 100px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: transform .3s cubic-bezier(.34,1.2,.64,1);
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

#bd-offline-pill.bd-offline-pill--visible {
  transform: translateX(-50%) translateY(0);
}
