@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #F4F6F9;
    color: #1E293B;
    -webkit-font-smoothing: antialiased;
}

.dashboard-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar (Light minimalist corporate look) */
.sidebar {
    width: 260px;
    background-color: #E9F0F8;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #cbd5e1;
}

.sidebar-header {
    padding: 24px 20px;
    background-color: #E9F0F8;
    border-bottom: 1px solid #cbd5e1;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: #4F46E5; /* Indigo Logo color */
    letter-spacing: -0.5px;
}

.sidebar-header p {
    font-size: 11px;
    font-weight: 600;
    color: #64748B;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-section {
    padding: 20px;
    flex-grow: 1;
    overflow-y: auto;
}

.filter-section h3 {
    margin-bottom: 15px;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #64748B;
}

.filter-group select, 
.filter-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #ffffff;
    color: #1e293b;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s ease;
}

.filter-group select:focus, 
.filter-group input:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-filter, 
.btn-reset {
    width: 100%;
    padding: 10px 14px;
    margin-top: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-filter {
    background-color: #4F46E5;
    color: white;
}

.btn-filter:hover {
    background-color: #4338CA;
}

.btn-reset {
    background-color: #ef4444;
    color: white;
    margin-top: 8px;
}

.btn-reset:hover {
    background-color: #dc2626;
}

/* Contenido Principal */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    margin-bottom: 24px;
    border: 1px solid #f1f5f9;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.5px;
}

/* Grupo Horizontal de Módulos (SaaS Style) */
.header-modules {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
    margin-right: 24px;
}

.module-btn {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

/* Colores pasteles ejecutivos para los módulos */
.module-btn.btn-green {
    background-color: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}
.module-btn.btn-green:hover {
    background-color: #dcfce7;
    border-color: #86efac;
}

.module-btn.btn-amber {
    background-color: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}
.module-btn.btn-amber:hover {
    background-color: #fef3c7;
    border-color: #fcd34d;
}

.module-btn.btn-yellow {
    background-color: #fefce8;
    color: #854d0e;
    border-color: #fef08a;
}
.module-btn.btn-yellow:hover {
    background-color: #fef9c3;
    border-color: #fde047;
}

.module-btn.btn-blue {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}
.module-btn.btn-blue:hover {
    background-color: #dbeafe;
    border-color: #93c5fd;
}

.module-btn.btn-slate {
    background-color: #f8fafc;
    color: #334155;
    border-color: #e2e8f0;
}
.module-btn.btn-slate:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-name-display {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.btn-logout {
    padding: 8px 16px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background-color: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}

/* --- NUEVO SISTEMA DE KPIs (Carrusel Minimalista y Premium) --- */
.kpi-carousel-wrapper {
    position: relative;
    margin-bottom: 24px;
    width: 100%;
}

.kpi-carousel-viewport {
    overflow: hidden;
    width: 100%;
}

.kpi-carousel-track {
    display: flex;
    gap: 20px;
}

.kpi-carousel-slide {
    display: contents; /* En escritorio, los slides no actúan como bloques separados */
}

/* Tarjetas Minimalistas Premium */
.kpi-card {
    flex: 1;
    background-color: #ffffff;
    padding: 24px 16px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03), 0 1px 3px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-family: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid #f8fafc;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
}

.kpi-card h3 {
    font-size: 13px;
    font-weight: 500;
    color: #64748b; /* Gris sutil minimalista */
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.kpi-card p {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b; /* Texto oscuro principal */
    margin: 0;
}

/* Colores de Acento Sutiles */
.kpi-card h3.kpi-orange, .kpi-card p.kpi-orange { color: #f59e0b; }
.kpi-card h3.kpi-red, .kpi-card p.kpi-red { color: #ef4444; }

/* En modo escritorio, los dots se ocultan */
.kpi-carousel-dots {
    display: none;
}

/* Dark Mode para KPIs Minimalistas */
.dark-mode .kpi-card {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.dark-mode .kpi-card h3 { color: #94a3b8; }
.kpi-card h3 {
    font-size: 11px;
    font-weight: 700;
    color: #64748B;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card p {
    font-size: 28px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
    text-shadow: none !important;
}

.kpi-clickable {
    cursor: pointer;
}
.kpi-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.03);
    border-color: #cbd5e1;
}

/* KPI Card Custom Pastel Backgrounds and Contrast Text colors */
#kpi-card-visitas {
    background-color: #BBDEFB !important;
    border-color: #90CAF9 !important;
}
#kpi-card-visitas p, #kpi-total-visitas {
    color: #1e40af !important;
}

#kpi-card-efectivas {
    background-color: #C8E6C9 !important;
    border-color: #A5D6A7 !important;
}
#kpi-card-efectivas p, #kpi-visitas-efectivas {
    color: #166534 !important;
}

