/* ==========================================
   MOBILE FIXES CSS
   Correções para usabilidade em celulares
   ========================================== */

/* Prevenir zoom em inputs no iOS */
@media (max-width: 1024px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* ==========================================
   1. TOUCH TARGETS MAIOR
   ========================================== */
@media (max-width: 768px) {
    /* Botões e links precisam ter área de toque mínima de 44px */
    .btn, button, .nav-item, .dropdown-btn, .dropdown-item,
    .action-btn, .page-header .menu-toggle, .sidebar-toggle {
        min-height: 44px;
        min-width: 44px;
    }

    /* Aumentar padding de itens clicáveis */
    .nav-item {
        padding: 14px 20px;
    }

    .dropdown-item {
        padding: 14px 16px;
    }

    /* Checkboxes e radios maiores */
    input[type="checkbox"], input[type="radio"] {
        width: 22px;
        height: 22px;
    }

    /* Aumentar área de toque das abas */
    .tab-btn {
        padding: 14px 20px;
        min-height: 48px;
    }
}

/* ==========================================
   2. SIDEBAR MOBILE - MELHORIAS
   ========================================== */
@media (max-width: 1024px) {
    .sidebar {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.open {
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* Animação mais suave em mobile */
    .sidebar {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Overlay mais escuro para contraste */
    .sidebar-overlay.active {
        background: rgba(0, 0, 0, 0.6);
    }

    /* Garantir que o menuToggle está sempre visível e acessível */
    .menu-toggle {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Itens da sidebar com área de toque maior */
    .sidebar-nav .nav-item {
        padding: 16px 20px;
        min-height: 48px;
    }

    .nav-group-toggle {
        padding: 16px 20px;
        min-height: 48px;
    }
}

/* ==========================================
   3. DROPDOWNS EM MOBILE
   ========================================== */
@media (max-width: 768px) {
    .multiselect-dropdown {
        position: relative;
    }

    .dropdown-btn {
        min-height: 48px;
        padding: 12px 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .dropdown-content {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 60vh !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2) !important;
        z-index: 9999 !important;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: block !important;
    }

    .dropdown-content.show {
        transform: translateY(0);
        animation: slideUp 0.3s ease;
    }

    .dropdown-item {
        padding: 16px;
        min-height: 48px;
        border-bottom: 1px solid var(--border-secondary);
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ==========================================
   4. TABELAS EM MOBILE
   ========================================== */
@media (max-width: 768px) {
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .table-wrapper::-webkit-scrollbar {
        height: 6px;
    }

    .table-wrapper::-webkit-scrollbar-track {
        background: var(--bg-tertiary);
        border-radius: 3px;
    }

    .table-wrapper::-webkit-scrollbar-thumb {
        background: var(--border-primary);
        border-radius: 3px;
    }

    /* Células da tabela com padding maior para touch */
    .data-table td, .data-table th {
        padding: 14px 12px;
        min-height: 48px;
    }

    /* Botões de ação na tabela maiores */
    .data-table .btn-sm, .data-table .action-btn {
        min-height: 40px;
        min-width: 40px;
        padding: 8px 12px;
    }
}

/* ==========================================
   5. FORMULÁRIOS EM MOBILE
   ========================================== */
@media (max-width: 768px) {
    .form-group {
        margin-bottom: 20px;
    }

    .form-label {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .form-control, .form-select {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 16px; /* Previne zoom no iOS */
    }

    /* Aumentar área de toque de selects */
    select.form-select {
        padding-right: 40px;
    }

    /* Modais em fullscreen no mobile */
    .modal-content {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        max-width: 100%;
    }

    .modal.active .modal-content {
        animation: modalSlideUp 0.3s ease;
    }
}

@keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ==========================================
   6. CARDS E STATS GRID EM MOBILE
   ========================================== */
@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        min-height: 100px;
    }

    .card {
        padding: 16px;
    }

    /* Aumentar espaçamento entre elementos */
    .main-content {
        padding: 16px;
    }

    .page-header {
        gap: 12px;
        margin-bottom: 20px;
    }
}

/* ==========================================
   7. PAGINATION EM MOBILE
   ========================================== */
@media (max-width: 640px) {
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }

    .pagination-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px;
    }
}

/* ==========================================
   8. TOASTS EM MOBILE
   ========================================== */
@media (max-width: 768px) {
    #toast-container {
        top: auto;
        bottom: 20px;
        left: 16px;
        right: 16px;
    }

    .toast {
        min-height: 56px;
        padding: 16px;
    }
}

/* ==========================================
   9. SCROLL SUAVE
   ========================================== */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================
   10. REMOVE HIGHLIGHT AZUL EM TOUCH
   ========================================== */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Mas mantém outline para acessibilidade via teclado */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
