/* Mobile Optimizations for WMS FlexClima */

/* ===== GERAL ===== */
/* Melhora do toque em dispositivos móveis */
@media (max-width: 640px) {
    /* Aumenta área de toque em elementos interativos */
    button, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Evita zoom em inputs no iOS */
    input[type="text"], 
    input[type="email"], 
    input[type="password"], 
    input[type="number"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Melhora espaçamento */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Textos responsivos */
    h1 { font-size: 1.5rem; line-height: 1.2; }
    h2 { font-size: 1.25rem; line-height: 1.2; }
    h3 { font-size: 1.125rem; line-height: 1.2; }
    
    /* Cards responsivos */
    .card {
        border-radius: 0.75rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
}

/* ===== OTIMIZAÇÕES DE TOQUE ===== */
/* Remove delay de 300ms do toque */
.touch-manipulation {
    touch-action: manipulation;
}

/* Feedback visual para toque */
@media (hover: none) and (pointer: coarse) {
    button:active,
    a:active,
    .touch-target:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* ===== NAVIGAÇÃO MOBILE ===== */
@media (max-width: 768px) {
    /* Menu mobile */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 9999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .mobile-menu.active {
        transform: translateX(0);
    }
    
    /* Bottom navigation */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        z-index: 1000;
        padding: 0.5rem 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
        min-height: 60px;
        color: #6b7280;
        text-decoration: none;
        transition: color 0.2s;
    }
    
    .bottom-nav-item.active {
        color: #3b82f6;
    }
    
    .bottom-nav-item:active {
        transform: scale(0.95);
    }
    
    .bottom-nav-icon {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .bottom-nav-label {
        font-size: 0.75rem;
        font-weight: 500;
    }
}

/* ===== FORMULÁRIOS ===== */
@media (max-width: 640px) {
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label {
        font-size: 0.875rem;
        font-weight: 500;
        margin-bottom: 0.5rem;
        display: block;
    }
    
    .form-input {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 0.5rem;
        font-size: 16px;
        transition: border-color 0.2s, box-shadow 0.2s;
    }
    
    .form-input:focus {
        outline: none;
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    .form-button {
        width: 100%;
        padding: 0.875rem;
        background: #3b82f6;
        color: white;
        border: none;
        border-radius: 0.5rem;
        font-size: 1rem;
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.2s;
        min-height: 48px;
    }
    
    .form-button:active {
        background: #2563eb;
    }
}

/* ===== TABELAS ===== */
@media (max-width: 640px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }
}

/* ===== CARDS E GRID ===== */
@media (max-width: 640px) {
    .grid-responsive {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .card-mobile {
        padding: 1rem;
        border-radius: 0.75rem;
    }
    
    .card-mobile .card-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .card-mobile .card-content {
        font-size: 0.875rem;
        line-height: 1.4;
    }
}

/* ===== MODAIS ===== */
@media (max-width: 640px) {
    .modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: flex-end;
        z-index: 9999;
    }
    
    .modal-content {
        background: white;
        border-radius: 1rem 1rem 0 0;
        max-height: 90vh;
        overflow-y: auto;
        width: 100%;
        max-width: 100%;
        padding: 1.5rem;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
        font-weight: 600;
    }
    
    .modal-close {
        width: 40px;
        height: 40px;
        border: none;
        background: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background-color 0.2s;
    }
    
    .modal-close:active {
        background: #f3f4f6;
    }
}

/* ===== NOTIFICAÇÕES ===== */
@media (max-width: 640px) {
    .notification {
        position: fixed;
        top: 1rem;
        left: 1rem;
        right: 1rem;
        z-index: 9999;
        border-radius: 0.5rem;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .notification-success {
        background: #10b981;
        color: white;
    }
    
    .notification-error {
        background: #ef4444;
        color: white;
    }
    
    .notification-warning {
        background: #f59e0b;
        color: white;
    }
    
    .notification-info {
        background: #3b82f6;
        color: white;
    }
}

/* ===== SCROLL ===== */
/* Melhora o scroll em iOS */
@media (max-width: 640px) {
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    body {
        overscroll-behavior-y: contain;
    }
}

/* ===== SAFE AREA ===== */
/* Respeita áreas seguras de dispositivos com notch */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .safe-area-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-area-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .safe-area-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ===== DARK MODE MOBILE ===== */
@media (max-width: 640px) {
    .dark .form-input {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .dark .form-input:focus {
        border-color: #60a5fa;
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
    }
    
    .dark .modal-content {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .dark .notification {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
}

/* ===== PERFORMANCE ===== */
/* Otimizações para dispositivos mais lentos */
@media (max-width: 640px) {
    /* Reduz animações em dispositivos mais lentos */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
    
    /* Otimiza imagens */
    img {
        max-width: 100%;
        height: auto;
        loading: lazy;
    }
    
    /* Otimiza fontes */
    body {
        font-display: swap;
    }
}

/* ===== PRINT ===== */
/* Otimizações para impressão */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    a {
        color: black;
        text-decoration: none;
    }
    
    .page-break {
        page-break-before: always;
    }
    
    .avoid-break {
        page-break-inside: avoid;
    }
}