#kpi-card-fallidas {
    background-color: #FFCDD2 !important;
    border-color: #EF9A9A !important;
}
#kpi-card-fallidas p, #kpi-visitas-fallidas {
    color: #991b1b !important;
}

#kpi-card-itinerario {
    background-color: #BBDEFB !important;
    border-color: #90CAF9 !important;
}
#kpi-card-itinerario p, #kpi-visitas-itinerario {
    color: #1e40af !important;
}

#kpi-card-fuera-itinerario {
    background-color: #FFE0B2 !important;
    border-color: #FFCC80 !important;
}
#kpi-card-fuera-itinerario p, #kpi-visitas-fuera-itinerario {
    color: #9a3412 !important;
}

#kpi-card-clientes {
    background-color: #E1BEE7 !important;
    border-color: #CE93D8 !important;
}
#kpi-card-clientes p, #kpi-nuevos-clientes {
    color: #6b21a8 !important;
}

#kpi-card-maestra-clientes {
    background-color: #E0F2F1 !important;
    border-color: #B2DFDB !important;
}
#kpi-card-maestra-clientes p, #kpi-maestra-clientes {
    color: #00695C !important;
}

/* Mapa y Gráficas (SaaS Clean Look) */
.charts-map-container {
    display: flex;
    gap: 24px;
    flex-grow: 1;
}

.map-section {
    flex: 2;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
}

