/* ============================================================
   MELHORIAS MOBILE - SEM IMPACTAR DESKTOP
   Todas as regras estão dentro de @media queries para mobile
   ============================================================ */

/* ============================================================
   CORREÇÃO 1: LARGURAS FIXAS EXCESSIVAS
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Remover min-width excessivos que causam scroll horizontal */
    .mobile-filter-shipments {
        min-width: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Filtros responsivos */
    .mobile-filter-type-shipments {
        max-width: 100% !important;
        width: 100% !important;
    }

    .mobile-filter-type-shipments select {
        min-width: 100% !important;
        width: 100% !important;
    }

    /* Containers com largura fixa */
    .container-fluid,
    .container {
        max-width: 100% !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* ============================================================
   CORREÇÃO 2: TABELAS RESPONSIVAS
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Remover min-width fixo das tabelas */
    .table {
        min-width: 100% !important;
        width: 100% !important;
        font-size: 0.75rem !important;
    }

    /* Tabelas com scroll horizontal quando necessário */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
    }

    .table-responsive table {
        min-width: 600px !important; /* Mínimo para legibilidade */
    }

    /* Células mais compactas */
    .table th,
    .table td {
        padding: 0.5rem 0.375rem !important;
        font-size: 0.75rem !important;
        white-space: nowrap;
    }

    /* Headers mais compactos */
    .table thead th {
        font-size: 0.688rem !important;
        font-weight: 600 !important;
        padding: 0.5rem 0.375rem !important;
    }
}

/* ============================================================
   CORREÇÃO 3: FILTROS E FORMULÁRIOS
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Filtros em coluna */
    .filter-container,
    .filters-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* Inputs e selects responsivos */
    .form-control,
    .form-select,
    select {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        font-size: 0.875rem !important;
        padding: 0.625rem 0.75rem !important;
        min-height: 44px !important; /* Tamanho mínimo para touch */
    }

    /* Labels mais compactos */
    .form-label {
        font-size: 0.813rem !important;
        margin-bottom: 0.375rem !important;
    }

    /* Botões de formulário */
    .btn {
        min-height: 44px !important; /* Tamanho mínimo para touch */
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Botões pequenos */
    .btn-sm {
        min-height: 38px !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.813rem !important;
    }
}

/* ============================================================
   CORREÇÃO 4: MODAIS MOBILE
   ============================================================ */
@media (max-width: 1199.98px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-content {
        border-radius: 0.5rem !important;
    }

    .modal-header {
        padding: 1rem !important;
    }

    .modal-body {
        padding: 1rem !important;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }

    .modal-footer {
        padding: 0.75rem 1rem !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* ============================================================
   CORREÇÃO 5: CARDS E ESPAÇAMENTO
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Cards mais compactos */
    .card {
        margin-bottom: 1rem !important;
        border-radius: 0.5rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
        font-size: 0.938rem !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-footer {
        padding: 0.75rem 1rem !important;
    }

    /* Espaçamento reduzido */
    .mb-4,
    .mb-5 {
        margin-bottom: 1rem !important;
    }

    .mt-4,
    .mt-5 {
        margin-top: 1rem !important;
    }

    .py-4,
    .py-5 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* ============================================================
   CORREÇÃO 6: BOTÕES E AÇÕES
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Botões com tamanho adequado para touch */
    .btn {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
        touch-action: manipulation;
    }

    /* Botões em grupos */
    .btn-group {
        width: 100% !important;
        flex-direction: column !important;
    }

    .btn-group .btn {
        width: 100% !important;
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Links como botões */
    a.btn {
        display: inline-block;
        text-align: center;
    }
}

/* ============================================================
   CORREÇÃO 7: DROPDOWNS E MENUS
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Dropdowns full width */
    .dropdown-menu {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0.5rem 0 !important;
        border-radius: 0.5rem !important;
    }

    .dropdown-item {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
}

/* ============================================================
   CORREÇÃO 8: NAVEGAÇÃO E BREADCRUMBS
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Breadcrumb oculto em telas muito pequenas */
    .breadcrumb {
        display: none !important;
    }

    /* Títulos mais compactos */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.125rem !important;
    }

    h4, h5, h6 {
        font-size: 1rem !important;
    }
}

/* ============================================================
   CORREÇÃO 9: SIDEBAR MOBILE - Z-INDEX E OVERLAY
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Sidebar com z-index alto quando aberto */
    body.g-sidenav-show.g-sidenav-pinned aside.sidenav {
        z-index: 9999 !important;
    }

    /* Overlay escuro */
    #mobile-menu-overlay {
        z-index: 9998 !important;
        background: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(2px);
    }

    /* Main content com z-index baixo quando sidebar aberto */
    body.g-sidenav-show.g-sidenav-pinned .main-content {
        z-index: 1 !important;
        pointer-events: none !important;
        opacity: 0.5;
    }

    /* Garantir que elementos interativos do main content não sejam clicáveis */
    body.g-sidenav-show.g-sidenav-pinned .main-content > *:not(.navbar-main) {
        pointer-events: none !important;
    }

    /* Navbar sempre acessível */
    body.g-sidenav-show.g-sidenav-pinned .navbar-main {
        z-index: 10000 !important;
        pointer-events: auto !important;
    }
}

/* ============================================================
   CORREÇÃO 10: SIDEBAR MOBILE - DESIGN E LARGURA
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Sidebar tela cheia quando aberto */
    body.g-sidenav-show.g-sidenav-pinned aside.sidenav {
        width: 100vw !important;
        max-width: 100vw !important;
        box-shadow: none !important;
    }

    /* Overlay transparente quando sidebar é tela cheia */
    #mobile-menu-overlay {
        background: transparent !important;
        backdrop-filter: none;
        pointer-events: none;
    }

    /* Hambúrguer menor */
    .sidenav-toggler-inner {
        width: 24px !important;
        height: 18px !important;
    }

    .sidenav-toggler-line {
        height: 2px !important;
    }

    /* Animação do hambúrguer para X */
    body.g-sidenav-pinned .sidenav-toggler-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    body.g-sidenav-pinned .sidenav-toggler-line:nth-child(2) {
        opacity: 0;
        transform: scale(0);
    }

    body.g-sidenav-pinned .sidenav-toggler-line:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* Header do sidebar */
    .sidenav-header {
        padding: 1rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Links do sidebar */
    .sidenav .nav-link {
        padding: 0.875rem 1rem !important;
        font-size: 0.938rem !important;
    }

    /* Seções do sidebar */
    .sidenav .nav-item h6 {
        padding: 0.75rem 1rem !important;
        font-size: 0.75rem !important;
        margin-top: 0.5rem !important;
    }
}

/* ============================================================
   CORREÇÃO 11: UTILITÁRIOS E AJUSTES FINAIS
   ============================================================ */
@media (max-width: 1199.98px) {
    /* Imagens responsivas */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Texto quebra corretamente */
    p, span, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Scroll suave */
    * {
        -webkit-overflow-scrolling: touch;
    }

    /* Prevenir zoom em inputs (iOS) */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important; /* Previne zoom no iOS */
    }

    @media (max-width: 767.98px) {
        input[type="text"],
        input[type="email"],
        input[type="number"],
        input[type="tel"],
        input[type="password"],
        select,
        textarea {
            font-size: 16px !important;
        }
    }
}

/* ============================================================
   FIM DAS MELHORIAS MOBILE
   ============================================================ */

