/**
 * NETZERO - Correções de Responsividade Mobile
 * =============================================
 * Este arquivo contém ajustes para dispositivos móveis.
 * Não afeta a versão desktop (usa media queries condicionais).
 */

/* =========================================================================
   TABELAS RESPONSIVAS
   ========================================================================= */

.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .table th,
    .table td {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Botões de ação empilhados */
    .table .d-flex.gap-1 {
        flex-direction: column;
        gap: 0.25rem !important;
    }

    .table .btn-sm {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Indicador de scroll horizontal */
    .table-responsive-wrapper::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .table-responsive-wrapper.has-scroll::after {
        opacity: 1;
    }
}

/* =========================================================================
   HEADER RESPONSIVO
   ========================================================================= */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 10px 15px !important;
    }

    .logo {
        font-size: 1.4rem !important;
        justify-content: center;
    }

    .logo::before {
        font-size: 1.8rem !important;
    }

    .header-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px !important;
    }

    .company-selector,
    .company-dropdown {
        width: 100%;
        text-align: center;
    }

    .user-info {
        flex-direction: column;
        text-align: center;
        gap: 5px !important;
    }

    .company-user-info {
        min-width: auto !important;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .header {
        padding: 10px 0 !important;
    }

    .logo {
        font-size: 1.2rem !important;
    }

    .logo::before {
        font-size: 1.5rem !important;
    }
}

/* =========================================================================
   BOTÕES DE IDIOMA E BADGES FIXOS
   ========================================================================= */

@media (max-width: 768px) {
    .lang-btn {
        position: fixed !important;
        top: auto !important;
        bottom: 70px !important;
        right: 10px !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
        z-index: 9999 !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    }

    .netzero-badge {
        position: fixed !important;
        top: auto !important;
        bottom: 20px !important;
        left: 10px !important;
        right: auto !important;
        padding: 5px 8px !important;
        font-size: 8px !important;
    }
}

@media (max-width: 576px) {
    .lang-btn {
        bottom: 60px !important;
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    .netzero-badge {
        display: none !important;
    }
}

/* =========================================================================
   DASHBOARD GRID
   ========================================================================= */

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .sidebar {
        order: -1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem !important;
    }

    .modules-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

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

    .module-icon {
        font-size: 2rem !important;
    }

    .module-title {
        font-size: 1.1rem !important;
    }

    .module-description {
        font-size: 0.9rem !important;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0.75rem !important;
    }

    .welcome-section {
        padding: 1rem !important;
    }

    .welcome-section h2 {
        font-size: 1.3rem !important;
    }

    .card {
        padding: 1rem !important;
        border-radius: 10px !important;
    }
}

/* =========================================================================
   SIDEBAR MOBILE (MENU HAMBURGUER)
   ========================================================================= */

@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        left: -100% !important;
        top: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        z-index: 1050 !important;
        transition: left 0.3s ease !important;
        overflow-y: auto !important;
        border-radius: 0 !important;
        box-shadow: 5px 0 20px rgba(0,0,0,0.2) !important;
    }

    .sidebar.active {
        left: 0 !important;
    }

    /* Overlay quando sidebar está aberta */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Botão menu hamburguer */
    .mobile-menu-btn {
        display: flex !important;
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: linear-gradient(135deg, #2d5a27, #4a7c59);
        color: white;
        border: none;
        padding: 12px 24px;
        border-radius: 30px;
        font-size: 14px;
        font-weight: 600;
        z-index: 1000;
        box-shadow: 0 4px 15px rgba(45,90,39,0.4);
        cursor: pointer;
        align-items: center;
        gap: 8px;
    }

    .mobile-menu-btn i {
        font-size: 16px;
    }

    /* Botão fechar sidebar */
    .sidebar-close {
        display: block !important;
        position: absolute;
        top: 15px;
        right: 15px;
        background: #f8f9fa;
        border: none;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        font-size: 18px;
        cursor: pointer;
        color: #666;
    }
}

/* Esconder elementos mobile no desktop */
.mobile-menu-btn,
.sidebar-close,
.sidebar-overlay {
    display: none;
}

/* =========================================================================
   FORMULÁRIOS MOBILE
   ========================================================================= */