.map-section h3, 
.chart-box h3 {
    margin-bottom: 16px;
    color: #1e293b;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

#dashboard-map {
    flex-grow: 1;
    min-height: 400px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.charts-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-box {
    background-color: #ffffff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    flex: 1;
    min-height: 180px;
    display: flex;
    flex-direction: column;
}

.canvas-container {
    position: relative;
    flex-grow: 1;
    height: 0;
    min-height: 130px;
}

.box-shadow {
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}

/* Modales del Dashboard (Clean typography, no text shadows, reduced size) */
.modal-dashboard {
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-dashboard-content {
    background-color: #ffffff;
    padding: 16px 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.05), 0 10px 10px -5px rgba(0,0,0,0.02);
    border: 1px solid #e2e8f0;
    font-size: 12px; /* Reduced font size for executive reading */
}

.modal-dashboard-content h2 {
    font-size: 15px;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 6px;
    text-align: center; /* Centered headers */
    text-shadow: none !important;
}

.modal-dashboard-content h3 {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    margin-top: 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 4px;
    text-shadow: none !important;
}

.modal-dashboard-content p {
    font-size: 11px;
    color: #64748b;
    text-shadow: none !important;
    margin-bottom: 4px;
}

.close-btn-dash {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 18px;
    font-weight: 400;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.15s ease;
}

.close-btn-dash:hover {
    color: #1e293b;
}

/* Tablas Modales (Minimalist light look) */
.clientes-table-container,
.table-scroll-container,
#detalle-visita-body,
#detalle-cliente-body,
#form-nuevo-usuario {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin-top: 8px;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.data-table th, 
.data-table td {
    padding: 6px 8px; /* Compact padding */
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    text-shadow: none !important;
}

.data-table th {
    background-color: #2C3E50;
    color: #ffffff;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    font-size: 12px;
    color: #334155;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.btn-ver-detalle {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 11px;
    font-family: inherit;
    transition: all 0.15s ease;
}
.btn-ver-detalle:hover {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* Cuadrícula de Fotos */
.fotos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.foto-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.foto-item img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.foto-item span {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    text-align: center;
}

/* --- PERFIL DE USUARIO EN SIDEBAR --- */
.sidebar-profile {
    padding: 20px;
    background-color: #E9F0F8;
    border-bottom: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-profile-name {
    color: #1e293b;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    word-break: break-all;
}

.sidebar-profile-company {
    color: #4F46E5;
    font-size: 11px;
    font-weight: 600;
    word-break: break-all;
}

/* --- MENÚ HAMBURGUESA EN MÓVILES --- */
.dashboard-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 3998;
    background-color: #ffffff;
    color: #4F46E5;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    display: none;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(2px);
    z-index: 3997;
}

/* --- RESPONSIVIDAD PARA MÓVILES --- */
@media (max-width: 1024px) {
    .dashboard-wrapper {
        display: block;
        height: auto;
        overflow: visible;
    }
    
    .sidebar {
        position: fixed;
        left: -285px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 4000;
        box-shadow: 10px 0 25px -5px rgba(0,0,0,0.05);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        padding-bottom: 100px; /* Evita que el bottom-nav tape el botón Cerrar Sesión */
        box-sizing: border-box;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .dashboard-menu-btn {
        display: flex;
    }

    .main-content {
        padding: 12px;
        padding-top: 70px;
        padding-bottom: 110px; /* Espacio extendido para el bottom nav iOS */
    }

    .topbar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        align-items: center;
        padding: 16px 12px;
    }

    .topbar h1 {
        font-size: 16px;
    }

    /* Rediseño de Módulos Horizontales en Móvil -> Ocultos a favor del Bottom Nav */
    .header-modules {
        display: none !important;
    }

    .module-btn {
        font-size: 11px;
        padding: 6px 10px;
    }

    .user-info {
        width: 100%;
        justify-content: center;
        border-top: 1px solid #f1f5f9;
        padding-top: 10px;
        margin-top: 4px;
    }

    /* Carrusel Táctil de KPIs para Celulares */
    .kpi-carousel-wrapper {
        margin-bottom: 12px;
    }
    
    .kpi-carousel-viewport {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch; /* Suavidad en iOS */
        scrollbar-width: none; /* Firefox */
    }
    .kpi-carousel-viewport::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .kpi-carousel-track {
        display: flex;
        flex-wrap: nowrap;
        gap: 0;
    }

    .kpi-carousel-slide {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        flex: 0 0 100%; /* Cada slide ocupa el 100% del ancho */
        scroll-snap-align: start; /* Encaje magnético */
        padding: 4px 2px;
        box-sizing: border-box;
    }
    
    /* Centrar la última tarjeta si la cuadrícula es impar SOLO en el segundo slide */
    .kpi-carousel-slide:nth-child(2) .kpi-card:nth-child(odd):last-child {
        grid-column: span 2;
    }

    /* Reordenamiento Solicitado para Móvil (Vendedor) */
    #kpi-card-visitas { order: 1; }
    #kpi-card-fallidas { order: 2; }
    #kpi-card-efectivas { 
        order: 3; 
        grid-column: span 2; /* Hacer que Efectivas sea alargado como Efectividad */
    }

    /* Reordenamiento Solicitado para Móvil (Promotor) */
    #kpi-card-promotor-total-ejecuciones { order: 1; }
    #kpi-card-promotor-efectivas-fuera { order: 2; }
    #kpi-card-promotor-efectivas-plan { 
        order: 3; 
        grid-column: span 2; 
    }

    .kpi-card {
        padding: 18px 12px;
        min-height: 85px;
    }

    .kpi-card h3 {
        font-size: 11px;
    }

    .kpi-card p {
        font-size: 22px;
    }

    /* Paginación (Dots) */
    .kpi-carousel-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-top: 12px;
    }
    
    .kpi-carousel-dots .dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: #cbd5e1;
        transition: background-color 0.3s ease, transform 0.3s ease;
    }
    
    .kpi-carousel-dots .dot.active {
        background-color: #38bdf8;
        transform: scale(1.3);
    }
    
    .dark-mode .kpi-carousel-dots .dot { background-color: #475569; }
    .dark-mode .kpi-carousel-dots .dot.active { background-color: #38bdf8; }

    .charts-map-container {
        flex-direction: column;
        gap: 16px;
    }

    .map-section {
        width: 100% !important;
        flex: none;
    }

    #dashboard-map {
        min-height: 400px; /* Más alto para facilitar exploración */
    }

    .charts-section {
        width: 100% !important;
        flex-direction: column !important; /* Forzar apilamiento vertical */
        flex: none;
        gap: 20px;
    }

    .chart-box {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-width: 100% !important;
        min-height: 300px; /* Gráficos con altura cómoda para no hacer zoom */
    }

    /* Fase 3: Rediseño de Tablas a Formato Tarjeta (Card Layout Vertical) */
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    
    .data-table thead {
        display: none; /* Ocultamos los encabezados de tabla */
    }
    
    .data-table tr {
        margin-bottom: 15px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        padding: 12px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }
    
    .dark-mode .data-table tr {
        background: #1e293b;
        border-color: #334155;
    }

    .data-table td {
        display: flex;
        justify-content: space-between; /* En caso de inyectar labels después, y para alinear texto */
        padding: 8px 0;
        border-bottom: 1px dashed #e2e8f0;
        text-align: left;
        font-size: 14px;
        color: #475569;
        word-break: break-word;
    }
    
    .dark-mode .data-table td {
        border-bottom-color: #334155;
        color: #94a3b8;
    }

    .data-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* El primer elemento suele ser el nombre/código, lo hacemos destacar como el "título" de la tarjeta */
    .data-table td:first-child {
        font-weight: 700;
        color: #1e293b;
        font-size: 15px;
        border-bottom: 2px solid #e2e8f0;
        padding-bottom: 8px;
        margin-bottom: 4px;
    }
    
    .dark-mode .data-table td:first-child {
        color: #f1f5f9;
        border-bottom-color: #475569;
    }

    /* Fase 3: Formularios, Botones y Entradas táctiles (Finger-Friendly) */
    input[type="text"], input[type="date"], input[type="number"], select, textarea, .btn, button {
        min-height: 48px !important; /* Estándar táctil (finger-friendly) */
        font-size: 16px !important; /* 16px evita que Safari en iOS haga zoom automático */
        border-radius: 8px;
        margin-bottom: 8px;
    }

    .modal-dashboard-content {
        padding: 20px 15px !important;
        width: 95% !important;
        box-sizing: border-box;
        border-radius: 16px !important; /* Más redondeado en móvil */
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-dashboard-content h2 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
        text-align: center;
    }

    .modal-dashboard-content p {
        font-size: 11px !important;
        margin-bottom: 8px !important;
    }

    .clientes-table-container {
        overflow-x: hidden !important;
    }

    .clientes-table-container table.data-table {
        min-width: unset !important;
        width: 100% !important;
        font-size: 9px !important;
    }

    .clientes-table-container table.data-table th, 
    .clientes-table-container table.data-table td {
        padding: 4px 3px !important;
        word-break: break-word !important;
        line-height: 1.15 !important;
    }

    .clientes-table-container table.data-table btn,
    .clientes-table-container table.data-table button,
    .clientes-table-container table.data-table a {
        font-size: 8px !important;
        padding: 3px 5px !important;
    }
}

