/**
 * AtFactoryPrice PWA Styles
 * Phase 4: Progressive Web App Enhancement
 */

/* ===== PWA INSTALL BANNER ===== */
#pwa-install-banner {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  border-radius: 16px;
  padding: 16px;
  z-index: 9999;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  transform: translateY(150%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#pwa-install-banner.show {
  transform: translateY(0);
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-banner-icon {
  width: 48px;
  height: 48px;
  background: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.pwa-banner-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pwa-banner-text {
  flex: 1;
  color: #fff;
}

.pwa-banner-text strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.pwa-banner-text span {
  font-size: 0.8rem;
  opacity: 0.8;
}

.pwa-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-install-btn {
  background: #fff;
  color: #0f172a;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pwa-install-btn:hover {
  background: #f1f5f9;
  transform: scale(1.02);
}

.pwa-dismiss-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  padding: 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.pwa-dismiss-btn:hover {
  color: #fff;
}

/* ===== OFFLINE BANNER ===== */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  padding: 12px 16px;
  z-index: 10000;
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#offline-banner.show {
  transform: translateY(0);
}

.offline-banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.9rem;
  font-weight: 500;
}

.offline-banner-content svg {
  flex-shrink: 0;
}

/* Offline disabled state for buttons */
.offline-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* ===== UPDATE BANNER ===== */
#pwa-update-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-150%);
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  z-index: 10000;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#pwa-update-banner.show {
  transform: translateX(-50%) translateY(0);
}

.pwa-update-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pwa-update-content button {
  background: #fff;
  color: #0f172a;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.pwa-update-content button:hover {
  background: #f1f5f9;
}

/* ===== MOBILE BOTTOM NAVIGATION ===== */
#mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 9998;
  border-top: 1px solid #e2e8f0;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: #64748b;
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
}

.mobile-nav-item.active {
  color: #0f172a;
}

.mobile-nav-item.active svg {
  stroke-width: 2.5;
}

.mobile-nav-item.whatsapp {
  color: #16a34a;
}

.mobile-nav-item.whatsapp svg {
  width: 26px;
  height: 26px;
}

.mobile-cart-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  background: #dc2626;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ===== PAGE TRANSITIONS ===== */
.page-transition-enter {
  opacity: 0;
  transform: translateY(20px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ===== PULL TO REFRESH INDICATOR ===== */
.pull-to-refresh {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 9999;
  transition: top 0.3s ease;
}

.pull-to-refresh.visible {
  top: 20px;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (min-width: 769px) {
  #mobile-bottom-nav {
    display: none;
  }
  
  #pwa-install-banner {
    left: auto;
    right: 24px;
    bottom: 24px;
    max-width: 400px;
  }
}

@media (max-width: 480px) {
  .pwa-banner-content {
    flex-wrap: wrap;
  }
  
  .pwa-banner-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 8px;
  }
  
  .pwa-banner-text {
    flex: 1;
    min-width: calc(100% - 60px);
  }
}

/* ===== SMOOTH SCROLLING ===== */
html {
  scroll-behavior: smooth;
}

/* ===== SMOOTH HEADER HIDE/SHOW ON SCROLL ===== */
.navbar {
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              background-color 0.3s ease,
              backdrop-filter 0.3s ease,
              -webkit-backdrop-filter 0.3s ease,
              box-shadow 0.3s ease;
  will-change: transform, opacity, background-color;
}

/* Initial state - fully visible */
.navbar.header-visible {
  transform: translateY(0);
  opacity: 1;
  background-color: rgba(255, 255, 255, 1);
}

/* Scrolled state - add subtle glass effect */
.navbar.header-scrolled {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
}

/* Fading state - becoming transparent */
.navbar.header-fading {
  opacity: 0.6;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Hidden state - fully invisible with elegant slide up */
.navbar.header-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

/* Premium entrance animation */
.navbar.header-entering {
  animation: headerSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes headerSlideIn {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  50% {
    opacity: 0.7;
    background-color: rgba(255, 255, 255, 0.85);
  }
  100% {
    transform: translateY(0);
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.95);
  }
}

/* ===== TOUCH FEEDBACK ===== */
.mobile-nav-item:active {
  transform: scale(0.95);
}

button:active,
a:active {
  transform: scale(0.98);
}

/* ===== SKELETON LOADING ANIMATION ===== */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ===== IMAGE LAZY LOADING ===== */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src=""]) {
  opacity: 1;
}

/* ===== SAFE AREA PADDING FOR NOTCHED DEVICES ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