@media (max-width: 768px) {
    .content-box {
        padding: 1rem !important;
        border-radius: 8px !important;
        margin-left: -5px;
        margin-right: -5px;
    }

    .field-group {
        padding: 0.875rem !important;
        margin-bottom: 1rem !important;
    }

    .field-group h6 {
        font-size: 0.9rem !important;
    }

    .form-label {
        font-size: 0.9rem !important;
    }

    .form-control,
    .form-select {
        font-size: 16px !important; /* Previne zoom iOS */
        padding: 0.6rem 0.75rem !important;
    }

    /* Botões de ação do formulário */
    .form-actions {
        flex-direction: column-reverse !important;
        gap: 0.75rem !important;
        padding: 1rem 0 !important;
    }

    .form-actions .btn {
        width: 100% !important;
        padding: 0.875rem !important;
        font-size: 1rem !important;
    }

    /* d-flex com justify-content-between */
    .d-flex.justify-content-between {
        flex-direction: column-reverse !important;
        gap: 0.75rem !important;
    }

    .d-flex.justify-content-between .btn {
        width: 100% !important;
    }
}

@media (max-width: 576px) {
    .content-box {
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0 !important;
    }

    .page-header {
        padding: 1rem !important;
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0 !important;
    }

    .page-header h2 {
        font-size: 1.2rem !important;
    }
}

/* =========================================================================
   MODAIS MOBILE
   ========================================================================= */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }

    .modal-content {
        border-radius: 12px !important;
    }

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

    .modal-body {
        padding: 1rem !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
    }

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

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

/* =========================================================================
   GRÁFICOS E DASHBOARDS
   ========================================================================= */

@media (max-width: 768px) {
    .chart-container,
    [class*="chart"] {
        min-height: 200px !important;
        max-height: 280px !important;
    }

    canvas {
        max-width: 100% !important;
    }

    /* Cards de métricas */
    .metric-card,
    .stat-card,
    .kpi-card {
        padding: 1rem !important;
    }

    .metric-value,
    .stat-value {
        font-size: 1.5rem !important;
    }

    /* Progress bars */
    .usage-bar {
        width: 100% !important;
        margin-top: 5px;
    }

    .usage-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 5px !important;
    }

    /* Barras de progresso em reports */
    .progress-bar-container {
        width: 100% !important;
    }
}

/* =========================================================================
   ALERTAS E MENSAGENS
   ========================================================================= */

@media (max-width: 768px) {
    .alert {
        padding: 0.875rem !important;
        font-size: 0.9rem !important;
        border-radius: 8px !important;
    }

    .alert i {
        font-size: 1rem !important;
    }

    .trial-warning {
        padding: 0.875rem !important;
    }

    .trial-warning h4 {
        font-size: 1rem !important;
    }
}

/* =========================================================================
   NAVEGAÇÃO E BREADCRUMBS
   ========================================================================= */

@media (max-width: 768px) {
    .breadcrumbs {
        padding: 10px 15px !important;
    }

    .breadcrumbs h2 {
        font-size: 1.2rem !important;
    }

    .breadcrumbs ol {
        font-size: 0.8rem !important;
    }

    /* Navbar mobile */
    .navbar {
        padding: 0.5rem 0 !important;
    }

    .navbar-brand {
        font-size: 1.2rem !important;
    }
}

/* =========================================================================
   LISTAS E CARDS
   ========================================================================= */

@media (max-width: 768px) {
    .list-group-item {
        padding: 0.875rem !important;
    }

    .card-header,
    .card-footer {
        padding: 0.875rem !important;
    }

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

    .card-title {
        font-size: 1.1rem !important;
    }
}

/* =========================================================================
   UTILITÁRIOS MOBILE
   ========================================================================= */

@media (max-width: 768px) {
    /* Esconder em mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Mostrar apenas em mobile */
    .show-mobile {
        display: block !important;
    }

    /* Texto menor em mobile */
    .text-mobile-sm {
        font-size: 0.85rem !important;
    }

    /* Padding reduzido */
    .p-mobile-2 {
        padding: 0.5rem !important;
    }

    /* Margin reduzido */
    .m-mobile-2 {
        margin: 0.5rem !important;
    }

    /* Full width em mobile */
    .w-mobile-100 {
        width: 100% !important;
    }
}