/* Badges/Pills Modern Style (SaaS corporate look) */
.badge-pill {
    display: inline-block;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    border-radius: 20px;
    text-shadow: none !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid transparent;
}

/* Tipos de Visitas (Pastel translúcidos con texto oscuro) */
.badge-tipo-visita {
    background-color: #E3F2FD !important; /* Soft blue */
    color: #1e40af !important;
    border-color: #bbdefb !important;
}

.badge-tipo-venta {
    background-color: #E8F5E9 !important; /* Soft green */
    color: #166534 !important;
    border-color: #c8e6c9 !important;
}

.badge-tipo-cobranza {
    background-color: #FFF3E0 !important; /* Soft orange/amber */
    color: #9a3412 !important;
    border-color: #ffe0b2 !important;
}

.badge-tipo-venta-cobranza {
    background-color: #F3E5F5 !important; /* Soft purple */
    color: #6b21a8 !important;
    border-color: #e1bee7 !important;
}

.badge-tipo-supervisor {
    background-color: #FFF8E1 !important; /* Soft yellow */
    color: #b45309 !important;
    border-color: #ffe0b2 !important;
}

/* Ubicación Badges */
.badge-ubicacion-local {
    background-color: #F1F5F9 !important;
    color: #475569 !important;
    border-color: #e2e8f0 !important;
}

