/**
 * VR Shopping - Sistema Responsivo Global
 * Suporte: 320px - 2560px+ (Mobile a TV/Ultra-Wide)
 * Versão: 2.0
 */

/* ============================================
   CSS CUSTOM PROPERTIES (VARIÁVEIS)
   ============================================ */
:root {
    /* Tipografia fluida */
    --font-size-xs: clamp(10px, 2vw, 12px);
    --font-size-sm: clamp(12px, 2.2vw, 14px);
    --font-size-base: clamp(14px, 2.5vw, 16px);
    --font-size-md: clamp(16px, 2.8vw, 18px);
    --font-size-lg: clamp(18px, 3vw, 22px);
    --font-size-xl: clamp(22px, 4vw, 28px);
    --font-size-2xl: clamp(28px, 5vw, 36px);
    --font-size-3xl: clamp(36px, 6vw, 48px);
    
    /* Espaçamento fluido */
    --space-xs: clamp(4px, 1vw, 8px);
    --space-sm: clamp(8px, 1.5vw, 12px);
    --space-md: clamp(12px, 2vw, 16px);
    --space-lg: clamp(16px, 3vw, 24px);
    --space-xl: clamp(24px, 4vw, 32px);
    --space-2xl: clamp(32px, 5vw, 48px);
    
    /* Safe Areas para dispositivos com notch */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    
    /* Container responsivo */
    --container-max: min(100% - 2rem, 1200px);
    --container-padding: clamp(12px, 4vw, 24px);
    
    /* Touch target mínimo (Apple HIG) */
    --touch-target-min: 44px;
    
    /* Border radius responsivo */
    --radius-sm: clamp(4px, 0.5vw, 6px);
    --radius-md: clamp(6px, 0.8vw, 10px);
    --radius-lg: clamp(10px, 1vw, 16px);
}

/* ============================================
   RESET E BASE RESPONSIVA
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Evita zoom automático no iOS */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   CONTAINER RESPONSIVO
   ============================================ */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* ============================================
   GRID SYSTEM RESPONSIVO
   ============================================ */
.grid {
    display: grid;
    gap: var(--space-md);
}

.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Auto-fit grid responsivo */
.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

/* ============================================
   ELEMENTOS TOUCH-FRIENDLY
   ============================================ */
button, 
[role="button"],
a.btn,
.btn,
input[type="submit"],
input[type="button"],
input[type="reset"],
select {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea,
select {
    font-size: 16px; /* Evita zoom no iOS */
    min-height: var(--touch-target-min);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    -webkit-appearance: none;
    appearance: none;
}

/* ============================================
   BREAKPOINTS - MOBILE FIRST
   ============================================ */

/* Mobile Small (320px - 479px) */
@media (max-width: 479px) {
    :root {
        --container-padding: 12px;
    }
    
    .hide-mobile-sm { display: none !important; }
    
    h1 { font-size: var(--font-size-xl); }
    h2 { font-size: var(--font-size-lg); }
    h3 { font-size: var(--font-size-md); }
}

/* Mobile (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    :root {
        --container-padding: 16px;
    }
    
    .hide-mobile { display: none !important; }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    :root {
        --container-max: min(100% - 3rem, 960px);
        --container-padding: 20px;
    }
    
    .hide-tablet { display: none !important; }
    .grid-cols-2-tablet { grid-template-columns: repeat(2, 1fr); }
}

/* Desktop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    :root {
        --container-max: min(100% - 4rem, 1100px);
    }
    
    .hide-desktop { display: none !important; }
    .grid-cols-3-desktop { grid-template-columns: repeat(3, 1fr); }
}

/* Desktop Large (1200px - 1599px) */
@media (min-width: 1200px) and (max-width: 1599px) {
    :root {
        --container-max: min(100% - 4rem, 1300px);
    }
    
    .grid-cols-4-desktop-lg { grid-template-columns: repeat(4, 1fr); }
}

/* Desktop XL (1600px - 1919px) */
@media (min-width: 1600px) and (max-width: 1919px) {
    :root {
        --container-max: min(100% - 5rem, 1500px);
    }
    
    html {
        font-size: 17px;
    }
}

/* TV / Monitor Grande (1920px - 2559px) */
@media (min-width: 1920px) and (max-width: 2559px) {
    :root {
        --container-max: min(100% - 6rem, 1700px);
    }
    
    html {
        font-size: 18px;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        min-height: 50px;
        padding: var(--space-md) var(--space-lg);
    }
    
    button, .btn {
        min-height: 50px;
        padding: var(--space-md) var(--space-xl);
    }
}

/* Ultra-Wide / TV 4K (2560px+) */
@media (min-width: 2560px) {
    :root {
        --container-max: min(100% - 8rem, 2000px);
    }
    
    html {
        font-size: 20px;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        min-height: 56px;
        padding: var(--space-lg) var(--space-xl);
    }
    
    button, .btn {
        min-height: 56px;
        padding: var(--space-lg) var(--space-2xl);
    }
}

/* ============================================
   LANDSCAPE MOBILE HANDLING
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        min-height: auto;
    }
    
    .modal,
    .overlay-content {
        max-height: 95vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   ACESSIBILIDADE
   ============================================ */

/* Preferência de movimento reduzido */
@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;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    :root {
        --radius-sm: 2px;
        --radius-md: 4px;
        --radius-lg: 6px;
    }
    
    button, .btn, input, select, textarea {
        border-width: 2px;
    }
}

/* ============================================
   iOS SAFARI SPECIFIC
   ============================================ */
@supports (-webkit-touch-callout: none) {
    body {
        /* Suporte para barra de navegação do Safari */
        min-height: -webkit-fill-available;
    }
    
    input, textarea, select {
        font-size: 16px !important; /* Previne zoom */
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        min-height: auto;
        padding: 0;
    }
    
    .no-print {
        display: none !important;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
    }
}

/* ============================================
   UTILIDADES RESPONSIVAS
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.overflow-y-auto {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar thin para WebKit */
.scroll-thin::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.scroll-thin::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-thin::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.4);
    border-radius: 3px;
}

/* ============================================
   ASPECT RATIOS RESPONSIVOS
   ============================================ */
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-photo { aspect-ratio: 4 / 3; }
