/* ========================================
   CSS RESPONSIVO PARA MOBILE
   Compatibilidade com dispositivos móveis
   ======================================== */

/* Variáveis CSS para mobile */
:root {
    --mobile-breakpoint: 768px;
    --mobile-sidebar-width: 60px;
    --mobile-header-height: 60px;
    --mobile-padding: 10px;
}

/* ========================================
   LAYOUT GERAL RESPONSIVO
   ======================================== */

/* Ajustes para telas pequenas */
@media (max-width: 768px) {
    /* Reset de margens e padding para mobile */
    body {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 14px;
        overflow-x: hidden;
    }
    
    /* Ajustar sidebar para mobile */
    .sidebar, .fix-menu-global-nivel0 {
        width: var(--mobile-sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.open, .fix-menu-global-nivel0.open {
        transform: translateX(0);
    }
    
    /* Ajustar conteúdo principal */
    .content, .content-main {
        margin-left: 0 !important;
        padding: var(--mobile-padding) !important;
        width: 100% !important;
        min-height: 100vh;
    }
    
    /* Botão hambúrguer para abrir menu */
    .mobile-menu-toggle {
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-main);
        padding: 10px;
        border-radius: 5px;
        cursor: pointer;
        display: block;
    }
    
    .mobile-menu-toggle:hover {
        background: var(--bg-darker);
    }
    
    /* Overlay para fechar menu */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .mobile-overlay.active {
        display: block;
    }
}

/* ========================================
   CARDS E ESTATÍSTICAS RESPONSIVAS
   ======================================== */

@media (max-width: 768px) {
    /* Container de estatísticas */
    .stats-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin-bottom: 15px !important;
    }
    
    .stat-card {
        min-width: unset !important;
        padding: 15px !important;
        text-align: center;
    }
    
    .stat-card h3 {
        font-size: 0.8em !important;
        margin-bottom: 5px !important;
    }
    
    .stat-card .value {
        font-size: 1.5em !important;
    }
    
    .stat-card i {
        font-size: 1.1em !important;
        margin-bottom: 8px !important;
    }
    
    /* Cards de informação */
    .row.mb-3 {
        margin-bottom: 15px !important;
    }
    
    .info-card {
        padding: 15px !important;
        margin-bottom: 10px !important;
    }
    
    .info-card .title {
        font-size: 0.85rem !important;
    }
    
    .info-card .value {
        font-size: 1.3rem !important;
    }
}

/* ========================================
   TABELAS RESPONSIVAS
   ======================================== */

@media (max-width: 768px) {
    /* Container de tabela com scroll horizontal */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        margin-bottom: 15px;
    }
    
    .activity-table, .users-table {
        min-width: 600px; /* Largura mínima para manter legibilidade */
        font-size: 0.8rem;
    }
    
    .activity-table th, .users-table th {
        padding: 8px 6px !important;
        font-size: 0.7rem !important;
        white-space: nowrap;
    }
    
    .activity-table td, .users-table td {
        padding: 8px 6px !important;
        font-size: 0.75rem;
    }
    
    /* Ocultar colunas menos importantes em mobile */
    .activity-table th:nth-child(3), /* IP */
    .activity-table td:nth-child(3),
    .activity-table th:nth-child(7), /* BIN Details */
    .activity-table td:nth-child(7) {
        display: none;
    }
    
    /* Ajustar badges para mobile */
    .badge-aprovada, .badge-reprovada, .badge-erro {
        font-size: 0.7rem !important;
        padding: 2px 6px !important;
    }
    
    /* Ajustar avatares de usuário */
    .user-avatar {
        width: 25px !important;
        height: 25px !important;
        font-size: 0.8rem !important;
    }
}

/* ========================================
   HEADER E NAVEGAÇÃO MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Header customizado */
    .dashboard-header-custom {
        margin-bottom: 10px !important;
        padding-top: 0 !important;
    }
    
    .dashboard-header-custom img.killua-logo {
        height: 100px !important;
        object-position: center 20% !important;
    }
    
    .dashboard-header-custom .header-title-main {
        font-size: 1.5em !important;
        bottom: 30px !important;
    }
    
    .dashboard-header-custom .dashboard-slogan-main {
        font-size: 0.9em !important;
        bottom: 10px !important;
    }
    
    /* Botões de ação superiores */
    .top-action-buttons {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        margin-bottom: 15px !important;
    }
    
    .top-action-buttons > * {
        width: 100% !important;
        justify-content: center !important;
        padding: 10px !important;
        font-size: 0.9rem !important;
    }
    
    /* Contador de créditos em mobile */
    .credits-display {
        text-align: center !important;
        font-size: 0.9rem !important;
    }
}