.badge-ubicacion-foraneo {
    background-color: #ECEFF1 !important;
    color: #37474F !important;
    border-color: #CFD8DC !important;
}

/* Global Prices Button & Modal Layout */
.btn-global-prices {
    padding: 8px 16px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-global-prices:hover {
    background-color: #e0f2fe;
    color: #0284c7;
    border-color: #bae6fd;
}

.modal-global-prices {
    position: fixed;
    z-index: 3100;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: #f4f6f9;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 16px 24px;
    overflow: hidden;
}

.modal-global-prices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #cbd5e1;
}

.modal-global-prices-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-global-prices-header p {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    font-weight: 600;
}

.modal-global-prices-close {
    font-size: 28px;
    font-weight: 300;
    color: #94a3b8;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.15s ease;
    padding: 0 8px;
    line-height: 1;
}

.modal-global-prices-close:hover {
    color: #ef4444;
}

.global-prices-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(300px, 1fr));
    gap: 15px;
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    padding-bottom: 15px; /* space for scrollbar */
}

.price-quadrant {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    border: 1px solid #e2e8f0;
    padding: 0; /* Remove padding to let table fill the edges */
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.price-quadrant h3 {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #2563eb;
    text-shadow: none !important;
    text-align: center !important;
}

.price-quadrant-table-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.price-ticker-table.consolidated-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    text-align: center;
}

.price-ticker-table.consolidated-table th {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e293b;
    font-weight: 700;
    padding: 12px 10px;
    border: 1px solid #e2e8f0;
    text-align: center !important;
}

.price-ticker-table.consolidated-table td {
    padding: 12px 10px;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    color: #475569;
    vertical-align: middle;
    text-align: center;
    transition: background-color 0.2s ease;
}

.price-ticker-table.consolidated-table tbody tr:hover td {
    background-color: #f0fdf4 !important;
}

/* Metric Cell Styling - Clean Corporate Look */
.cell-price-min {
    color: #ef4444 !important;
    font-weight: 600;
}
.cell-price-avg {
    color: #f59e0b !important;
    font-weight: 600;
}
.cell-price-max {
    color: #22c55e !important;
    font-weight: 600;
}
.cell-price-avg-gen {
    color: #2563eb !important;
    font-weight: 700;
}
.cell-sinc {
    color: #64748b !important;
    font-size: 11px;
    width: 60px;
    max-width: 60px;
    word-wrap: break-word;
}
.col-divider {
    border-right: 3px solid #b0c4de !important;
}

