/* ===== OTIMIZAÇÕES ESPECÍFICAS PARA MOBILE ===== */

/* Melhorias gerais de touch e scroll */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* --- Correções Mobile Específicas --- */
@media (max-width: 600px) {
    /* Reduzir tamanho do avatar e espaçamento */
    .hero-avatar {
        width: 160px !important;
        height: 160px !important;
        margin: 0 auto 1.2rem auto !important;
        display: block;
    }
    .hero-image {
        margin-bottom: 0.5rem !important;
    }
    /* Espaço extra entre imagem e botões fixos */
    .hero-fixed-cta {
        margin-top: 1.2rem !important;
        gap: 0.5rem !important;
    }
    /* Ajuste do grid para 1 coluna e gap menor */
    .hero-content-grid {
        grid-template-columns: 1fr !important;
        gap: 1.2rem !important;
        min-height: unset !important;
    }
    /* Botões ocupando largura total */
    .hero-fixed-cta .btn {
        width: 100% !important;
        max-width: 320px !important;
        font-size: 1rem !important;
    }
    /* Carrossel: garantir visualização dos cards */
    .carousel-track {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        gap: 0.75rem !important;
        padding-bottom: 1.2rem !important;
    }
    .carousel-track > * {
        /* Use a fixed flex-basis for predictable slide widths on mobile */
        flex: 0 0 85vw !important;
        max-width: 95vw !important;
        flex-shrink: 0 !important;
        scroll-snap-align: start !important;
    }
    /* Corrige cards para não ocupar 100% no mobile */
    .product-card {
        /* Match carousel children sizing so cards don't collapse or overflow */
        flex: 0 0 85vw !important;
        max-width: 95vw !important;
        width: auto !important;
    }
    /* Allow the outer carousel container to show overflow on mobile so track can scroll */
    .carousel {
        overflow: visible !important;
    }

    /* On mobile, render hero slides in normal flow so CTAs sit below images */
    .hero-carousel-container {
        min-height: auto !important;
    }

    .hero-slide {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 1 !important;
    }

    /* Keep avatar inside slide but don't overlay CTAs */
    .hero-avatar {
        position: relative !important;
        z-index: 1 !important;
    }

    /* Ensure CTAs are placed after the hero content (below) and have spacing */
    .hero-fixed-cta {
        position: relative !important;
        z-index: 5 !important;
        pointer-events: auto !important;
        margin-top: 1.6rem !important;
    }

    /* Smooth native scrolling on iOS */
    .carousel-track {
        -webkit-overflow-scrolling: touch !important;
        /* Use logical property to better support LTR/RTL and precise snappoints */
        scroll-padding-inline: 8vw !important;
        scroll-snap-type: x mandatory !important;
    }
    /* Esconde dots e controles no mobile */
    .carousel-controls, .about-controls, .dot, .about-dot {
        display: none !important;
    }
    /* Esconde barra de scroll */
    .carousel-track {
        scrollbar-width: none !important; /* Firefox */
        -ms-overflow-style: none !important; /* IE 10+ */
    }
    .carousel-track::-webkit-scrollbar {
        display: none !important;
    }
}

