/**
 * Analytics Dashboard CSS
 * Estilos profesionales para KPIs, gráficos y reportes
 */

/* ========== KPIs Grid ========== */
.kpis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Responsive: en pantallas pequeñas, 2 columnas */
@media (max-width: 1200px) {
    .kpis-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive: en móviles, 1 columna */
@media (max-width: 768px) {
    .kpis-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

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

.kpi-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.kpi-icon {
    font-size: 2rem;
}

.kpi-title {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.kpi-comparison {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.kpi-trend {
    font-size: 1.5rem;
    font-weight: 700;
}

.kpi-trend.trend-positive {
    color: #10b981;
}

.kpi-trend.trend-negative {
    color: #ef4444;
}

.kpi-trend.trend-neutral {
    color: #6b7280;
}

.kpi-change {
    font-weight: 600;
    color: #1f2937;
}

.kpi-vs-previous {
    color: #9ca3af;
    font-size: 0.75rem;
}

/* ========== Charts Grid ========== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f3f4f6;
}

.chart-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.chart-control {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.875rem;
    color: #374151;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-control:hover {
    border-color: #2563eb;
}

.chart-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chart-container {
    min-height: 400px;
    position: relative;
}

.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #9ca3af;
    font-size: 1rem;
}

/* ========== Insights Section ========== */
.insights-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    color: white;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.insights-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.insights-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.insight-placeholder {
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
}

/* ========== Botones en Insights ========== */
#ask-carlos-btn {
    background: white;
    color: #667eea;
    border: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

#ask-carlos-btn:hover {
    background: #f3f4f6;
    transform: scale(1.05);
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .kpis-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .kpi-value {
        font-size: 2rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .insights-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

/* ========== Animaciones ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card {
    animation: fadeInUp 0.5s ease-out;
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }
.kpi-card:nth-child(5) { animation-delay: 0.25s; }
.kpi-card:nth-child(6) { animation-delay: 0.3s; }

.chart-card {
    animation: fadeInUp 0.6s ease-out;
}

.insights-section {
    animation: fadeInUp 0.7s ease-out;
}

/* ========== Print Styles ========== */
@media print {
    .view-header,
    .filters-bar,
    .btn {
        display: none !important;
    }

    .kpi-card,
    .chart-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }

    .insights-section {
        background: white;
        color: black;
        border: 1px solid #e5e7eb;
    }
}

/* ========== Temporal Metrics Section ========== */
.temporal-metrics-section {
    margin: 2rem 0;
}

.temporal-metrics-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.temporal-metrics-section .section-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

/* Grid de 3 columnas para las tarjetas temporales */
.temporal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Tarjetas individuales */
.temporal-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.temporal-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.temporal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f3f4f6;
}

.temporal-icon {
    font-size: 2rem;
}

.temporal-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

/* Contenido de las tarjetas */
.temporal-content {
    min-height: 120px;
}

.temporal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: #9ca3af;
    font-size: 0.875rem;
}

.temporal-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: #ef4444;
    font-size: 0.875rem;
}

/* Stats dentro de las tarjetas */
.temporal-stat {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.temporal-stat:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1f2937;
}

.stat-value.growth-rate {
    color: #10b981;
}

/* Bar Chart Styles */
.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 1rem;
    min-height: 300px;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(to top, #f9fafb 0%, transparent 100%);
    border-radius: 8px;
}

.bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 60px;
}

.bar {
    position: relative;
    width: 100%;
    max-width: 80px;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 6px 6px 0 0;
    transition: all 0.3s ease;
    min-height: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0.5rem;
}

.bar:hover {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    transform: scaleY(1.05);
}

.bar-value {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.bar-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    white-space: nowrap;
}

/* Responsive para métricas temporales */
@media (max-width: 768px) {
    .temporal-grid {
        grid-template-columns: 1fr;
    }

    .temporal-metrics-section .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .bar-chart {
        padding: 1rem 0.5rem 0.5rem;
        gap: 0.5rem;
    }

    .bar-item {
        min-width: 40px;
    }

    .bar {
        max-width: 50px;
    }

    .bar-value {
        font-size: 0.625rem;
    }

    .bar-label {
        font-size: 0.625rem;
    }
}

/* Animaciones para las tarjetas temporales */
.temporal-card {
    animation: fadeInUp 0.5s ease-out;
}

.temporal-card:nth-child(1) { animation-delay: 0.1s; }
.temporal-card:nth-child(2) { animation-delay: 0.2s; }
.temporal-card:nth-child(3) { animation-delay: 0.3s; }

/* ========== Utilidades adicionales ========== */
.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-select,
.filter-input {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 0.875rem;
    color: #374151;
    background: white;
    transition: all 0.2s ease;
}

.filter-select:hover,
.filter-input:hover {
    border-color: #2563eb;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.hidden {
    display: none !important;
}

/* ========== View Header Overrides para Analytics ========== */
#view-analytics-dashboard .view-header {
    margin-bottom: 2rem;
}

#view-analytics-dashboard .view-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
}

#view-analytics-dashboard .view-actions {
    display: flex;
    gap: 0.75rem;
}
