/* ================================================
   CORREÇÃO OVERFLOW HORIZONTAL MOBILE
   Aplicado apenas em dispositivos móveis
   Desktop permanece 100% inalterado
   ================================================ */

/* ========== RESET GLOBAL MOBILE ========== */
@media only screen and (max-width: 768px) {
    /* Prevenir overflow horizontal no documento */
    html {
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Container Bootstrap */
    .container,
    .container-fluid,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl {
        max-width: 100% !important;
        overflow-x: hidden !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Rows e Cols Bootstrap */
    .row {
        margin-left: -15px !important;
        margin-right: -15px !important;
        max-width: calc(100% + 30px) !important;
    }
    
    [class*="col-"] {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* ========== CARROSSEL/SWIPER MOBILE ========== */
@media only screen and (max-width: 768px) {
    /* Hero Section Container */
    .hero-section {
        max-width: 100vw !important;
        width: 100% !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }
    
    /* Hero Carousel */
    .hero-carousel,
    .swiper.hero-carousel {
        max-width: 100vw !important;
        width: 100% !important;
        height: auto !important;
        min-height: 200px !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
    }
    
    .swiper,
    .swiper-container {
        max-width: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
        margin: 0 !important;
        height: auto !important;
    }
    
    .swiper-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }
    
    .swiper-slide {
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        overflow: hidden !important;
    }
    
    .swiper-slide img,
    .slide-bg {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        max-height: 300px !important;
        object-fit: cover !important;
        display: block !important;
    }
    
    /* Links nos slides devem funcionar */
    .swiper-slide a,
    .slide-link {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Controles do Swiper */
    .swiper-button-next,
    .swiper-button-prev {
        right: 10px !important;
        left: 10px !important;
        width: 35px !important;
        height: 35px !important;
    }
    
    .swiper-button-next {
        right: 10px !important;
        left: auto !important;
    }
    
    .swiper-button-prev {
        left: 10px !important;
        right: auto !important;
    }
    
    .swiper-pagination {
        bottom: 10px !important;
        width: 100% !important;
        padding: 0 20px !important;
    }
}

/* ========== BOTÕES FLUTUANTES MOBILE ========== */
@media only screen and (max-width: 768px) {
    /* VLibras Widget */
    .vw-plugin-wrapper,
    [vw] .enabled,
    div[vw] {
        right: 10px !important;
        left: auto !important;
        max-width: 50px !important;
        position: fixed !important;
        z-index: 9999 !important;
    }
    
    /* Botão Admin - Removido da posição flutuante */
    /* Admin agora fica na barra superior */
    
    /* Botão Voltar ao Topo */
    .back-to-top,
    .btn-back-to-top,
    #backToTop,
    [onclick*="scrollToTop"],
    [href="#top"] {
        position: fixed !important;
        bottom: 20px !important;
        right: 10px !important;
        left: auto !important;
        width: 50px !important;
        height: 50px !important;
        max-width: 50px !important;
        z-index: 997 !important;
    }
    
    /* WhatsApp Float */
    .whatsapp-float,
    .whatsapp-btn,
    .fab-whatsapp {
        position: fixed !important;
        bottom: 140px !important;
        right: 10px !important;
        left: auto !important;
        width: 50px !important;
        height: 50px !important;
        max-width: 50px !important;
        z-index: 996 !important;
    }
}

/* ========== ACCESSIBILITY BAR MOBILE ========== */
@media only screen and (max-width: 768px) {
    .accessibility-bar {
        width: 100% !important;
        max-width: 100vw !important;
        overflow: hidden !important;
        padding: 8px 10px !important;
        min-height: auto !important;
    }
    
    .accessibility-bar .container {
        padding: 0 !important;
    }
    
    .accessibility-controls {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .btn-access {
        flex-shrink: 0 !important;
        min-width: 38px !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
        height: 32px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .btn-access i {
        font-size: 14px !important;
    }
    
    .btn-access .access-icon {
        font-size: 13px !important;
    }
    
    .btn-access sup {
        font-size: 10px !important;
    }
    
    /* Esconder textos, mostrar só ícones */
    .btn-access .d-none.d-md-inline {
        display: none !important;
    }
    
    .access-divider {
        display: none !important;
    }
    
    /* Admin button no topo */
    .admin-link,
    a[href*="admin"] {
        position: relative !important;
        margin-left: auto !important;
    }
}

/* ========== TOP BAR E HEADER MOBILE ========== */
@media only screen and (max-width: 768px) {
    .top-info-bar {
        width: 100% !important;
        max-width: 100vw !important;
        overflow: hidden !important;
        padding: 8px 10px !important;
    }
    
    .top-info-bar .info-item {
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* Navbar */
    .navbar {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 10px 15px !important;
    }
    
    .navbar-brand img {
        max-width: 200px !important;
        height: auto !important;
    }
    
    .navbar-collapse {
        width: 100% !important;
        max-width: 100vw !important;
    }
}

/* ========== CARDS E GRIDS MOBILE ========== */
@media only screen and (max-width: 768px) {
    /* Service Cards */
    .service-box,
    .service-flip-container,
    .licitacao-card,
    .concurso-card,
    .news-card {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        overflow: hidden !important;
    }
    
    /* Stats Cards */
    .stats-card,
    .stat-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 20px 0 !important;
    }
    
    /* Grid genérico */
    .grid,
    .grid-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ========== TABELAS MOBILE ========== */
@media only screen and (max-width: 768px) {
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .table-responsive {
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 !important;
    }
}

/* ========== IMAGENS E MEDIA MOBILE ========== */
@media only screen and (max-width: 768px) {
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    iframe {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    video {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
}

/* ========== TEXTOS LONGOS MOBILE ========== */
@media only screen and (max-width: 768px) {
    p, span, a, div {
        word-wrap: break-word !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        word-wrap: break-word !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
    }
}

/* ========== POPOVERS E MODALS MOBILE ========== */
@media only screen and (max-width: 768px) {
    .popover,
    .tooltip {
        max-width: 90vw !important;
    }
    
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    .modal-content {
        width: 100% !important;
    }
    
    /* Popover de Contato */
    .contato-popover {
        max-width: 85vw !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

/* ========== ELEMENTOS POSITION ABSOLUTE/FIXED ========== */
@media only screen and (max-width: 768px) {
    [style*="position: absolute"],
    [style*="position: fixed"] {
        /* Garantir que não vaze */
        max-width: 100vw !important;
    }
    
    /* Elementos decorativos que podem vazar */
    [style*="position: absolute"][style*="right: -"],
    [style*="position: absolute"][style*="left: -"] {
        display: none !important;
    }
}

/* ========== BREADCRUMBS MOBILE ========== */
@media only screen and (max-width: 768px) {
    .breadcrumb {
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ========== FOOTER MOBILE ========== */
@media only screen and (max-width: 768px) {
    footer {
        width: 100% !important;
        max-width: 100vw !important;
        overflow: hidden !important;
    }
    
    .footer-content,
    .footer-bottom {
        width: 100% !important;
        padding: 20px 15px !important;
    }
}

/* ========== BREAKPOINTS ESPECÍFICOS ========== */

/* iPhone SE, Galaxy S8 */
@media only screen and (max-width: 375px) {
    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* iPhone 12/13 mini */
@media only screen and (max-width: 390px) {
    body {
        font-size: 14px !important;
    }
}

/* iPhone 12/13/14 */
@media only screen and (max-width: 414px) {
    .hero-carousel {
        height: 250px !important;
    }
}

/* iPhone 14 Pro Max */
@media only screen and (max-width: 430px) {
    .service-box {
        padding: 20px 15px !important;
    }
}

/* ========== UTILITY CLASSES MOBILE ========== */
@media only screen and (max-width: 768px) {
    /* Esconder elementos que causam overflow */
    .overflow-hidden-mobile {
        overflow: hidden !important;
    }
    
    .max-width-100 {
        max-width: 100% !important;
    }
    
    .no-horizontal-scroll {
        overflow-x: hidden !important;
    }
    
    /* Debug - remover após testes */
    .debug-border * {
        border: 1px solid red !important;
    }
}