/**
 * Estilos responsive mejorados para móviles
 * Plataforma SaaS Email Marketing
 */

/* Overlay para sidebar en móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block !important;
}

/* Móviles - hasta 768px */
@media (max-width: 768px) {
    /* Sidebar completamente oculto por defecto */
    #sidebar,
    .sidebar {
        position: fixed !important;
        left: -260px !important;
        top: 0 !important;
        width: 260px !important;
        height: 100vh !important;
        z-index: 1050 !important;
        transition: left 0.3s ease !important;
        box-shadow: none !important;
    }
    
    /* Sidebar visible cuando tiene clase .show */
    #sidebar.show,
    .sidebar.show {
        left: 0 !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3) !important;
    }
    
    /* Header a ancho completo */
    .header,
    header.header {
        left: 0 !important;
        right: 0 !important;
        padding: 0.75rem 1rem !important;
        padding-left: 4.5rem !important; /* Espacio para el botón hamburguesa */
        height: auto !important;
        min-height: 60px !important;
        position: fixed !important;
        top: 0 !important;
        z-index: 1040 !important;
        background: #fff !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    }
    
    .header-content {
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
    }
    
    .header-left {
        flex: 1;
        min-width: 0;
    }
    
    .header-right {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .page-title {
        font-size: 1.1rem !important;
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Ajustar elementos del header en móvil */
    .header-item {
        margin: 0 !important;
    }
    
    .header-item .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    .user-menu-btn {
        padding: 0.25rem !important;
    }
    
    .user-avatar-header {
        width: 32px !important;
        height: 32px !important;
    }
    
    /* Main content a ancho completo */
    main.main-content,
    .main-content {
        margin-left: 0 !important;
        margin-top: 60px !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem !important;
    }
    
    /* Container fluid sin padding extra */
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Cards más compactas */
    .card {
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .card-header {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem;
    }
    
    /* Estadísticas en grid responsive */
    .row .col-md-3,
    .row .col-md-4,
    .row .col-md-6 {
        margin-bottom: 1rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Tarjetas de estadísticas más pequeñas */
    .stat-card {
        min-height: auto;
    }
    
    .stat-card .card-body {
        padding: 1rem !important;
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .stat-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.2rem !important;
    }
    
    .stat-value {
        font-size: 1.5rem !important;
        margin: 0 !important;
    }
    
    .stat-label {
        font-size: 0.85rem !important;
        margin: 0 !important;
    }
    
    /* Tablas responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
        border-radius: 8px;
    }
    
    .table {
        font-size: 0.875rem;
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Ocultar columnas menos importantes en tablas */
    .table th:nth-child(n+5),
    .table td:nth-child(n+5) {
        display: none;
    }
    
    /* Botones más pequeños */
    .btn-group {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        min-width: auto;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    
    /* Modales más pequeños */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 8px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem !important;
    }
    
    /* Formularios */
    .form-control,
    .form-select {
        font-size: 0.9rem;
        padding: 0.5rem;
    }
    
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    /* Botón toggle visible en móvil */
    .sidebar-toggle-mobile,
    #sidebarToggleMobile {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        left: 1rem;
        top: 1rem;
        z-index: 1060 !important;
        background: #fff !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 8px !important;
        padding: 0.75rem !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
        width: 44px;
        height: 44px;
        color: #374151 !important;
        font-size: 1.2rem;
        transition: all 0.3s ease;
    }
    
    .sidebar-toggle-mobile:hover,
    #sidebarToggleMobile:hover {
        background: #f9fafb !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
        transform: scale(1.05);
    }
    
    .sidebar-toggle-mobile:active,
    #sidebarToggleMobile:active {
        transform: scale(0.95);
    }
    
    /* Ocultar botón de colapsar sidebar en móvil */
    #sidebarCollapse {
        display: none !important;
    }
    
    /* Mejorar visualización de badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Gráficos más pequeños */
    .chart-container {
        height: 250px !important;
    }
    
    .chart-container-large {
        height: 280px !important;
    }
    
    /* Dashboard KPI Cards - Responsive */
    .dashboard-kpi .kpi-card {
        margin-bottom: 1rem;
        padding: 1.25rem !important;
    }
    
    .dashboard-kpi .kpi-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.25rem !important;
    }
    
    .dashboard-kpi .kpi-value {
        font-size: 1.75rem !important;
        margin: 0.5rem 0 !important;
    }
    
    .dashboard-kpi .kpi-label {
        font-size: 0.75rem !important;
        margin-top: 0.25rem !important;
    }
    
    /* Dashboard Charts - Stack verticalmente en móvil */
    .dashboard-kpi .row > [class*="col-"] {
        margin-bottom: 1.5rem;
    }
    
    .dashboard-kpi .chart-card {
        padding: 1.25rem !important;
        margin-bottom: 1.5rem;
    }
    
    .dashboard-kpi .chart-header {
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }
    
    .dashboard-kpi .chart-title {
        font-size: 1rem !important;
    }
    
    /* Donut chart más pequeño en móvil */
    .donut-chart-wrapper {
        height: 220px !important;
    }
    
    .donut-center-value {
        font-size: 1.75rem !important;
    }
    
    .donut-center-label {
        font-size: 0.75rem !important;
    }
    
    /* Bar chart horizontal más compacto */
    .bar-chart-horizontal {
        gap: 0.75rem;
    }
    
    .bar-item {
        gap: 0.75rem;
    }
    
    .bar-label {
        min-width: 100px;
        font-size: 0.8rem;
    }
    
    .bar-container {
        height: 28px;
    }
    
    /* Tabla de campañas más compacta */
    .recent-campaigns-table {
        font-size: 0.85rem;
    }
    
    .recent-campaigns-table th,
    .recent-campaigns-table td {
        padding: 0.75rem 0.5rem !important;
    }
    
    /* Ocultar columnas menos importantes en tabla de campañas */
    .recent-campaigns-table th:nth-child(3),
    .recent-campaigns-table td:nth-child(3),
    .recent-campaigns-table th:nth-child(6),
    .recent-campaigns-table td:nth-child(6) {
        display: none;
    }
    
    /* Texto más legible */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.3rem !important; }
    h3 { font-size: 1.1rem !important; }
    h4 { font-size: 1rem !important; }
    h5 { font-size: 0.95rem !important; }
    h6 { font-size: 0.9rem !important; }
    
    /* Dropdowns */
    .dropdown-menu {
        font-size: 0.9rem;
        max-width: calc(100vw - 2rem);
    }
    
    /* Alerts */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Tablets - 769px a 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    main.main-content,
    .main-content {
        padding: 1.5rem !important;
    }
    
    .card-body {
        padding: 1.25rem !important;
    }
    
    .stat-card .card-body {
        padding: 1.25rem !important;
    }
    
    .table th,
    .table td {
        padding: 0.75rem !important;
    }
}

/* Prevenir scroll horizontal */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    * {
        max-width: 100%;
    }
}