/* Esconder no desktop */
.show-mobile {
    display: none;
}

/* =========================================================================
   TOUCH IMPROVEMENTS
   ========================================================================= */

@media (max-width: 768px) {
    /* Área de toque maior para links e botões */
    .btn,
    .nav-link,
    .list-group-item-action {
        min-height: 44px;
    }

    /* Espaçamento entre elementos clicáveis */
    .btn + .btn,
    .nav-link + .nav-link {
        margin-left: 0;
    }

    /* Feedback visual de toque */
    .btn:active,
    .card:active,
    .list-group-item:active {
        transform: scale(0.98);
    }
}

/* =========================================================================
   SCROLL SUAVE E PERFORMANCE
   ========================================================================= */

@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }

    /* Evitar reflow durante scroll */
    .content-box,
    .card,
    .sidebar {
        will-change: transform;
    }

    /* Scroll momentum no iOS */
    .modal-body,
    .sidebar,
    .table-responsive-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}

/* =========================================================================
   ESG.HTML ESPECÍFICO
   ========================================================================= */

@media (max-width: 768px) {
    /* Menu lateral ESG */
    .esg-sidebar,
    .nav-sidebar {
        position: fixed !important;
        left: -100% !important;
        width: 85% !important;
        max-width: 300px !important;
        height: 100vh !important;
        z-index: 1050 !important;
        transition: left 0.3s ease !important;
    }

    .esg-sidebar.active,
    .nav-sidebar.active {
        left: 0 !important;
    }

    /* Conteúdo principal ocupa 100% */
    .main-content,
    .esg-content {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Cards de módulos */
    .module-grid {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================================================
   PORTAL.HTML ESPECÍFICO
   ========================================================================= */

@media (max-width: 768px) {
    /* Container do portal */
    .portal-container {
        grid-template-columns: 1fr !important;
        padding: 1rem !important;
    }

    /* Sidebar do portal */
    .portal-sidebar {
        position: fixed !important;
        left: -100% !important;
        width: 85% !important;
        max-width: 300px !important;
        height: 100vh !important;
        top: 0 !important;
        z-index: 1050 !important;
        transition: left 0.3s ease !important;
        background: white !important;
    }

    .portal-sidebar.active {
        left: 0 !important;
    }

    /* Menu items */
    .portal-menu-item {
        padding: 12px 16px !important;
        font-size: 0.95rem !important;
    }
}

/* =========================================================================
   FOOTER MOBILE
   ========================================================================= */

@media (max-width: 768px) {
    .netzero-footer {
        padding: 15px 10px !important;
        font-size: 9px !important;
        margin-bottom: 80px !important; /* Espaço para botão menu flutuante */
    }

    #footer {
        padding: 20px 15px !important;
    }

    #footer h3 {
        font-size: 1.5rem !important;
    }

    #footer .social-links a {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
    }
}

/* =========================================================================
   DATEPICKER MOBILE
   ========================================================================= */

@media (max-width: 768px) {
    .flatpickr-calendar {
        width: calc(100vw - 20px) !important;
        max-width: 320px !important;
    }

    .flatpickr-months {
        padding: 5px !important;
    }

    .flatpickr-day {
        height: 38px !important;
        line-height: 38px !important;
    }
}

/* =========================================================================
   DATATABLES MOBILE
   ========================================================================= */

@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: center !important;
        margin-bottom: 10px !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 5px !important;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 10px !important;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 8px 12px !important;
    }
}

/* =========================================================================
   SITE.HTML - PÁGINA INSTITUCIONAL
   ========================================================================= */