/* ========================================
   MENU LATERAL MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Menu lateral compacto */
    .nav-menu a {
        padding: 10px 15px !important;
        font-size: 0.9rem;
    }
    
    .nav-menu i {
        margin-right: 8px !important;
        font-size: 1rem;
    }
    
    /* Logo do menu */
    .logo {
        height: 60px !important;
        padding: 0 15px !important;
    }
    
    .logo img {
        width: 35px !important;
        height: 35px !important;
    }
    
    .logo span {
        font-size: 18px !important;
    }
}

/* ========================================
   MODAIS E POPUPS MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Modais responsivos */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    .modal-content {
        border-radius: 8px !important;
    }
    
    .modal-header {
        padding: 15px !important;
    }
    
    .modal-body {
        padding: 15px !important;
    }
    
    .modal-footer {
        padding: 15px !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
    }
}

/* ========================================
   FORMULÁRIOS MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Inputs e selects */
    .form-control, .form-select {
        font-size: 16px !important; /* Evita zoom no iOS */
        padding: 12px !important;
    }
    
    /* Botões */
    .btn {
        padding: 12px 20px !important;
        font-size: 0.9rem !important;
        min-height: 44px; /* Tamanho mínimo para touch */
    }
    
    /* Grupos de botões */
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .btn-group .btn {
        border-radius: 6px !important;
        margin-bottom: 5px !important;
    }
}

/* ========================================
   AVISOS E NOTIFICAÇÕES MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Sistema de avisos */
    .system-notices {
        margin-bottom: 15px !important;
    }
    
    .notice-item {
        padding: 10px 12px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .notice-time {
        flex: none !important;
        margin-bottom: 5px !important;
        font-size: 0.8rem !important;
    }
    
    .notice-icon {
        flex: none !important;
        margin-right: 0 !important;
        margin-bottom: 5px !important;
    }
    
    .notice-content {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }
}

/* ========================================
   CONTROLES DE REFRESH MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Controles de refresh */
    .refresh-controls {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        margin-bottom: 10px !important;
    }
    
    .refresh-controls select {
        width: 100% !important;
        font-size: 0.9rem !important;
    }
    
    /* Botões de filtro */
    .filter-buttons {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .filter-buttons .btn {
        margin: 2px 0 !important;
        width: 100% !important;
    }
}

/* ========================================
   UTILITÁRIOS MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Texto responsivo */
    .text-mobile-center {
        text-align: center !important;
    }
    
    .text-mobile-left {
        text-align: left !important;
    }
    
    /* Espaçamentos */
    .mb-mobile-2 {
        margin-bottom: 0.5rem !important;
    }
    
    .mb-mobile-3 {
        margin-bottom: 1rem !important;
    }
    
    .mb-mobile-4 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Ocultar elementos em mobile */
    .d-mobile-none {
        display: none !important;
    }
    
    /* Mostrar apenas em mobile */
    .d-mobile-block {
        display: block !important;
    }
    
    .d-mobile-flex {
        display: flex !important;
    }
}

/* ========================================
   MELHORIAS DE TOUCH
   ======================================== */

@media (max-width: 768px) {
    /* Área de toque mínima */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Links clicáveis */
    .clickable {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Scroll suave */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevenir zoom em inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ========================================
   ORIENTAÇÃO LANDSCAPE
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    /* Ajustes para landscape */
    .dashboard-header-custom img.killua-logo {
        height: 80px !important;
    }
    
    .stats-container {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .top-action-buttons {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }
    
    .top-action-buttons > * {
        flex: 1 !important;
        min-width: 120px !important;
    }
}

/* ========================================
   TELAS MUITO PEQUENAS
   ======================================== */

@media (max-width: 480px) {
    /* Ajustes para telas muito pequenas */
    .stats-container {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .stat-card {
        padding: 12px !important;
    }
    
    .stat-card .value {
        font-size: 1.3em !important;
    }
    
    .activity-table, .users-table {
        min-width: 500px;
        font-size: 0.75rem;
    }
    
    .dashboard-header-custom .header-title-main {
        font-size: 1.2em !important;
    }
    
    .dashboard-header-custom .dashboard-slogan-main {
        font-size: 0.8em !important;
    }
}

/* ========================================
   ANIMAÇÕES E TRANSITIONS
   ======================================== */

@media (max-width: 768px) {
    /* Transições suaves para mobile */
    .sidebar, .fix-menu-global-nivel0 {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-overlay {
        transition: opacity 0.3s ease;
    }
    
    /* Animações reduzidas para performance */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Desabilitar animações se o usuário preferir */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation: none !important;
            transition: none !important;
        }
    }
}
