/* ==================== MOBILE OPTIMIZATIONS ==================== */
/* Otimizações específicas para dispositivos móveis */

/* ==================== HEADER E NAVEGAÇÃO MOBILE ==================== */
@media (max-width: 767px) {
    /* Header mais compacto no mobile */
    header {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    header nav {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Logo menor no mobile */
    header img {
        height: 2.5rem !important;
        width: 2.5rem !important;
    }
    
    /* Menu mobile horizontal - melhor scroll */
    #mobileMenuExpanded {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    #mobileMenuExpanded::-webkit-scrollbar {
        display: none;
    }
    
    /* Botões do header mobile - tamanho mínimo para touch */
    header button,
    header a {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Menu mobile expandido - melhor espaçamento */
    #mobileMenuExpanded .flex {
        gap: 0.5rem;
    }
}

/* ==================== MODAIS MOBILE ==================== */
@media (max-width: 767px) {
    /* Todos os modais - fullscreen no mobile */
    .modal,
    #purchaseModal,
    #scheduleModal,
    #loginModal,
    #tokensModal,
    #freeWhatsModal,
    #clientAreaModal {
        padding: 0 !important;
        align-items: flex-start !important;
    }
    
    .modal > div,
    #purchaseModal > div,
    #scheduleModal > div,
    #loginModal > div,
    #tokensModal > div,
    #freeWhatsModal > div,
    #clientAreaModal > div {
        max-height: 100vh !important;
        height: 100vh !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Padding interno dos modais */
    .modal .p-6,
    #purchaseModal .p-6,
    #scheduleModal .p-6,
    #loginModal .p-6 {
        padding: 1rem !important;
    }
    
    /* Títulos dos modais - menor no mobile */
    .modal h2,
    .modal h3 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    /* Botão fechar modal - maior para touch */
    .modal button[onclick*="close"],
    .modal .close-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.5rem;
    }
}

/* ==================== CARDS E PRODUTOS MOBILE ==================== */
@media (max-width: 767px) {
    /* Cards de produtos - melhor espaçamento */
    .product-card,
    .event-card {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }
    
    /* Imagens dos cards - altura fixa no mobile */
    .product-card img,
    .event-card img {
        height: 180px;
        object-fit: cover;
    }
    
    /* Títulos dos cards - menor */
    .product-card h3,
    .event-card h3 {
        font-size: 1.125rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.5rem;
    }
    
    /* Texto dos cards - menor */
    .product-card p,
    .event-card p {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }
    
    /* Preços - destaque no mobile */
    .product-card .price,
    .event-card .price {
        font-size: 1.25rem !important;
        font-weight: 700;
    }
    
    /* Botões dos cards - full width no mobile */
    .product-card button,
    .event-card button {
        width: 100%;
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}

/* ==================== FORMULÁRIOS E INPUTS MOBILE ==================== */
@media (max-width: 767px) {
    /* Todos os inputs - tamanho mínimo para touch (44px) */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    input[type="date"],
    textarea,
    select {
        min-height: 44px !important;
        font-size: 16px !important; /* Evita zoom no iOS */
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem !important;
    }
    
    /* Labels - melhor espaçamento */
    label {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
        display: block;
    }
    
    /* Grupos de formulário - melhor espaçamento */
    .form-group,
    .space-y-4 > * + * {
        margin-top: 1rem !important;
    }
    
    /* Botões de formulário - full width no mobile */
    form button[type="submit"],
    .btn-primary,
    .btn-secondary {
        width: 100%;
        min-height: 44px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        font-weight: 600;
    }
    
    /* Checkboxes e radios - maior para touch */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
    }
}

/* ==================== GRID DE HORÁRIOS MOBILE ==================== */
@media (max-width: 767px) {
    /* Grid de slots - 2 colunas no mobile */
    .slot-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    /* Botões de slot - melhor para touch */
    .slot-btn {
        min-height: 60px !important;
        padding: 0.75rem 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Grid de times - 1 coluna no mobile */
    .teams-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

/* ==================== TIPOGRAFIA MOBILE ==================== */
@media (max-width: 767px) {
    /* Títulos principais - responsivos */
    h1 {
        font-size: clamp(1.75rem, 8vw, 2.5rem) !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: clamp(1.25rem, 5vw, 1.5rem) !important;
        line-height: 1.4 !important;
    }
    
    /* Parágrafos - melhor legibilidade */
    p {
        font-size: 0.9375rem !important;
        line-height: 1.6 !important;
    }
    
    /* Texto pequeno - ainda legível */
    .text-sm {
        font-size: 0.875rem !important;
    }
    
    .text-xs {
        font-size: 0.8125rem !important;
    }
}

/* ==================== BOTÕES FLUTUANTES (FAB) MOBILE ==================== */
@media (max-width: 767px) {
    /* FAB do carrinho - melhor posicionamento */
    #cartFab {
        bottom: 1rem !important;
        right: 1rem !important;
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }
    
    /* Botão voltar ao topo - melhor posicionamento */
    #backToTop {
        bottom: 5rem !important;
        right: 1rem !important;
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }
    
    /* Chat FAB - melhor posicionamento */
    #chatFab {
        bottom: 1rem !important;
        left: 1rem !important;
        width: 56px !important;
        height: 56px !important;
    }
}