@media (max-width: 768px) {
    /* Top bar esconder em mobile */
    #topbar {
        display: none !important;
    }

    /* Header fixo */
    #header {
        height: auto !important;
        padding: 10px 0 !important;
    }

    #header .container {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    #header .logo {
        font-size: 1.2rem !important;
    }

    #header .logo img {
        max-height: 35px !important;
    }

    /* Hero section */
    #hero {
        height: auto !important;
        min-height: 60vh !important;
    }

    #hero h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }

    #hero p {
        font-size: 0.9rem !important;
        padding: 0 10px !important;
    }

    #hero .carousel-container {
        left: 15px !important;
        right: 15px !important;
    }

    #hero .btn-get-started {
        padding: 12px 25px !important;
        font-size: 13px !important;
    }

    /* Carousel controls */
    #hero .carousel-control-prev,
    #hero .carousel-control-next {
        width: 40px !important;
    }

    #hero .carousel-control-prev-icon,
    #hero .carousel-control-next-icon {
        width: 40px !important;
        height: 40px !important;
    }

    /* Featured services */
    #featured-services .icon-box {
        padding: 15px !important;
        text-align: center;
    }

    #featured-services .icon i {
        font-size: 32px !important;
    }

    #featured-services .title {
        font-size: 1rem !important;
    }

    #featured-services .description {
        font-size: 0.85rem !important;
    }

    /* Sections gerais */
    section {
        padding: 40px 0 !important;
    }

    .section-title h2 {
        font-size: 1.5rem !important;
    }

    .section-title p {
        font-size: 0.85rem !important;
    }

    /* About section */
    .about .content h3 {
        font-size: 1.3rem !important;
    }

    .about .content ul li {
        font-size: 0.9rem !important;
    }

    /* Services */
    .services .icon-box {
        padding: 30px 15px !important;
    }

    .services .icon-box h4 {
        font-size: 1.1rem !important;
    }

    /* CTA */
    .cta {
        padding: 40px 0 !important;
    }

    .cta h3 {
        font-size: 1.3rem !important;
    }

    .cta .cta-btn {
        display: block !important;
        margin: 10px auto !important;
        width: 80% !important;
    }

    /* Team */
    .team .member {
        padding: 20px 15px !important;
    }

    .team .member img {
        max-width: 50% !important;
    }

    .team .member h4 {
        font-size: 1rem !important;
    }

    /* Contact */
    .contact .info {
        padding: 20px !important;
    }

    .contact .info h4 {
        font-size: 1rem !important;
        padding-left: 50px !important;
    }

    .contact .info p {
        padding-left: 50px !important;
        font-size: 0.85rem !important;
    }

    .contact .php-email-form {
        padding: 20px !important;
    }

    /* Why Us */
    .why-us .content-item {
        padding: 25px 15px !important;
    }

    .why-us .content-item h4 {
        font-size: 1.2rem !important;
    }

    /* Navbar mobile já existe no style.css, mas melhorar */
    .navbar-mobile ul {
        top: 50px !important;
        padding: 15px !important;
    }

    .navbar-mobile a {
        padding: 12px 15px !important;
        font-size: 1rem !important;
    }

    .navbar-mobile .getstarted {
        margin: 15px !important;
        text-align: center !important;
    }

    /* Language switcher mobile */
    .language-switcher {
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        z-index: 9999 !important;
    }

    .language-btn {
        padding: 10px 15px !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    }

    .language-dropdown {
        bottom: 100% !important;
        top: auto !important;
        margin-bottom: 5px !important;
    }
}

@media (max-width: 576px) {
    #hero h2 {
        font-size: 1.3rem !important;
    }

    #hero p {
        font-size: 0.85rem !important;
    }

    .section-title h2 {
        font-size: 1.3rem !important;
    }

    /* Cards empilhados */
    .row > [class*="col-"] {
        margin-bottom: 15px;
    }
}

/* =========================================================================
   PORTAL.HTML - PÁGINA DE LOGIN
   ========================================================================= */

