/*
 * MOBILE OPTIMIZED CSS
 * Sistema de Relatórios - Grupo Qualy
 * Otimizações para dispositivos móveis
 */

/* ============================================
   VARIÁVEIS MOBILE
   ============================================ */
:root {
    --touch-target-size: 44px; /* Tamanho mínimo recomendado Apple/Google */
    --mobile-padding: 1rem;
    --mobile-gap: 0.75rem;
}

/* ============================================
   BREAKPOINT: MOBILE PEQUENO (até 480px)
   ============================================ */
@media (max-width: 480px) {
    /* Container e padding */
    .container {
        padding: 0.75rem !important;
    }
    
    /* Header compacto */
    .header {
        padding: 0.75rem !important;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    /* Logo menor */
    .header-logo-img {
        width: 35px !important;
        height: 35px !important;
    }
    
    .header-brand-name {
        font-size: 1rem !important;
    }
    
    .header-brand-tagline {
        font-size: 0.6rem !important;
    }
    
    /* Botões com touch target */
    .btn, button {
        min-height: var(--touch-target-size);
        min-width: var(--touch-target-size);
        padding: 0.75rem 1rem !important;
        font-size: 1rem;
    }
    
    /* Inputs com touch target */
    input, select, textarea {
        min-height: var(--touch-target-size);
        font-size: 16px !important; /* Evita zoom no iOS */
        padding: 0.75rem !important;
    }
    
    /* Cards e estatísticas */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-value {
        font-size: 1.75rem !important;
    }
    
    .stat-label {
        font-size: 0.85rem !important;
    }
    
    /* Tabelas responsivas - modo CARD */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Transformar tabelas em cards em telas muito pequenas */
    .table-mobile-card thead {
        display: none;
    }
    
    .table-mobile-card tbody,
    .table-mobile-card tr {
        display: block;
        margin-bottom: 1rem;
    }
    
    .table-mobile-card td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem !important;
        border: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .table-mobile-card td:before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 1rem;
        color: var(--primary-green);
    }
    
    /* Modal fullscreen em mobile */
    .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0 !important;
        margin: 0 !important;
        overflow-y: auto;
    }
    
    .modal {
        padding: 0 !important;
    }
    
    /* Formulários mobile */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control {
        font-size: 16px !important; /* Evita zoom no iOS */
    }
    
    /* Grids responsivos */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Menu de navegação */
    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
        padding: 1rem !important;
    }
    
    /* Section headers */
    .section-header {
        font-size: 1rem !important;
        padding: 0.75rem !important;
    }
    
    /* Cards de produtos/itens */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Footer */
    .footer {
        padding: 1rem 0.75rem !important;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
}

/* ============================================
   BREAKPOINT: MOBILE GRANDE / TABLET (481px - 768px)
   ============================================ */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Tabelas com scroll horizontal */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Botões menores que mobile pequeno mas maiores que desktop */
    .btn, button {
        min-height: 42px;
        padding: 0.625rem 1rem;
    }
    
    /* Modal menos extremo */
    .modal-content {
        width: 95vw !important;
        max-width: 600px !important;
        height: auto;
        max-height: 90vh;
    }
    
    /* Grids 2 colunas */
    [style*="grid-template-columns"]:not(.stats-grid) {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================
   BREAKPOINT: TABLET GRANDE (769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .modal-content {
        max-width: 700px !important;
    }
}

/* ============================================
   ORIENTAÇÃO: LANDSCAPE MOBILE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    /* Header mais compacto */
    .header {
        padding: 0.5rem !important;
    }
    
    .header-brand-name {
        font-size: 1rem !important;
    }
    
    /* Modal scroll */
    .modal-content {
        height: 100vh;
        overflow-y: auto;
    }
    
    /* Reduzir padding vertical */
    .container {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
}

/* ============================================
   MELHORIAS GERAIS MOBILE
   ============================================ */

/* Remover hover em touch devices */
@media (hover: none) {
    .btn:hover,
    button:hover,
    .nav-link:hover {
        transform: none !important;
    }
    
    /* Adicionar efeito :active em vez de :hover */
    .btn:active,
    button:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Melhorar legibilidade em telas pequenas */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    
    /* Melhorar contraste em mobile */
    .card, .stat-card {
        background: rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Scroll suave */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Remover seleção de texto acidental em botões */
    .btn, button {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
}

/* ============================================
   PERFORMANCE MOBILE
   ============================================ */
@media (max-width: 768px) {
    /* Reduzir animações para economizar bateria */
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Otimizar renderização */
    .card, .stat-card, .modal-content {
        will-change: auto !important;
    }
}

/* ============================================
   ACESSIBILIDADE MOBILE
   ============================================ */

/* Área de toque maior para links pequenos */
@media (max-width: 768px) {
    a {
        padding: 0.25rem;
        margin: -0.25rem;
    }
    
    /* Foco visível */
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--primary-green);
        outline-offset: 2px;
    }
}
