/* ============================================
   MOBILE RESPONSIVIDADE - CORREÇÕES GLOBAIS
   Sistema Disciplinar Pantanal v3.2.1

   Este arquivo contém TODAS as correções de responsividade
   mobile para o sistema, sem alterar arquivos CSS existentes.

   Criado: 2025-11-11
   Breakpoints: 1024px (tablet), 768px (mobile landscape), 480px (mobile portrait), 320px (mobile small)
   ============================================ */

/* ============================================
   1. TABELAS - OVERFLOW HORIZONTAL E RESPONSIVIDADE
   ============================================ */

/* Garante scroll horizontal em todas as tabelas */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling no iOS */
    margin-bottom: 20px;
}

/* Tabelas com largura mínima para forçar scroll em mobile */
.data-table {
    min-width: 600px; /* Força scroll horizontal em telas < 600px */
}

/* Responsividade de tabelas em tablets */
@media (max-width: 768px) {
    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px; /* Reduz padding */
        white-space: nowrap; /* Evita quebra de texto */
    }

    .data-table th {
        font-size: 11px;
    }
}

/* Esconde colunas secundárias em mobile */
@media (max-width: 480px) {
    .data-table {
        font-size: 11px;
        min-width: 500px; /* Ajusta largura mínima */
    }

    .data-table th,
    .data-table td {
        padding: 6px 4px;
    }

    /* Esconde colunas menos importantes (ajustar por página se necessário) */
    .data-table th:nth-child(5),
    .data-table td:nth-child(5),
    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        display: none; /* Esconde 5ª e 6ª coluna */
    }
}

/* ============================================
   2. SIDEBAR - HAMBURGER MENU EM MOBILE
   ============================================ */

/* Corrige comportamento da sidebar em tablets e mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        left: 0;
        top: 48px; /* Abaixo da top bar */
        transform: translateX(-100%); /* Esconde por padrão */
        width: 250px !important;
        height: calc(100vh - 48px);
        z-index: 999;
        transition: transform 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        border-right: 1px solid #e1dfdd;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Quando aberta via JavaScript (adicionar classe 'mobile-open') */
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Overlay para fechar sidebar ao clicar fora */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Força layout correto do conteúdo */
    .main-layout {
        flex-direction: row !important; /* Mantém row, não column */
    }

    .content-area {
        margin-left: 0 !important;
        width: 100% !important;
        flex: 1;
    }

    /* Botão hamburger (precisa adicionar no HTML) */
    .hamburger-menu {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        cursor: pointer;
        background: none;
        border: none;
        padding: 0;
    }

    .hamburger-menu span {
        display: block;
        width: 24px;
        height: 2px;
        background: #323130;
        position: relative;
        transition: background 0.3s ease;
    }

    .hamburger-menu span::before,
    .hamburger-menu span::after {
        content: '';
        display: block;
        width: 24px;
        height: 2px;
        background: #323130;
        position: absolute;
        left: 0;
        transition: all 0.3s ease;
    }

    .hamburger-menu span::before {
        top: -8px;
    }

    .hamburger-menu span::after {
        top: 8px;
    }

    /* Animação do hamburger quando ativo (transforma em X) */
    .hamburger-menu.active span {
        background: transparent;
    }

    .hamburger-menu.active span::before {
        top: 0;
        transform: rotate(45deg);
    }

    .hamburger-menu.active span::after {
        top: 0;
        transform: rotate(-45deg);
    }
}

