/* ========================================
   ADECOAL WEAR - TOUCH & PERFORMANCE
   Otimizações para Mobile e Performance
======================================== */

/* ========================================
   TOUCH INTERACTIONS
======================================== */

/* Melhorar área de toque */
.btn,
.categoria-tile,
.whatsapp-float,
.menu-toggle,
.swiper-button-next,
.swiper-button-prev {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Estados de toque responsivos */
.touch .btn:active,
.touch .categoria-tile:active,
.touch .whatsapp-float:active {
  transform: scale(0.98);
  transition: transform 0.1s ease;
}

/* Hover states para dispositivos não-touch */
.no-touch .btn:hover,
.no-touch .categoria-tile:hover,
.no-touch .whatsapp-float:hover {
  transform: translateY(-2px);
  transition: transform var(--transition-normal);
}

/* ========================================
   SCROLL PERFORMANCE
======================================== */

/* Otimizar scroll suave */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Melhorar performance de scroll */
.hero-swiper,
.categorias-section,
footer {
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* ========================================
   ANIMATION PERFORMANCE
======================================== */

/* Usar transform e opacity para animações */
.btn,
.categoria-tile,
.whatsapp-float {
  will-change: transform, opacity;
}

/* Reduzir animações em dispositivos móveis */
@media (max-width: 768px) {
  .hero-swiper .swiper-slide img {
    transition: transform 3s ease-in-out;
  }
  
  .categoria-tile:hover img {
    transform: scale(1.02);
  }
  
  .btn:hover {
    transform: translateY(-1px);
  }
}

/* ========================================
   MEMORY OPTIMIZATION
======================================== */

/* Limpar will-change após animação */
.animation-complete {
  will-change: auto;
}

/* ========================================
   TOUCH GESTURES
======================================== */

/* Melhorar gestos de swipe */
.swiper-container {
  touch-action: pan-y;
}

/* Prevenir zoom duplo toque */
* {
  touch-action: manipulation;
}

/* ========================================
   FOCUS STATES
======================================== */

/* Estados de foco melhorados para teclado */
.keyboard-navigation .btn:focus,
.keyboard-navigation .categoria-tile:focus,
.keyboard-navigation .whatsapp-float:focus {
  outline: 3px solid var(--dourado);
  outline-offset: 2px;
}

/* Remover outline padrão e adicionar customizado */
.btn:focus,
.categoria-tile:focus,
.whatsapp-float:focus,
.menu-toggle:focus {
  outline: none;
}

.btn:focus-visible,
.categoria-tile:focus-visible,
.whatsapp-float:focus-visible,
.menu-toggle:focus-visible {
  outline: 3px solid var(--dourado);
  outline-offset: 2px;
}

/* ========================================
   LOADING STATES
======================================== */

/* Skeleton loading para conteúdo */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================
   REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .hero-swiper .swiper-slide img {
    transform: none !important;
    transition: none !important;
  }
  
  .whatsapp-float {
    animation: none !important;
  }
}

/* ========================================
   HIGH CONTRAST MODE
======================================== */

@media (prefers-contrast: high) {
  .btn,
  .categoria-tile,
  .whatsapp-float {
    border: 2px solid currentColor;
  }
  
  .btn:focus,
  .categoria-tile:focus,
  .whatsapp-float:focus {
    outline: 4px solid currentColor;
    outline-offset: 2px;
  }
}

/* ========================================
   PRINT OPTIMIZATIONS
======================================== */

@media print {
  .hero-swiper,
  .whatsapp-float,
  .menu-toggle {
    display: none !important;
  }
  
  .categoria-tile {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  * {
    will-change: auto !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ========================================
   PWA SPECIFIC
======================================== */

.pwa-mode .whatsapp-float {
  bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
}

.pwa-mode header {
  padding-top: calc(var(--space-sm) + env(safe-area-inset-top));
}

/* ========================================
   DEVICE SPECIFIC OPTIMIZATIONS
======================================== */

/* iOS Safari */
@supports (-webkit-touch-callout: none) {
  .hero-swiper {
    height: 100vh;
    height: -webkit-fill-available;
  }
  
  .btn,
  .categoria-tile {
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Android Chrome */
@media screen and (max-width: 768px) {
  .hero-swiper,
  .categorias-section {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
}

/* ========================================
   PERFORMANCE MONITORING
======================================== */

/* Classes para monitoramento de performance */
.perf-slow {
  border: 2px solid red;
}

.perf-medium {
  border: 2px solid orange;
}

.perf-fast {
  border: 2px solid green;
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
======================================== */

/* Melhorar contraste para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--dourado);
  color: var(--primary-white);
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* ========================================
   ERROR STATES
======================================== */

/* Estados de erro para imagens */
img[src=""],
img:not([src]) {
  background: var(--primary-beige);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  min-height: 100px;
}

img[src=""]::before,
img:not([src])::before {
  content: "Imagem não encontrada";
}

/* ========================================
   NETWORK AWARENESS
======================================== */

/* Estilos para conexões lentas */
@media (prefers-reduced-data: reduce) {
  .hero-swiper .swiper-slide img {
    filter: blur(0);
  }
  
  .categoria-tile img {
    filter: blur(0);
  }
}

/* ========================================
   BATTERY AWARENESS
======================================== */

/* Reduzir animações quando bateria está baixa */
@media (prefers-reduced-motion: reduce) and (prefers-reduced-data: reduce) {
  .hero-swiper {
    animation: none;
  }
  
  .whatsapp-float {
    animation: none;
  }
}
