/* ============================================================
   LAWTECH PRO — RESPONSIVIDADE MOBILE GLOBAL
   Aplicado a todas as páginas do sistema via link compartilhado
   ============================================================ */

/* ====== OVERLAY DA SIDEBAR (páginas internas) ====== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1050;
    animation: mob-fadeIn 0.2s ease;
}
.sidebar-overlay.active { display: block; }

@keyframes mob-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ====== BOTÃO HAMBURGER — PÁGINAS INTERNAS (sidebar) ====== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1200;
    width: 44px;
    height: 44px;
    background: #1E3A5F;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: background 0.2s;
}
.mobile-menu-btn:hover,
.mobile-menu-btn:focus { background: #2A4A73; outline: none; }

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.2s ease;
}
.mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ====== BOTÃO HAMBURGER — PÁGINAS PÚBLICAS (nav) ====== */
.nav-toggle-pub {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    z-index: 1010;
}
.nav-toggle-pub span {
    display: block;
    width: 24px;
    height: 2px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.2s ease;
}
.nav-toggle-pub.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle-pub.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle-pub.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Menu mobile — páginas públicas */
.nav-mobile-pub {
    display: none;
    flex-direction: column;
    background: rgba(10, 18, 35, 0.99);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 0 14px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 999;
    animation: mob-slideDown 0.2s ease;
}
@keyframes mob-slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
nav.pub-menu-open .nav-mobile-pub { display: flex; }

.nav-mobile-pub a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    padding: 13px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s, color 0.2s;
}
.nav-mobile-pub a:last-child { border-bottom: none; }
.nav-mobile-pub a:hover { background: rgba(255,255,255,0.06); color: #fff; }

.nav-mobile-pub .nmob-btn {
    margin: 10px 20px 2px;
    text-align: center;
    border-radius: 10px;
    border-bottom: none !important;
    padding: 12px 20px !important;
    font-weight: 600;
    font-size: 14px;
}
.nav-mobile-pub .nmob-login {
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    background: transparent;
    margin-bottom: 6px;
}
.nav-mobile-pub .nmob-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
}

/* ================================================================
   BREAKPOINT 768px
   ================================================================ */
@media (max-width: 768px) {

    /* --- SIDEBAR: slide fora da tela --- */
    .sidebar {
        display: flex !important;        /* override: pages que têm display:none no próprio @media */
        animation: none !important;      /* override: remove animações de entrada que conflitam com transform */
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1100 !important;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* --- CONTEÚDO PRINCIPAL: largura total --- */
    .main {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    /* --- BOTÃO HAMBURGER: visível --- */
    .mobile-menu-btn {
        display: flex;
    }

    /* --- HEADER: espaço para o botão hamburger --- */
    .header {
        padding-left: 68px !important;
        min-height: 62px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .header h1,
    .header h2 {
        font-size: 15px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100vw - 180px);
    }

    /* --- NAV PÚBLICO: esconde links desktop, mostra toggle --- */
    .nav-toggle-pub { display: flex; }
    nav:not(#mainNav) .nav-links,
    nav:not(#mainNav) .nav-buttons { display: none !important; }

    /* --- TABELAS: scroll horizontal --- */
    .table-responsive,
    .table-container,
    .table-wrapper,
    .table-wrap,
    .tabela-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    table { min-width: 560px; }
    td, th { white-space: nowrap; }

    /* --- GRIDS DE CARDS/STATS: 2 colunas --- */
    .stats-grid,
    .cards-grid,
    .grid-cards,
    .resumo-grid,
    .kpi-grid,
    .summary-grid,
    .stats-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    /* --- MODAIS: tela quase cheia --- */
    .modal-content,
    .modal-box,
    .modal-container,
    .modal {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        padding: 24px 16px !important;
        margin: auto !important;
    }

    /* --- LINHAS DE FORMULÁRIO: empilhadas --- */
    .form-row,
    .input-row,
    .field-row {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .form-row > *,
    .input-row > * { width: 100% !important; }

    /* --- BARRA DE AÇÕES / FILTROS --- */
    .page-header,
    .content-header,
    .actions-bar,
    .toolbar {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: flex-start !important;
    }
    .filters,
    .filter-row,
    .search-filters {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }
    .filters input,
    .filters select,
    .filter-row input,
    .filter-row select,
    .search-filters input,
    .search-filters select {
        width: 100% !important;
    }

    /* --- ABAS (tabs) --- */
    .tabs,
    .tab-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }

    /* --- AUTH PAGES: card de login/recuperação --- */
    .card {
        padding: 28px 20px !important;
        margin: 0 16px !important;
        width: calc(100% - 32px) !important;
        max-width: 100% !important;
    }
}

/* ================================================================
   BREAKPOINT 480px (celulares pequenos)
   ================================================================ */
@media (max-width: 480px) {

    /* Stats/cards → coluna única */
    .stats-grid,
    .cards-grid,
    .grid-cards,
    .resumo-grid,
    .kpi-grid,
    .summary-grid,
    .stats-row {
        grid-template-columns: 1fr !important;
    }

    /* Conteúdo interno */
    .content {
        padding: 14px !important;
    }

    /* Header ainda mais compacto */
    .header {
        padding: 10px 10px 10px 62px !important;
    }
    .header h1,
    .header h2 {
        font-size: 13px !important;
    }

    /* Tabelas menores */
    table { min-width: 480px; font-size: 13px; }
    td, th { padding: 8px 10px !important; }

    /* Modais: bottom sheet em telas muito pequenas */
    .modal-content,
    .modal-box,
    .modal-container,
    .modal {
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 16px 16px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        top: auto !important;
        margin: 0 !important;
        max-height: 85vh !important;
    }

    /* Botões de ação: tamanho toque */
    .btn,
    button {
        min-height: 40px;
    }
}