@media (max-width: 768px) {
    /* Container do portal - centralizado */
    .portal-container,
    .login-container,
    .auth-container {
        width: 95% !important;
        max-width: 400px !important;
        margin: 20px auto !important;
        padding: 1.5rem !important;
    }

    /* Logo no portal */
    .portal-logo,
    .auth-logo {
        font-size: 1.5rem !important;
    }

    .portal-logo::before,
    .auth-logo::before {
        font-size: 2rem !important;
    }

    /* Formulário de login */
    .login-form,
    .auth-form {
        padding: 1.5rem !important;
    }

    .login-form h2,
    .auth-form h2 {
        font-size: 1.3rem !important;
    }

    .login-form .form-control,
    .auth-form .form-control {
        font-size: 16px !important; /* Previne zoom iOS */
        padding: 12px 15px !important;
    }

    .login-form .btn,
    .auth-form .btn {
        padding: 12px !important;
        font-size: 1rem !important;
    }

    /* Cards de empresa no portal */
    .company-card,
    .portal-card {
        padding: 1rem !important;
    }

    .company-card h3,
    .portal-card h3 {
        font-size: 1.1rem !important;
    }

    /* Tabs no portal */
    .portal-tabs,
    .auth-tabs {
        flex-direction: column !important;
    }

    .portal-tabs .tab,
    .auth-tabs .tab {
        width: 100% !important;
        text-align: center !important;
    }

    /* Info do usuário */
    .user-welcome {
        font-size: 0.9rem !important;
        text-align: center !important;
    }

    /* Background animation menor */
    .bg-animation .leaf {
        width: 15px !important;
        height: 15px !important;
    }
}

@media (max-width: 576px) {
    .portal-container,
    .login-container,
    .auth-container {
        width: 100% !important;
        margin: 10px !important;
        border-radius: 10px !important;
    }
}

/* =========================================================================
   MELHORIAS GERAIS PARA TOQUE
   ========================================================================= */

@media (max-width: 768px) {
    /* Links e botões com área de toque maior */
    a, button, .btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Inputs mais fáceis de usar */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* Previne zoom no iOS */
    }

    /* Espaçamento entre elementos interativos */
    .btn + .btn {
        margin-top: 10px;
    }

    /* Scrollbar mais visível em mobile */
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 3px;
    }
}

/* =========================================================================
   INDEX.HTML - PÁGINA INICIAL (HOME)
   ========================================================================= */

@media (max-width: 768px) {
    /* Header da página inicial */
    header .container {
        flex-direction: column !important;
        gap: 15px !important;
        padding: 15px !important;
    }

    header .logo h1 {
        font-size: 1.3rem !important;
        text-align: center;
    }

    /* Hero section */
    .hero-section {
        padding: 40px 20px !important;
    }

    .hero-content h1 {
        font-size: 1.8rem !important;
        line-height: 1.3 !important;
    }

    .hero-content p {
        font-size: 1rem !important;
        padding: 0 10px !important;
    }

    .btn-main {
        padding: 12px 25px !important;
        font-size: 0.95rem !important;
        display: inline-block !important;
        width: auto !important;
    }

    /* Seções de conteúdo */
    section {
        padding: 40px 15px !important;
    }

    section h2 {
        font-size: 1.5rem !important;
        margin-bottom: 20px !important;
    }

    /* Cards de módulos */
    .module-card {
        flex-direction: column !important;
        text-align: center !important;
        padding: 20px 15px !important;
    }

    .module-card .icon {
        margin-bottom: 15px !important;
    }

    .module-card h3 {
        font-size: 1.1rem !important;
    }

    .module-card p {
        font-size: 0.9rem !important;
    }

    /* Link do sistema */
    .system-link {
        width: 100% !important;
        text-align: center !important;
        padding: 12px 20px !important;
    }

    /* Language selector */
    .language-selector {
        justify-content: center !important;
        width: 100% !important;
    }

    .lang-btn {
        padding: 8px 15px !important;
    }

    /* What is ESG section */
    #what-is-esg .container {
        padding: 0 15px !important;
    }

    /* Modules grid */
    #modules .container {
        padding: 0 15px !important;
    }

    .modules-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Contact info */
    .contact-section {
        padding: 30px 15px !important;
    }

    /* Footer */
    footer {
        padding: 20px 15px !important;
        text-align: center !important;
    }

    footer .container {
        flex-direction: column !important;
        gap: 15px !important;
    }
}

@media (max-width: 576px) {
    .hero-content h1 {
        font-size: 1.5rem !important;
    }

    .hero-content p {
        font-size: 0.9rem !important;
    }

    section h2 {
        font-size: 1.3rem !important;
    }

    .module-card {
        padding: 15px !important;
    }
}