@media (min-width: 769px) {
    .hamburger-menu {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* ============================================
   3. TOP BAR - RESPONSIVIDADE
   ============================================ */

@media (max-width: 768px) {
    .top-bar {
        padding: 0 12px;
        height: 48px;
    }

    .top-bar-left {
        gap: 8px;
    }

    .app-name {
        font-size: 14px;
    }

    .top-bar-center {
        flex: 1;
        margin: 0 8px;
        max-width: none;
        min-width: 0;
    }

    .search-box {
        font-size: 13px;
        padding: 6px 12px;
    }

    .top-bar-right {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 0 8px;
    }

    /* Esconde barra de busca em mobile pequeno */
    .top-bar-center {
        display: none;
    }

    .app-name {
        font-size: 13px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .btn-logout {
        min-width: auto;
        padding: 8px 12px;
        font-size: 11px;
    }

    .btn-logout:before {
        font-size: 10px;
    }
}

/* ============================================
   4. BOTÕES - ALTURA MÍNIMA 44px (ACESSIBILIDADE)
   ============================================ */

/* Garante que todos os botões tenham altura mínima para toque */
.btn,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-warning,
.btn-info,
.btn-danger,
.btn-login,
.btn-logout {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Botões pequenos também devem ter altura mínima */
.btn-small {
    min-height: 40px;
    padding: 8px 12px;
}

@media (max-width: 480px) {
    /* Botões em largura total em mobile */
    .form-actions .btn,
    .filters-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   5. GRIDS - RESPONSIVIDADE UNIVERSAL
   ============================================ */

/* Quick stats, hub cards, stat cards */
@media (max-width: 1024px) {
    .quick-stats,
    .hub-cards,
    .stats-grid,
    .data-actions-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 colunas em tablet */
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .quick-stats,
    .hub-cards,
    .stats-grid,
    .data-actions-grid {
        grid-template-columns: 1fr !important; /* Uma coluna única em mobile */
        gap: 12px;
    }

    .stat-card,
    .hub-card {
        padding: 16px !important;
    }

    .stat-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 28px !important;
    }

    .stat-number {
        font-size: 24px !important;
    }

    .stat-label {
        font-size: 11px !important;
    }
}

/* ============================================
   6. FORMULÁRIOS - RESPONSIVIDADE
   ============================================ */

@media (max-width: 768px) {
    .form-grid,
    .config-grid,
    .filters-grid {
        grid-template-columns: 1fr !important; /* Uma coluna */
        gap: 16px;
    }

    .form-group-full {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .management-section,
    .filters-section,
    .config-section {
        padding: 16px;
    }

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ============================================
   7. BOLETIM - GRID 5 COLUNAS RESPONSIVO
   ============================================ */

/* Corrige grid de matérias do boletim */
@media (max-width: 768px) {
    .materia-row,
    .materias-header {
        grid-template-columns: 1fr 1fr 1fr !important; /* 3 colunas */
        gap: 8px !important;
        font-size: 12px;
    }

    .nota-input {
        width: 100%;
        font-size: 12px;
        padding: 6px;
    }
}

@media (max-width: 480px) {
    .materia-row,
    .materias-header {
        grid-template-columns: 1fr !important; /* 1 coluna */
        gap: 6px !important;
        font-size: 11px;
    }

    .nota-input {
        width: 100%;
        max-width: none;
        font-size: 13px;
        padding: 8px;
    }

    .materia-nome {
        font-weight: 600;
        margin-bottom: 4px;
    }
}

/* ============================================
   8. FILTROS DE HISTÓRICO - GRID 5 COLUNAS
   ============================================ */

/* Corrige filtros com 5 colunas fixas */
@media (max-width: 1024px) {
    .filters-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 colunas em tablet */
    }
}

@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 colunas em mobile landscape */
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .filters-grid {
        grid-template-columns: 1fr !important; /* 1 coluna em mobile portrait */
        gap: 10px;
    }
}

/* ============================================
   9. FONT-SIZE - REDUÇÃO EM MOBILE
   ============================================ */

@media (max-width: 768px) {
    .module-title {
        font-size: 20px !important;
    }

    .card-title {
        font-size: 16px !important;
    }

    .management-title,
    .config-title,
    .filters-title {
        font-size: 16px !important;
    }

    .sidebar-text {
        font-size: 12px;
    }

    .table-title {
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .module-title {
        font-size: 18px !important;
        gap: 8px;
    }

    .card-title {
        font-size: 14px !important;
    }

    .management-title,
    .config-title,
    .filters-title {
        font-size: 14px !important;
    }

    body {
        font-size: 14px;
    }

    .form-label,
    .filter-label,
    .config-label {
        font-size: 13px;
    }
}

/* ============================================
   10. MAIN CONTENT - PADDING REDUZIDO
   ============================================ */

@media (max-width: 768px) {
    .main-content {
        padding: 20px 16px !important;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 16px 12px !important;
    }
}

/* ============================================
   11. PORTAL DOS PAIS - OTIMIZAÇÕES
   ============================================ */

@media (max-width: 768px) {
    .header {
        padding: 20px !important;
        margin-bottom: 20px;
    }

    .header h1 {
        font-size: 1.8em !important;
    }

    .logo-img {
        width: 60px !important;
        height: 60px !important;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px !important;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 1.3em !important;
    }

    .logo-img {
        width: 50px !important;
        height: 50px !important;
    }

    .search-section {
        padding: 20px !important;
    }
}

/* ============================================
   12. CONSULTA FICHA - LAYOUT COMPLEXO
   ============================================ */

@media (max-width: 768px) {
    .search-form-row {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
}

/* ============================================
   13. CARDS E SEÇÕES
   ============================================ */

@media (max-width: 768px) {
    .student-card,
    .data-card,
    .ficha-section {
        padding: 16px !important;
        margin-bottom: 16px;
    }

    .card-header {
        padding: 16px !important;
    }

    .card-content {
        padding: 16px !important;
    }
}

@media (max-width: 480px) {
    .student-card,
    .data-card,
    .ficha-section {
        padding: 12px !important;
        margin-bottom: 12px;
    }

    .card-header {
        padding: 12px !important;
    }

    .card-content {
        padding: 12px !important;
    }
}

/* ============================================
   14. MENSAGENS E NOTIFICAÇÕES
   ============================================ */

@media (max-width: 768px) {
    .message {
        right: 12px;
        left: 12px;
        max-width: none;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .message {
        right: 8px;
        left: 8px;
        top: 56px; /* Abaixo da top bar */
        font-size: 12px;
        padding: 12px 16px;
    }
}

/* ============================================
   15. DETALHES E ESTATÍSTICAS
   ============================================ */

@media (max-width: 768px) {
    .dados-pessoais,
    .resumo-stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .dados-pessoais,
    .resumo-stats {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    .resumo-card {
        padding: 12px !important;
    }

    .resumo-numero {
        font-size: 20px !important;
    }

    .resumo-label {
        font-size: 11px !important;
    }
}

/* ============================================
   16. HISTÓRICO E TIMELINE
   ============================================ */

@media (max-width: 480px) {
    .historico-container {
        max-height: 300px; /* Reduz altura em mobile */
    }

    .historico-item {
        padding: 10px 12px;
        margin-bottom: 6px;
        font-size: 12px;
    }

    .historico-header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .historico-data {
        font-size: 11px;
    }

    .historico-descricao {
        font-size: 12px;
    }
}

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

@media (max-width: 480px) {
    .breadcrumb {
        font-size: 12px;
        padding: 8px 0;
    }

    .breadcrumb-item {
        margin-right: 8px;
    }
}

/* ============================================
   18. EMPTY STATES E LOADING
   ============================================ */

@media (max-width: 480px) {
    .empty-state {
        padding: 40px 16px;
    }

    .empty-icon {
        font-size: 36px !important;
    }

    .empty-state h3 {
        font-size: 16px !important;
    }

    .empty-state p {
        font-size: 13px !important;
    }

    .loading-state {
        padding: 30px 16px;
    }
}

/* ============================================
   19. TABS E NAVEGAÇÃO
   ============================================ */

@media (max-width: 768px) {
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tabs {
        min-width: max-content;
    }
}

@media (max-width: 480px) {
    .tab {
        font-size: 12px;
        padding: 8px 12px;
        min-width: 80px;
    }
}

/* ============================================
   20. MODAIS E OVERLAYS
   ============================================ */

@media (max-width: 768px) {
    .modal-content {
        max-width: 90% !important;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    .modal-content {
        max-width: 95% !important;
        margin: 5% auto;
        padding: 16px !important;
    }

    .modal-header {
        padding: 12px !important;
    }

    .modal-body {
        padding: 12px !important;
    }

    .modal-footer {
        padding: 12px !important;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ============================================
   21. SMOOTH SCROLLING E TOUCH
   ============================================ */

/* Melhora scrolling em iOS */
.sidebar,
.content-area,
.table-container,
.historico-container,
.tabs-container {
    -webkit-overflow-scrolling: touch;
}

/* Remove bounce effect em iOS (opcional) */
html, body {
    overscroll-behavior-y: none;
}

/* ============================================
   22. HOVER EFFECTS - DESABILITA EM TOUCH
   ============================================ */

/* Remove hover effects em dispositivos touch */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .sidebar-item:hover,
    .data-table tr:hover,
    .student-card:hover,
    .data-card:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
}

/* ============================================
   23. PRINT - MANTÉM LAYOUT DESKTOP
   ============================================ */

@media print {
    .sidebar,
    .top-bar,
    .hamburger-menu,
    .sidebar-overlay,
    .btn-logout {
        display: none !important;
    }

    .content-area {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .main-content {
        padding: 0 !important;
    }
}

/* ============================================
   24. AJUSTES ESPECÍFICOS POR PÁGINA
   ============================================ */

/* Login Page */
@media (max-width: 480px) {
    .login-container {
        max-width: 100% !important;
        padding: 20px !important;
        margin: 20px !important;
    }
}

/* Gestão de Alunos */
@media (max-width: 480px) {
    #alunosTable th:nth-child(5),
    #alunosTable td:nth-child(5),
    #alunosTable th:nth-child(6),
    #alunosTable td:nth-child(6),
    #alunosTable th:nth-child(7),
    #alunosTable td:nth-child(7) {
        display: none; /* Esconde Responsável, Telefone 1, Telefone 2 */
    }
}

/* Frequência - Lançamento */
@media (max-width: 768px) {
    .frequencia-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Comunicação - Tabs */
@media (max-width: 480px) {
    .comunicacao-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .comunicacao-tabs .tab {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   25. UTILITIES - MOBILE HELPERS
   ============================================ */

/* Classes auxiliares para esconder/mostrar em mobile */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

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

    .show-mobile {
        display: block !important;
    }
}

/* Padding e margin utilities para mobile */
@media (max-width: 480px) {
    .p-mobile-0 { padding: 0 !important; }
    .p-mobile-1 { padding: 8px !important; }
    .p-mobile-2 { padding: 16px !important; }

    .m-mobile-0 { margin: 0 !important; }
    .m-mobile-1 { margin: 8px !important; }
    .m-mobile-2 { margin: 16px !important; }
}

/* ============================================
   FIM DAS CORREÇÕES MOBILE
   ============================================ */
