/* CORRECCIONES DE RESPONSIVIDAD - FIXES CRÍTICOS */

/* ===== NAVBAR FIXES ===== */
@media (max-width: 1200px) {
    .header-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        text-align: center;
    }
    
    .admin-nav {
        justify-self: center;
        width: 100%;
        max-width: none;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.75rem;
        gap: 0.25rem;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        text-align: center;
        min-width: auto;
        flex: 1;
        white-space: nowrap;
    }
    
    .nav-link br {
        display: none;
    }
    
    .user-info {
        position: static;
        margin-top: 1rem;
        width: 100%;
        max-width: 300px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }
    
    .admin-nav {
        display: none;
    }
    
    .mobile-menu {
        display: block !important;
    }
    
    .header-left h1 {
        font-size: 1.5rem;
    }
    
    .header-left p {
        font-size: 0.8rem;
    }
}

/* ===== FILTROS DE VENTAS FIXES ===== */
.sales-filters {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

@media (max-width: 768px) {
    .sales-filters {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .filter-controls {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .filter-select,
    .date-input,
    .btn-filter {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
        box-sizing: border-box;
    }
    
    .btn-filter {
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .sales-filters {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }
    
    .filter-controls {
        gap: 0.5rem;
    }
    
    .filter-select,
    .date-input,
    .btn-filter {
        padding: 0.6rem;
        font-size: 16px;
        border-radius: 6px;
    }
}

/* ===== TABLA TARIFARIO FIXES ===== */
.tarifario-section {
    margin-top: 3rem;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tarifario-section .search-container {
    margin-bottom: 1rem;
}

.tarifario-section .search-container select {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Contenedor con scroll horizontal para la tabla */
.table-scroll-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#tarifas-table {
    min-width: 1200px;
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.8rem;
}

#tarifas-table th {
    background: #667eea;
    color: white;
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

#tarifas-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    text-align: center;
    font-size: 0.75rem;
    white-space: nowrap;
}

#tarifas-table tbody tr:hover {
    background: #f8f9fa;
}

/* Colores específicos para cada tipo de tarifa */
.header-agencia { background: #28a745 !important; }
.header-aliado17 { background: #6f42c1 !important; }
.header-aliado15 { background: #007bff !important; }
.header-freelance { background: #fd7e14 !important; }

.sub-agencia { background: #d4edda !important; color: #155724 !important; }
.sub-aliado17 { background: #e8d5f0 !important; color: #4a1a5c !important; }
.sub-aliado15 { background: #cce7ff !important; color: #004085 !important; }
.sub-freelance { background: #ffe0cc !important; color: #7a3f00 !important; }

@media (max-width: 768px) {
    .tarifario-section {
        padding: 0.5rem;
        margin: 1rem 0;
    }
    
    #tarifas-table {
        min-width: 1000px;
        font-size: 0.7rem;
    }
    
    #tarifas-table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.65rem;
    }
    
    #tarifas-table td {
        padding: 0.4rem 0.25rem;
        font-size: 0.65rem;
    }
    
    .btn-edit-tarifa,
    .btn-delete-tarifa {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        margin: 0.1rem;
    }
}

/* ===== CHARTS RESPONSIVOS ===== */
.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 1024px) {
    .charts-container {
        grid-template-columns: 1fr 2fr;
    }
}

.chart-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

@media (max-width: 768px) {
    .chart-section {
        padding: 1rem;
    }
    
    .chart-wrapper {
        height: 250px;
    }
}

/* ===== STATS GRID RESPONSIVO ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== AGENCY SUMMARY RESPONSIVO ===== */
.agency-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .agency-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .agency-summary {
        grid-template-columns: 1fr;
    }
}

/* ===== TABLAS RESPONSIVAS GENERALES ===== */
.users-table-wrapper,
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .users-table,
    .cotizaciones-table {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    .users-table th,
    .users-table td,
    .cotizaciones-table th,
    .cotizaciones-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .btn-user-action,
    .btn-action {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
}

/* ===== FORMULARIOS RESPONSIVOS ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== HOTELES GRID RESPONSIVO ===== */
.hoteles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .hoteles-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== SERVICIOS GRID RESPONSIVO ===== */
.servicios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .servicios-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ===== ASESORES GRID RESPONSIVO ===== */
.asesores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .asesores-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== FILTROS RESPONSIVOS ===== */
.filters-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .filters-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .search-input,
    .filter-select {
        width: 100%;
    }
}

/* ===== MODAL RESPONSIVO ===== */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal form {
        padding: 1rem;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.w-100 { width: 100%; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ===== SCROLL INDICATORS ===== */
.table-scroll-container::after {
    content: "← Desliza para ver más →";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px 12px 0 0;
    font-size: 0.7rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .table-scroll-container {
        position: relative;
    }
    
    .table-scroll-container::after {
        opacity: 1;
    }
}

/* ===== LOADING STATES ===== */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.loading i {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

/* ===== ERROR STATES ===== */
.error {
    text-align: center;
    padding: 2rem;
    color: #dc3545;
    background: #f8d7da;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
}