/**
 * RESPONSIVIDADE COMPLETA - KIZUA
 * Suporta todos os tamanhos de dispositivos móveis
 */

/* ============================================
   VARIÁVEIS GLOBAIS RESPONSIVAS
   ============================================ */
:root {
    --mobile-padding: clamp(12px, 3vw, 20px);
    --mobile-font: clamp(0.875rem, 2.5vw, 1rem);
    --mobile-h1: clamp(1.5rem, 5vw, 2rem);
    --mobile-h2: clamp(1.25rem, 4vw, 1.5rem);
    --mobile-h3: clamp(1.1rem, 3.5vw, 1.25rem);
}

/* ============================================
   RESET BÁSICO PARA MOBILE
   ============================================ */
@media (max-width: 767px) {
    html {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    body {
        font-size: var(--mobile-font);
        overflow-x: hidden;
        width: 100%;
        min-width: 320px; /* Largura mínima suportada */
    }
    
    * {
        box-sizing: border-box;
    }
}

/* ============================================
   CONTAINERS E LAYOUT
   ============================================ */
@media (max-width: 767px) {
    .container,
    .container-fluid {
        padding-left: var(--mobile-padding) !important;
        padding-right: var(--mobile-padding) !important;
        max-width: 100% !important;
    }
    
    .row {
        margin-left: calc(var(--mobile-padding) * -0.5) !important;
        margin-right: calc(var(--mobile-padding) * -0.5) !important;
    }
    
    [class*="col-"] {
        padding-left: calc(var(--mobile-padding) * 0.5) !important;
        padding-right: calc(var(--mobile-padding) * 0.5) !important;
    }
}

/* ============================================
   TIPOGRAFIA RESPONSIVA
   ============================================ */
@media (max-width: 767px) {
    h1, .h1 { font-size: var(--mobile-h1) !important; line-height: 1.3; }
    h2, .h2 { font-size: var(--mobile-h2) !important; line-height: 1.3; }
    h3, .h3 { font-size: var(--mobile-h3) !important; line-height: 1.3; }
    h4, .h4 { font-size: clamp(1rem, 3vw, 1.15rem) !important; }
    h5, .h5 { font-size: clamp(0.95rem, 2.8vw, 1.1rem) !important; }
    h6, .h6 { font-size: clamp(0.9rem, 2.5vw, 1rem) !important; }
    
    p, li, td, th {
        font-size: var(--mobile-font) !important;
        line-height: 1.5;
    }
    
    small, .small {
        font-size: clamp(0.75rem, 2vw, 0.875rem) !important;
    }
}

/* ============================================
   SIDEBAR MOBILE
   ============================================ */
@media (max-width: 991px) {
    .sidebar {
        position: fixed !important;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar.show {
        left: 0;
        box-shadow: 0 0 20px rgba(0,0,0,0.3);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: clamp(10px, 2vw, 15px) !important;
    }
}

/* ============================================
   CARDS RESPONSIVOS
   ============================================ */
@media (max-width: 767px) {
    .card {
        margin-bottom: clamp(12px, 3vw, 20px) !important;
        border-radius: clamp(6px, 1.5vw, 10px) !important;
    }
    
    .card-body {
        padding: clamp(12px, 3vw, 20px) !important;
    }
    
    .card-header {
        padding: clamp(10px, 2.5vw, 15px) !important;
        font-size: var(--mobile-font) !important;
    }
    
    .card-footer {
        padding: clamp(10px, 2.5vw, 15px) !important;
    }
}

/* ============================================
   TABELAS RESPONSIVAS
   ============================================ */
@media (max-width: 767px) {
    .table-responsive {
        border: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: clamp(0.75rem, 2vw, 0.875rem) !important;
        min-width: 600px; /* Força scroll horizontal */
    }
    
    .table th,
    .table td {
        padding: clamp(6px, 1.5vw, 10px) clamp(8px, 2vw, 12px) !important;
        white-space: nowrap;
    }
    
    .table thead th {
        font-size: clamp(0.7rem, 1.8vw, 0.85rem) !important;
        position: sticky;
        top: 0;
        background: #f8f9fa;
        z-index: 10;
    }
}

/* ============================================
   BOTÕES RESPONSIVOS
   ============================================ */
@media (max-width: 767px) {
    .btn {
        padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 20px) !important;
        font-size: var(--mobile-font) !important;
        white-space: nowrap;
    }
    
    .btn-sm {
        padding: clamp(5px, 1.2vw, 8px) clamp(8px, 2vw, 12px) !important;
        font-size: clamp(0.75rem, 1.8vw, 0.875rem) !important;
    }
    
    .btn-lg {
        padding: clamp(10px, 2.5vw, 14px) clamp(16px, 4vw, 24px) !important;
        font-size: clamp(0.95rem, 2.5vw, 1.1rem) !important;
    }
    
    .btn-group {
        flex-wrap: wrap;
        gap: clamp(4px, 1vw, 8px);
    }
    
    .btn-block,
    .d-grid .btn {
        width: 100% !important;
        margin-bottom: clamp(8px, 2vw, 12px);
    }
}

/* ============================================
   FORMULÁRIOS RESPONSIVOS
   ============================================ */
@media (max-width: 767px) {
    .form-control,
    .form-select {
        padding: clamp(8px, 2vw, 12px) !important;
        font-size: var(--mobile-font) !important;
        height: auto !important;
        min-height: clamp(38px, 10vw, 42px);
    }
    
    .form-label {
        font-size: clamp(0.85rem, 2.2vw, 0.95rem) !important;
        margin-bottom: clamp(4px, 1vw, 8px) !important;
    }
    
    .input-group-text {
        padding: clamp(8px, 2vw, 12px) !important;
        font-size: var(--mobile-font) !important;
    }
    
    textarea.form-control {
        min-height: clamp(80px, 20vw, 120px) !important;
    }
}

/* ============================================
   MODALS RESPONSIVOS
   ============================================ */
@media (max-width: 767px) {
    .modal-dialog {
        margin: clamp(8px, 2vw, 15px) !important;
        max-width: calc(100% - clamp(16px, 4vw, 30px)) !important;
    }
    
    .modal-content {
        border-radius: clamp(8px, 2vw, 12px) !important;
    }
    
    .modal-header,
    .modal-footer {
        padding: clamp(12px, 3vw, 16px) !important;
    }
    
    .modal-body {
        padding: clamp(15px, 4vw, 20px) !important;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .modal-title {
        font-size: var(--mobile-h3) !important;
    }
}

/* ============================================
   BADGES E LABELS
   ============================================ */
@media (max-width: 767px) {
    .badge {
        padding: clamp(4px, 1vw, 6px) clamp(8px, 2vw, 10px) !important;
        font-size: clamp(0.7rem, 1.8vw, 0.8rem) !important;
    }
}

/* ============================================
   DASHBOARD CARDS
   ============================================ */
@media (max-width: 767px) {
    .dashboard-card {
        margin-bottom: clamp(15px, 4vw, 20px) !important;
    }
    
    .dashboard-card .card-body {
        padding: clamp(15px, 4vw, 20px) !important;
    }
    
    .dashboard-card h3 {
        font-size: var(--mobile-h2) !important;
    }
    
    .dashboard-card .display-4 {
        font-size: clamp(1.8rem, 8vw, 2.5rem) !important;
    }
}

/* ============================================
   FOOTER RESPONSIVO
   ============================================ */
@media (max-width: 767px) {
    .dashboard-footer {
        padding: clamp(15px, 4vw, 20px) clamp(10px, 2.5vw, 15px) !important;
        font-size: clamp(0.75rem, 2vw, 0.85rem) !important;
    }
    
    .dashboard-footer .row {
        text-align: center !important;
    }
    
    .dashboard-footer [class*="col-"] {
        margin-bottom: clamp(10px, 2.5vw, 15px);
    }
    
    .bandeira-angola {
        width: clamp(40px, 10vw, 60px) !important;
        margin: 0 auto clamp(10px, 2.5vw, 15px) !important;
        display: block !important;
    }
}

/* ============================================
   NAVEGAÇÃO MOBILE
   ============================================ */
@media (max-width: 767px) {
    .navbar {
        padding: clamp(8px, 2vw, 12px) var(--mobile-padding) !important;
    }
    
    .navbar-brand {
        font-size: var(--mobile-h3) !important;
    }
    
    .nav-link {
        padding: clamp(8px, 2vw, 12px) !important;
        font-size: var(--mobile-font) !important;
    }
}

/* ============================================
   ALERTAS RESPONSIVOS
   ============================================ */
@media (max-width: 767px) {
    .alert {
        padding: clamp(10px, 2.5vw, 15px) !important;
        font-size: var(--mobile-font) !important;
        margin-bottom: clamp(12px, 3vw, 16px) !important;
    }
}

/* ============================================
   PAGINAÇÃO RESPONSIVA
   ============================================ */
@media (max-width: 767px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center !important;
    }
    
    .page-link {
        padding: clamp(6px, 1.5vw, 8px) clamp(10px, 2.5vw, 12px) !important;
        font-size: clamp(0.8rem, 2vw, 0.9rem) !important;
    }
}

/* ============================================
   UTILITY CLASSES MOBILE
   ============================================ */
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    
    .text-mobile-center { text-align: center !important; }
    .text-mobile-left { text-align: left !important; }
    .text-mobile-right { text-align: right !important; }
    
    .mt-mobile { margin-top: var(--mobile-padding) !important; }
    .mb-mobile { margin-bottom: var(--mobile-padding) !important; }
    .py-mobile { padding-top: var(--mobile-padding) !important; padding-bottom: var(--mobile-padding) !important; }
    .px-mobile { padding-left: var(--mobile-padding) !important; padding-right: var(--mobile-padding) !important; }
}

/* ============================================
   SAFE AREA (iPhone X, 11, 12, 13, 14, 15)
   ============================================ */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================
   LANDSCAPE MODE (Celular deitado)
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-body {
        max-height: 50vh !important;
    }
    
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }
}

/* ============================================
   DISPOSITIVOS MUITO PEQUENOS (< 360px)
   ============================================ */
@media (max-width: 359px) {
    html { font-size: 12px; }
    
    .table {
        font-size: 0.7rem !important;
    }
    
    .btn {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
}

/* ============================================
   TOUCH TARGETS (Áreas de toque)
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    a, button, .btn, .nav-link, .page-link {
        min-height: 44px; /* Padrão Apple HIG */
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