@media (max-width: 768px) {
    .global-prices-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* Efecto hover interactivo para nombres de clientes clicables */
.clickable-name {
    transition: color 0.15s ease;
}
.clickable-name:hover {
    color: #1e3a8a !important;
    text-decoration: underline;
}

/* Efecto hover interactivo en la celda del nombre del cliente */
.clickable-cell {
    transition: background-color 0.15s ease;
    cursor: pointer;
}
.clickable-cell:hover {
    background-color: #cbd5e1 !important; /* Fondo gris oscuro para resaltar la celda */
}

/* =========================================
   MODO OSCURO (DARK MODE)
   ========================================= */
body.dark-mode {
    background-color: #0f172a;
    color: #f8fafc;
}

/* Scrollbars Modo Oscuro */
.dark-mode ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.dark-mode ::-webkit-scrollbar-track {
    background: #0f172a;
}
.dark-mode ::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 5px;
}
.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.dark-mode .sidebar {
    background-color: #1e293b;
    border-right: 1px solid #334155;
}

.dark-mode .sidebar-header h2,
.dark-mode .filter-section h3,
.dark-mode label,
.dark-mode .map-section h3,
.dark-mode .chart-box h3,
.dark-mode h2,
.dark-mode h3 {
    color: #f8fafc;
}

.dark-mode .sidebar-header h2 {
    color: #818cf8; /* Mantener la identidad corporativa (indigo) pero brillante para dark mode */
}
.dark-mode .sidebar-header p {
    color: #94a3b8;
}
.dark-mode .sidebar-header {
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
}

.dark-mode .sidebar-profile {
    background-color: #0f172a; /* Fondo más oscuro para contraste con el sidebar */
    border-bottom: 1px solid #334155;
}
.dark-mode .sidebar-profile-name {
    color: #f8fafc;
}
.dark-mode .sidebar-profile-company {
    color: #818cf8; /* Indigo más claro y vibrante para modo noche */
}

.dark-mode .main-content {
    background-color: #0f172a;
}

.dark-mode .topbar {
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
}

.dark-mode #company-name-display {
    color: #f8fafc;
}

.dark-mode .map-section,
.dark-mode .chart-box,
.dark-mode .modal-dashboard-content {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.5);
}

.dark-mode .kpi-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

.dark-mode .kpi-card h3 {
    color: #cbd5e1 !important;
}

.dark-mode .data-table th {
    background-color: #334155;
    color: #f8fafc;
    border-bottom: 1px solid #475569;
}

.dark-mode .data-table td {
    border-bottom: 1px solid #334155;
    color: #cbd5e1;
}

/* Filtros */
.dark-mode .filter-group select,
.dark-mode .filter-group input[type="date"],
.dark-mode .filter-group input[type="text"] {
    background-color: #334155; /* Mejor contraste en sidebar */
    color: #f8fafc;
    border-color: #475569;
}
.dark-mode .filter-group select:focus,
.dark-mode .filter-group input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.dark-mode .btn-filter {
    background-color: #4f46e5;
    color: #fff;
}
.dark-mode .btn-filter:hover {
    background-color: #6366f1;
}

