/**
 * =============================================================================
 * API BI Gestión Automotriz - Estilos del Dashboard
 * =============================================================================
 * Estilos específicos para el dashboard ejecutivo.
 * Basado en el diseño de referencia DASHBOARD.JPG
 * =============================================================================
 */

/* =============================================================================
   LAYOUT DEL DASHBOARD
   ============================================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.dashboard-section {
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.dashboard-section.full-width {
    grid-column: 1 / -1;
}

/* =============================================================================
   ENCABEZADO DE SECCIÓN
   ============================================================================= */
.section-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--color-white);
    padding: var(--spacing-sm) var(--spacing-md);
    font-weight: 600;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-title svg {
    width: 18px;
    height: 18px;
    opacity: 0.9;
}

.section-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.section-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: var(--font-size-xs);
    transition: background var(--transition-fast);
}

.section-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =============================================================================
   TABLAS DEL DASHBOARD
   ============================================================================= */
.dashboard-table-container {
    overflow-x: auto;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.dashboard-table th {
    background-color: var(--color-primary);
    color: var(--color-white);
    padding: 6px 8px;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--color-primary-dark);
}

.dashboard-table th.col-department {
    text-align: left;
    min-width: 120px;
}

.dashboard-table td {
    padding: 4px 8px;
    border: 1px solid var(--color-gray-200);
    vertical-align: middle;
}

.dashboard-table tbody tr:nth-child(even) {
    background-color: var(--color-gray-100);
}

.dashboard-table tbody tr:hover {
    background-color: rgba(30, 58, 95, 0.05);
}

.dashboard-table .row-total {
    background-color: var(--color-primary) !important;
    color: var(--color-white);
    font-weight: 700;
}

.dashboard-table .row-total td {
    border-color: var(--color-primary-dark);
}

/* Celdas con iconos */
.cell-with-icon {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cell-icon {
    width: 16px;
    height: 16px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.cell-icon:hover {
    opacity: 1;
}

.cell-icon.icon-chart {
    color: var(--color-warning);
}

.cell-icon.icon-table {
    color: var(--color-secondary);
}

/* Valores numéricos */
.cell-numeric {
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
}

.cell-currency {
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
}

.cell-percent {
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Colores de valores */
.value-positive {
    color: var(--color-success);
}

.value-negative {
    color: var(--color-danger);
}

.value-warning {
    color: #856404;
}

/* =============================================================================
   SECCIÓN DE VENTAS
   ============================================================================= */
.ventas-table th:not(.col-department) {
    min-width: 90px;
}

/* =============================================================================
   SECCIÓN DE CUENTAS POR COBRAR
   ============================================================================= */
.cxc-table th:not(.col-department) {
    min-width: 100px;
}

/* =============================================================================
   SECCIÓN DE INVENTARIO
   ============================================================================= */
.inventario-table th:not(.col-department) {
    min-width: 80px;
}

/* =============================================================================
   SECCIÓN DE AVANCE DE OBJETIVOS
   ============================================================================= */
.objetivos-container {
    padding: var(--spacing-md);
}

.objetivo-item {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-md);
}

.objetivo-item:last-child {
    margin-bottom: 0;
}

.objetivo-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.objetivo-label {
    width: 120px;
    font-size: var(--font-size-sm);
    color: var(--color-gray-700);
}

.objetivo-bar-container {
    flex: 1;
    height: 24px;
    background-color: var(--color-gray-200);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    position: relative;
}

.objetivo-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: var(--border-radius-sm);
    transition: width var(--transition-slow);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: var(--spacing-sm);
}

.objetivo-bar.bar-success {
    background: linear-gradient(90deg, var(--color-success) 0%, #34ce57 100%);
}

.objetivo-bar.bar-warning {
    background: linear-gradient(90deg, var(--color-warning) 0%, #ffda6a 100%);
}

.objetivo-bar.bar-danger {
    background: linear-gradient(90deg, var(--color-danger) 0%, #e35d6a 100%);
}

.objetivo-value {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-white);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.objetivo-target {
    width: 80px;
    text-align: right;
    font-size: var(--font-size-sm);
    color: var(--color-gray-600);
}

/* =============================================================================
   SECCIÓN DE PROBLEMAS DE ATENCIÓN INMEDIATA
   ============================================================================= */
.problemas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
}

.problema-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--color-gray-100);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--color-danger);
}

.problema-item.warning {
    border-left-color: var(--color-warning);
}

.problema-item.info {
    border-left-color: var(--color-info);
}

.problema-label {
    font-size: var(--font-size-xs);
    color: var(--color-gray-700);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.problema-value {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-dark);
}

.problema-value.danger {
    color: var(--color-danger);
}

.problema-value.warning {
    color: #856404;
}

/* =============================================================================
   FILTROS DEL DASHBOARD
   ============================================================================= */
.dashboard-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    align-items: center;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-label {
    font-size: var(--font-size-sm);
    color: var(--color-gray-600);
    white-space: nowrap;
}

.filter-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-sm);
    border: 1px solid var(--color-gray-300);
    border-radius: var(--border-radius-sm);
    background-color: var(--color-white);
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-actions {
    margin-left: auto;
    display: flex;
    gap: var(--spacing-sm);
}

/* =============================================================================
   INDICADOR DE ÚLTIMA ACTUALIZACIÓN
   ============================================================================= */
.last-update {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-gray-500);
}

.last-update svg {
    width: 14px;
    height: 14px;
}

/* =============================================================================
   NOTA AL PIE
   ============================================================================= */
.dashboard-note {
    font-size: var(--font-size-xs);
    color: var(--color-gray-500);
    font-style: italic;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--color-gray-100);
    border-top: 1px solid var(--color-gray-200);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-item {
        width: 100%;
    }
    
    .filter-select {
        flex: 1;
    }
    
    .filter-actions {
        margin-left: 0;
        justify-content: flex-end;
    }
    
    .problemas-grid {
        grid-template-columns: 1fr;
    }
    
    .objetivo-label {
        width: 80px;
        font-size: var(--font-size-xs);
    }
    
    .objetivo-target {
        width: 60px;
        font-size: var(--font-size-xs);
    }
}

@media (max-width: 480px) {
    .dashboard-table {
        font-size: 10px;
    }
    
    .dashboard-table th,
    .dashboard-table td {
        padding: 3px 4px;
    }
    
    .section-header {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}
