/* css/mobile.css - Otimizações Responsivas Premium e Correção do Modal */

@media (max-width: 768px) {
    body { overflow-x: hidden; padding-bottom: 80px; }
    main { margin: 15px auto; padding: 0 10px; }

    /* NAVEGAÇÃO ESTILO APLICATIVO */
    .navbar {
        position: fixed; bottom: 0; top: auto; width: 100%;
        padding: 10px 5px; padding-bottom: env(safe-area-inset-bottom, 10px);
        background-color: var(--bg-card); border-top: 1px solid var(--border-light);
        z-index: 9999; box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    }
    body.dark-theme .navbar { background-color: #111827; border-top: 1px solid #1F2937; box-shadow: 0 -4px 15px rgba(0,0,0,0.4); }
    .nav-container { justify-content: space-around; gap: 0; padding: 0; }
    .nav-btn { font-size: 0.75rem; padding: 10px 2px; flex: 1; text-align: center; border-radius: 12px !important; border: none !important; background: transparent !important; color: var(--text-muted) !important; margin: 0 4px; transition: all 0.2s ease; }
    .nav-btn.active { background: rgba(0, 102, 79, 0.1) !important; color: var(--imposto-green) !important; font-weight: 700 !important; box-shadow: none !important; }
    body.dark-theme .nav-btn.active { background: rgba(0, 229, 255, 0.1) !important; color: #00E5FF !important; border: 1px solid rgba(0, 229, 255, 0.2) !important; box-shadow: inset 0 0 10px rgba(0, 229, 255, 0.05) !important; }
    .theme-toggle-btn { position: fixed; top: 15px; right: 15px; background: var(--bg-card); box-shadow: 0 4px 10px rgba(0,0,0,0.3); z-index: 100; padding: 8px; }

    .card-impostometro { height: 160px; }
    .dash-rankings-grid { grid-template-columns: 1fr; }
    .divider { display: none; }
    .filtros-bar { flex-direction: column; width: 100%; }
    .filtros-bar input, .filtros-bar select { max-width: 100%; }

    /* FIX DEFINITIVO DO MODAL */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-container { 
        width: 100vw; max-width: 100vw; max-height: 85vh; border-radius: 20px 20px 0 0; 
        margin-top: auto; animation: slideUp 0.3s ease; padding-bottom: 20px; box-sizing: border-box; 
    }
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .profile-header { flex-direction: column; text-align: center; padding: 20px; width: 100%; box-sizing: border-box; }
    .profile-header > div { text-align: center !important; margin: 0 auto !important; }
    .profile-img-lg { width: 80px; height: 80px; }
    .modal-grid-body { display: flex; flex-direction: column; width: 100%; padding: 15px; gap: 15px; box-sizing: border-box; }
    .modal-section-card { width: 100%; max-width: 100%; padding: 12px; margin-bottom: 10px; box-sizing: border-box; overflow: hidden; }

    /* MÁGICA DA TABELA RESPONSIVA */
    .tabela-container { width: 100%; max-width: 100%; box-sizing: border-box; }
    .table-responsive-wrapper { width: 100%; max-width: 100%; display: block; overflow-x: auto !important; -webkit-overflow-scrolling: touch; padding-bottom: 10px; max-height: 350px; overflow-y: auto;}
    .table-despesas { min-width: 500px; width: 100%; }
    .table-despesas th, .table-despesas td { font-size: 0.85rem; padding: 10px; white-space: nowrap; }

    /* MODAL INTRO MOBILE */
    .intro-modal-container { width: 90%; margin: auto; border-radius: 20px; }
    .intro-modal-content { padding: 30px 20px; }
    .intro-modal-content h2 { font-size: 1.4rem; }
    .intro-modal-content p { font-size: 0.95rem; }
    .btn-instagram, .btn-entrar { padding: 16px; font-size: 1rem; }

    /* NOVO LAYOUT DO RANKING MOBILE (FOTO EM CIMA, VALOR EMBAIXO) */
    .ranking-item-bar {
        display: flex;
        flex-wrap: wrap;
        padding: 15px 10px;
    }
    .rank-position { 
        width: 35px; min-width: 35px; text-align: left; 
    }
    .rank-avatar { 
        margin-right: 10px; 
    }
    .rank-info { 
        flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; 
    }
    .rank-stats {
        width: 100%;
        margin-top: 12px;
        text-align: left;
        padding-top: 8px;
        border-top: 1px dashed var(--border-light); 
    }

    /* SISTEMA DE ABAS DO RANKING NACIONAL */
   /* =========================================
       BOTÕES MOBILE PREMIUM (MAIORES/MENORES)
       ========================================= */
    .hidden-desktop { display: flex !important; }
    
    .mobile-ranking-tabs {
        display: flex;
        background: rgba(0,0,0,0.05); /* Fundo sutil */
        padding: 5px;
        border-radius: 30px; /* Formato Pílula */
        margin: 10px 15px 25px 15px;
        border: none;
    }
    body.dark-theme .mobile-ranking-tabs { background: rgba(255,255,255,0.08); }
    
    .tab-btn {
        flex: 1;
        padding: 10px 5px;
        border-radius: 25px; /* Formato Pílula no Botão */
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-weight: 700;
        font-size: 0.85rem;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .tab-btn.active {
        background: var(--bg-card); /* Fundo iluminado */
        color: var(--imposto-green);
        box-shadow: 0 2px 8px rgba(0,0,0,0.15); /* Sombra elegante */
    }
    body.dark-theme .tab-btn.active { background: var(--imposto-dark); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

    /* Lógica das colunas no Mobile */
    .ranking-split-view { padding: 0; flex-direction: column; }
    .ranking-col { padding: 10px 0; }
    #ranking-split-container .col-menores { display: none; }
    #ranking-split-container.show-menores .col-maiores { display: none; }
    #ranking-split-container.show-menores .col-menores { display: block; }}

    @media (max-width: 768px) {
    #btn-float-form {
        bottom: 90px !important; /* Ajuste esse valor dependendo da altura da sua navbar */
    }
}