/* Botones de Módulos (Adaptación a modo oscuro) */
.dark-mode .module-btn {
    background-color: #334155;
    border-color: #475569;
    color: #cbd5e1;
}
.dark-mode .module-btn.btn-green { background-color: rgba(22, 101, 52, 0.3); color: #86efac; border-color: rgba(22, 101, 52, 0.5); }
.dark-mode .module-btn.btn-amber { background-color: rgba(146, 64, 14, 0.3); color: #fcd34d; border-color: rgba(146, 64, 14, 0.5); }
.dark-mode .module-btn.btn-yellow { background-color: rgba(133, 77, 14, 0.3); color: #fde047; border-color: rgba(133, 77, 14, 0.5); }
.dark-mode .module-btn.btn-indigo { background-color: rgba(55, 48, 163, 0.3); color: #a5b4fc; border-color: rgba(55, 48, 163, 0.5); }
.dark-mode .module-btn.btn-blue { background-color: rgba(30, 64, 175, 0.3); color: #93c5fd; border-color: rgba(30, 64, 175, 0.5); }
.dark-mode .module-btn.btn-slate { background-color: rgba(51, 65, 85, 0.5); color: #e2e8f0; border-color: #475569; }

.dark-mode .module-btn:hover {
    filter: brightness(1.2);
}

/* Botón Global Prices y Logout */
.dark-mode .btn-global-prices {
    background-color: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, 0.4);
}
.dark-mode .btn-logout {
    background-color: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border-color: rgba(220, 38, 38, 0.4);
}

.dark-mode #dashboard-map {
    border-color: #334155;
    /* El mapa ahora se cambia nativamente por JS, no con filtros CSS */
}

.dark-mode .btn-slate {
    background-color: #334155;
    color: #f8fafc;
    border-color: #475569;
}
.dark-mode .btn-slate:hover {
    background-color: #475569;
}

/* Suavizar bordes del botón modo oscuro específicamente (si tiene clase) */
#btn-dark-mode {
    border-radius: 20px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}
.dark-mode #btn-dark-mode {
    background-color: #334155;
    border-color: #475569;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Active View (Tabs Mapa vs Gráficos) */
.module-btn.active-view {
    background-color: #4F46E5 !important;
    color: #ffffff !important;
    border-color: #4338CA !important;
}

.dark-mode .module-btn.active-view {
    background-color: #818cf8 !important;
    color: #0f172a !important;
    border-color: #6366f1 !important;
}

/* --- ESTILO PREMIUM PARA EL GRID 2x3 DE GRÁFICOS --- */
.premium-dashboard .chart-box {
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
.premium-box-header {
    padding-bottom: 12px;
    margin-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
}
.premium-box-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dark-mode .premium-dashboard .chart-box {
    background: #111827; /* Fondo súper oscuro premium para las gráficas */
    border: 1px solid #1f2937;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.5);
}
.dark-mode .premium-box-header {
    border-bottom: 1px solid #1f2937;
}
.dark-mode .premium-box-header h3 {
    color: #e5e7eb;
}

/* --- BOTTOM NAVIGATION BAR (MÓVIL iOS STYLE) --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.08);
    z-index: 5000;
    justify-content: space-around;
    align-items: flex-start;
    padding: 12px 10px 30px 10px; /* 30px padding bottom para el safe area indicator */
    border-radius: 24px 24px 0 0; /* Esquinas superiores redondeadas */
    border: none;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #94a3b8; /* Gris claro (Outline vibe) */
    font-size: 11px;
    font-weight: 500;
    gap: 6px;
    position: relative;
    padding-top: 10px; /* Espacio para la linea superior */
    flex: 1;
    filter: grayscale(100%) opacity(0.6); /* Apaga los colores de los emojis por defecto */
    transition: all 0.3s ease;
}

.bottom-nav .nav-item .nav-icon {
    font-size: 22px;
}

/* Indicador de barra superior para el item activo */
.bottom-nav .nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 4px;
    border-radius: 0 0 4px 4px;
    background-color: transparent;
    transition: background-color 0.3s ease;
}

.bottom-nav .nav-item.active {
    color: #38bdf8; /* Azul claro */
    filter: none;
}

.bottom-nav .nav-item.active .nav-label {
    color: #38bdf8;
    font-weight: 600;
}

.bottom-nav .nav-item.active::before {
    background-color: #38bdf8; /* Línea azul clara arriba */
}

/* iOS Home Indicator */
.ios-home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 134px;
    height: 5px;
    background-color: #000000;
    border-radius: 100px;
}

.dark-mode .bottom-nav {
    background-color: #1e293b;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.4);
}

.dark-mode .ios-home-indicator {
    background-color: #ffffff;
}

.dark-mode .bottom-nav .nav-item {
    color: #64748b;
}

.dark-mode .bottom-nav .nav-item.active .nav-label {
    color: #38bdf8;
}

@media (max-width: 1024px) {
    .bottom-nav {
        display: flex;
    }
}