/* ==================== TOASTS MOBILE ==================== */
@media (max-width: 640px) {
    #toastContainer {
        right: 0.5rem !important;
        left: 0.5rem !important;
        max-width: calc(100vw - 1rem) !important;
        top: 4rem !important;
    }
    
    .toast {
        width: 100% !important;
        min-width: 0 !important;
        padding: 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* ==================== SEÇÕES E CONTAINERS MOBILE ==================== */
@media (max-width: 767px) {
    /* Containers - padding reduzido */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Seções - padding vertical reduzido */
    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* Hero section - altura ajustada */
    #home {
        min-height: calc(100vh - 80px) !important;
        padding-top: 5rem !important;
    }
    
    /* Grids - 1 coluna no mobile (mas respeitar classes Tailwind específicas) */
    .grid:not([class*="grid-cols"]) {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Forçar 1 coluna em grids responsivos do Tailwind no mobile */
    [class*="md:grid-cols-2"],
    [class*="lg:grid-cols-3"],
    [class*="lg:grid-cols-4"],
    [class*="lg:grid-cols-5"] {
        grid-template-columns: 1fr !important;
    }
}

/* ==================== TABELAS MOBILE ==================== */
@media (max-width: 767px) {
    /* Tabelas - scroll horizontal */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Células da tabela - padding reduzido */
    table td,
    table th {
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Alternativa: cards ao invés de tabela */
    .table-mobile-card {
        display: block;
    }
    
    .table-mobile-card thead {
        display: none;
    }
    
    .table-mobile-card tbody,
    .table-mobile-card tr,
    .table-mobile-card td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-card tr {
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        padding: 1rem;
    }
    
    .table-mobile-card td {
        padding: 0.5rem 0 !important;
        text-align: left !important;
    }
    
    .table-mobile-card td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        display: inline-block;
        width: 40%;
    }
}

/* ==================== IMAGENS E MÍDIA MOBILE ==================== */
@media (max-width: 767px) {
    /* Imagens - responsivas */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Imagens de fundo - otimizadas */
    .bg-image {
        background-size: cover;
        background-position: center;
    }
    
    /* Vídeos - responsivos */
    video,
    iframe {
        width: 100%;
        height: auto;
        max-height: 50vh;
    }
}

/* ==================== CHAT MOBILE ==================== */
@media (max-width: 480px) {
    #chatWindow {
        width: calc(100vw - 1rem) !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
        height: 70vh !important;
        max-height: 70vh !important;
        bottom: 5rem !important;
    }
    
    #chatWindow .p-4 {
        padding: 0.75rem !important;
    }
}

/* ==================== UTILITÁRIOS MOBILE ==================== */
@media (max-width: 767px) {
    /* Espaçamentos reduzidos */
    .space-y-8 > * + * {
        margin-top: 1.5rem !important;
    }
    
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }
    
    .space-y-4 > * + * {
        margin-top: 0.75rem !important;
    }
    
    /* Padding vertical reduzido */
    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .py-12 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    .py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Margens reduzidas */
    .mb-8 {
        margin-bottom: 1.5rem !important;
    }
    
    .mb-6 {
        margin-bottom: 1rem !important;
    }
    
    .mt-8 {
        margin-top: 1.5rem !important;
    }
    
    .mt-6 {
        margin-top: 1rem !important;
    }
}

/* ==================== SAFE AREA (iPhone notch) ==================== */
@supports (padding: max(0px)) {
    @media (max-width: 767px) {
        header {
            padding-top: max(0.5rem, env(safe-area-inset-top)) !important;
        }
        
        #cartFab,
        #backToTop,
        #chatFab {
            bottom: max(1rem, env(safe-area-inset-bottom)) !important;
        }
        
        .modal > div {
            padding-top: max(1rem, env(safe-area-inset-top)) !important;
            padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ==================== PERFORMANCE MOBILE ==================== */
@media (max-width: 767px) {
    /* Reduzir animações em dispositivos lentos */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
    
    /* Otimizar renderização */
    .product-card,
    .event-card {
        will-change: transform;
        transform: translateZ(0);
    }
}