/* Smooth scroll and small-screen adjustments (scoped to mobile/tablet) */
@media (max-width: 1024px) {
    html {
        -webkit-overflow-scrolling: touch;
        /* Prevent horizontal overflow during zoom */
        overflow-x: hidden;
        width: 100%;
        /* Better text scaling on zoom */
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Body improvements for zoom */
    body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    /* Prevent zoom on form inputs while maintaining accessibility */
    input, select, textarea {
        font-size: max(16px, 1rem); /* Prevents zoom on iOS while keeping accessible size */
    }
}

/* Carrosséis - Otimizações Mobile */
@media (max-width: 768px) {
    
    /* Melhoria na área de toque dos carrosséis */
    .carousel-track {
    cursor: grab;
    /* Allow horizontal pan for native swipe */
    touch-action: pan-x pinch-zoom;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        /* Better performance during zoom */
        will-change: transform;
        transform: translateZ(0);
    /* Allow horizontal scrolling on mobile; keep vertical scrolling normal */
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
        box-sizing: border-box;
    }

    /* Position carousel relative so we can place the drag hint overlay */
    .carousel {
        position: relative;
    }

    /* Drag hint (affordance) to indicate horizontal swipe on mobile */
    .carousel .drag-hint {
        position: absolute;
        right: 12px;
        bottom: 12px;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        background: rgba(0,0,0,0.45);
        color: white;
        font-size: 14px;
        border-radius: 20px;
        pointer-events: none; /* don't block gestures */
        z-index: 40;
        opacity: 0.95;
        backdrop-filter: blur(4px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .carousel .drag-hint .hand {
        font-size: 18px;
        transform: translateX(0);
        animation: hand-swipe 1.2s infinite ease-in-out;
    }

    @keyframes hand-swipe {
        0% { transform: translateX(0); }
        50% { transform: translateX(-8px); }
        100% { transform: translateX(0); }
    }
    
    .carousel-track:active {
        cursor: grabbing;
    }
    
    /* Botões de navegação otimizados para touch */
    .carousel-btn,
    .about-btn {
        min-height: max(44px, 8vw) !important; /* Adaptive touch target */
        min-width: max(44px, 8vw) !important;
        position: relative;
        z-index: 10;
        box-sizing: border-box;
        /* Responsive font size */
        font-size: clamp(1rem, 3vw, 1.4rem) !important;
    }
    
    /* Área de toque expandida para botões */
    .carousel-btn::before,
    .about-btn::before {
        content: '';
        position: absolute;
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
        z-index: -1;
    }
    
    /* Dots com área de toque maior */
    .dot,
    .about-dot {
        position: relative;
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    .dot::before,
    .about-dot::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        background: currentColor;
        border-radius: 50%;
        transition: all 0.3s ease;
    }
    
    .dot.active::before,
    .about-dot.active::before {
        transform: translate(-50%, -50%) scale(1.3);
    }
    
    /* Prevenção de zoom duplo toque */
    .carousel-controls,
    .about-controls {
        touch-action: manipulation;
    }
    
    /* Melhoria na rolagem das seções */
    .carousel-container {
        scroll-margin-top: 80px;
    }
    
    /* Performance - will-change para animações */
    .carousel-track,
    .product-card,
    .carousel-btn,
    .dot {
        will-change: transform;
    }
    
    /* Redução de motion para usuários sensíveis */
    @media (prefers-reduced-motion: reduce) {
        .carousel-track {
            transition: none !important;
        }
        
        .carousel-btn,
        .dot,
        .product-card {
            transition: none !important;
            animation: none !important;
        }
    }
}

/* Mobile pequeno - ajustes finais */
@media (max-width: 480px) {
    
    /* Carrosséis mais compactos */
    .carousel {
        margin: 0 2px;
    }
    
    /* Controles com espaçamento otimizado */
    .carousel-controls {
        padding: 0 10px;
        gap: 0.5rem;
    }
    
    /* Cards mais legíveis */
    .product-title {
        font-size: 1.4rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.75rem !important;
    }
    
    .product-description {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }
    
    /* Features list mais compacta */
    .product-features li {
        padding: 0.4rem 0 !important;
        font-size: 0.9rem !important;
    }
    
    /* Botões de compra mais destacados */
    .buy-button {
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3) !important;
    }
    
    .buy-button:active {
        transform: translateY(1px) !important;
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4) !important;
    }
}

/* Orientação landscape em mobile */
@media (max-width: 768px) and (orientation: landscape) {
    
    .product-card {
        grid-template-columns: 1fr 1.5fr !important;
        max-height: 400px;
    }
    
    .product-image {
        min-height: 160px !important;
    }
    
    .product-content {
        padding: 1rem !important;
    }
    
    .carousel-controls {
        margin-top: 1rem !important;
    }
}

/* Estados de loading para carrosséis */
.carousel-loading {
    pointer-events: none;
    opacity: 0.7;
}

.carousel-loading .carousel-track {
    transition: none !important;
}

/* Accessibility - foco visível em mobile */
@media (max-width: 768px) {
    .carousel-btn:focus,
    .dot:focus,
    .about-btn:focus,
    .about-dot:focus {
        outline: 3px solid var(--primary-green) !important;
        outline-offset: 3px !important;
    }
}

/* Dark mode support para mobile */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .carousel-btn {
        border-color: rgba(255, 255, 255, 0.3) !important;
    }
    
    .carousel-counter {
        color: rgba(255, 255, 255, 0.9) !important;
    }
}