/**
 * UNIFIED DASHBOARD - Complete Styling
 * Styles for the comprehensive dashboard showing ALL system metrics
 * Connected with: SystemIntegrationHub, All 20+ Modules
 */

/* =================================================================
   MAIN DASHBOARD CONTAINER
   ================================================================= */
#dashboard-container {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    direction: ltr;
}

.dashboard-header {
    margin-bottom: 30px;
}

.dashboard-header h1 {
    font-size: 28px;
    color: #1a202c;
    margin-bottom: 10px;
    font-weight: 700;
}

.dashboard-header .subtitle {
    color: #64748b;
    font-size: 14px;
}

.last-updated {
    display: inline-block;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    margin-top: 10px;
}

.last-updated i {
    margin-right: 6px;
    color: #10b981;
}

/* =================================================================
   DATA BREAKDOWN SECTION - 8 Main Metrics
   ================================================================= */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

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

.metric-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.metric-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
}

/* Icon colors for different metrics */
.metric-card-icon.quotes {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.metric-card-icon.customers {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.metric-card-icon.contacts {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.metric-card-icon.products {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.metric-card-icon.tasks {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.metric-card-icon.deals {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    color: white;
}

.metric-card-icon.partners {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
}

.metric-card-icon.mappings {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #333;
}

.metric-card-title {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.metric-card-value {
    font-size: 32px;
    font-weight: 700;
    color: #1a202c;
    margin: 8px 0;
}

.metric-card-change {
    font-size: 13px;
    color: #10b981;
    font-weight: 500;
}

.metric-card-change.negative {
    color: #ef4444;
}

.metric-card-change i {
    margin-right: 4px;
}

/* =================================================================
   BUSINESS METRICS SECTION - Financial Overview
   ================================================================= */
.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a202c;
    margin: 40px 0 20px 0;
    display: flex;
    align-items: center;
}

.section-title i {
    margin-right: 10px;
    color: #667eea;
}

.business-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.business-metric-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.business-metric-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.business-metric-label {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.business-metric-label i {
    margin-right: 8px;
    color: #667eea;
}

.business-metric-value {
    font-size: 36px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 8px;
}

.business-metric-value.success {
    color: #10b981;
}

.business-metric-value.warning {
    color: #f59e0b;
}

.business-metric-value.info {
    color: #3b82f6;
}

.business-metric-change {
    font-size: 13px;
    color: #64748b;
}

.business-metric-change .positive {
    color: #10b981;
    font-weight: 600;
}

.business-metric-change .negative {
    color: #ef4444;
    font-weight: 600;
}

/* =================================================================
   ADDITIONAL INSIGHTS SECTION - Partner Mapping, Tasks, etc.
   ================================================================= */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.insight-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.insight-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.insight-header i {
    font-size: 20px;
    margin-right: 10px;
    color: #667eea;
}

.insight-header span {
    font-size: 16px;
    font-weight: 700;
    color: #1a202c;
}

.insight-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.insight-row span {
    font-size: 14px;
    color: #64748b;
}

.insight-row strong {
    font-size: 18px;
    font-weight: 700;
    color: #1a202c;
}

.insight-row .badge {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.insight-row .badge.success {
    background: #d1fae5;
    color: #065f46;
}

.insight-row .badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.insight-row .badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

/* =================================================================
   CHARTS SECTION
   ================================================================= */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.chart-header {
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a202c;
    display: flex;
    align-items: center;
}

.chart-title i {
    margin-right: 10px;
    color: #667eea;
}

.chart-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

.chart-body {
    min-height: 250px;
    position: relative;
}

/* Bar Chart Styling */
.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 200px;
    padding: 20px 0;
}

.chart-bar {
    flex: 1;
    margin: 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-bar-fill {
    width: 100%;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.chart-bar-fill:hover {
    opacity: 0.8;
    transform: scaleY(1.05);
}

.chart-bar-value {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 700;
    color: #1a202c;
    white-space: nowrap;
}

.chart-bar-label {
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    text-align: center;
}

/* Line Chart Styling */
.chart-line {
    position: relative;
    height: 200px;
}

.chart-line svg {
    width: 100%;
    height: 100%;
}

.chart-line-path {
    fill: none;
    stroke: #667eea;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-line-area {
    fill: url(#lineGradient);
    opacity: 0.3;
}

.chart-line-point {
    fill: #667eea;
    stroke: white;
    stroke-width: 2;
}

.chart-line-point:hover {
    r: 6;
    fill: #764ba2;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #64748b;
}

.chart-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
}

/* =================================================================
   LOADING AND EMPTY STATES
   ================================================================= */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f1f5f9;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.empty-state i {
    font-size: 48px;
    color: #cbd5e1;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state .hint {
    font-size: 13px;
    color: #94a3b8;
}

/* =================================================================
   REFRESH INDICATOR
   ================================================================= */
.refresh-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.refresh-indicator.show {
    display: flex;
}

.refresh-indicator i {
    color: #10b981;
    animation: spin 1s linear infinite;
}

.refresh-indicator span {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */
@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    .business-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #dashboard-container {
        padding: 12px;
    }
    
    .dashboard-header h1 {
        font-size: 24px;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .metric-card {
        padding: 16px;
    }
    
    .metric-card-value {
        font-size: 24px;
    }
    
    .business-metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .section-title {
        font-size: 18px;
        margin: 30px 0 16px 0;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-card-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .metric-card-value {
        font-size: 20px;
    }
    
    .business-metric-value {
        font-size: 28px;
    }
    
    .chart-bars {
        height: 150px;
    }
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */
.text-success {
    color: #10b981 !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-danger {
    color: #ef4444 !important;
}

.text-info {
    color: #3b82f6 !important;
}

.text-muted {
    color: #64748b !important;
}

.bg-success {
    background-color: #d1fae5 !important;
}

.bg-warning {
    background-color: #fef3c7 !important;
}

.bg-danger {
    background-color: #fee2e2 !important;
}

.bg-info {
    background-color: #dbeafe !important;
}

/* =================================================================
   PRINT STYLES
   ================================================================= */
@media print {
    .refresh-indicator,
    .chart-bar-fill:hover,
    .business-metric-card:hover,
    .metric-card:hover {
        display: none !important;
        box-shadow: none !important;
        transform: none !important;
    }
    
    #dashboard-container {
        max-width: 100%;
    }
    
    .metric-card,
    .business-metric-card,
    .insight-card,
    .chart-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
