/**
 * Dashboard Analytics Styles
 * PPG Refinish CRM v2.0
 * Version: 1.0
 */

/* ============================================
   DASHBOARD CONTAINER
   ============================================ */
.dashboard-container {
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================
   KPI CARDS SECTION
   ============================================ */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: white;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--kpi-color, #0066CC);
}

.kpi-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    border-color: var(--kpi-color, #0066CC);
}

.kpi-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
    background: linear-gradient(135deg, var(--kpi-color, #0066CC) 0%, var(--kpi-color-dark, #004a99) 100%);
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 2.75rem;
    font-weight: 900;
    color: #000000;
    line-height: 1.1;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.kpi-label {
    font-size: 1rem;
    color: #374151;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-change {
    font-size: 0.9375rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 24px;
}

.kpi-change.positive {
    color: #28A745;
    background: #D4EDDA;
}

.kpi-change.negative {
    color: #DC3545;
    background: #F8D7DA;
}

.kpi-change i {
    font-size: 11px;
}

/* KPI Color Variants */
.kpi-revenue {
    --kpi-color: #28A745;
    --kpi-color-dark: #1e7e34;
}

.kpi-customers {
    --kpi-color: #0066CC;
    --kpi-color-dark: #004a99;
}

.kpi-engagement {
    --kpi-color: #FFC107;
    --kpi-color-dark: #d39e00;
}

.kpi-activities {
    --kpi-color: #17A2B8;
    --kpi-color-dark: #117a8b;
}

/* ============================================
   CHARTS SECTION
   ============================================ */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.chart-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.chart-header {
    padding: 24px 28px;
    border-bottom: 2px solid #E9ECEF;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, #F8F9FA, #FFFFFF);
}

.chart-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-header i {
    color: #0066CC;
    font-size: 18px;
}

.chart-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6C757D;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #E9ECEF;
    color: #0066CC;
}

.btn-link {
    background: none;
    border: none;
    color: #0066CC;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-link:hover {
    background: #E7F3FF;
    text-decoration: underline;
}

.chart-body {
    padding: 28px;
    min-height: 320px;
    position: relative;
    background: #FAFBFC;
}

/* Chart size variants */
.chart-large {
    grid-column: span 2;
}

.chart-medium {
    grid-column: span 1;
}

.chart-body canvas {
    max-height: 350px;
}

/* ============================================
   TOP CUSTOMERS LIST
   ============================================ */
.top-customers-list {
    max-height: 400px;
    overflow-y: auto;
}

.customer-row {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #F1F3F5;
    transition: all 0.2s;
    cursor: pointer;
}

.customer-row:hover {
    background: #F8F9FA;
    padding-left: 8px;
    padding-right: 8px;
    border-radius: 6px;
}

.customer-row:last-child {
    border-bottom: none;
}

.customer-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066CC, #0052A3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.customer-rank.top3 {
    background: linear-gradient(135deg, #FFC107, #FF9800);
}

.customer-info {
    flex: 1;
    margin-left: 16px;
}

.customer-name {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 14px;
    margin-bottom: 2px;
}

.customer-meta {
    font-size: 12px;
    color: #6C757D;
}

.customer-value {
    font-size: 18px;
    font-weight: 700;
    color: #28A745;
    flex-shrink: 0;
}

.customer-score {
    margin-left: 16px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.customer-score.excellent {
    background: #D4EDDA;
    color: #28A745;
}

.customer-score.good {
    background: #FFF3CD;
    color: #856404;
}

.customer-score.at-risk {
    background: #F8D7DA;
    color: #DC3545;
}

/* ============================================
   AT-RISK CUSTOMERS SECTION
   ============================================ */
.alert-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    border-left: 5px solid #DC3545;
    transition: all 0.3s ease;
}

.alert-section:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.alert-header {
    padding: 24px 28px;
    background: linear-gradient(to bottom, #FFF5F5, #FFFFFF);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #FFEBEE;
}

.alert-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-header i {
    color: #DC3545;
    font-size: 1.25rem;
}

.alert-badge {
    background: linear-gradient(135deg, #DC3545, #b02a37);
    color: white;
    padding: 6px 16px;
    border-radius: 24px;
    font-size: 0.9375rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.alert-body {
    padding: 20px 28px;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: #FFF9E6;
    border-left: 3px solid #FFC107;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.alert-item:hover {
    background: #FFF3CD;
    transform: translateX(4px);
}

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

.alert-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFC107, #d39e00);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.alert-content {
    flex: 1;
}

.alert-customer {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 15px;
    margin-bottom: 6px;
}

.alert-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.alert-reason {
    font-size: 12px;
    color: #856404;
    background: white;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.alert-reason i {
    font-size: 10px;
}

.alert-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-alert-action {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-view {
    background: #0066CC;
    color: white;
}

.btn-view:hover {
    background: #0052A3;
}

.btn-contact {
    background: white;
    color: #0066CC;
    border: 1px solid #0066CC;
}

.btn-contact:hover {
    background: #E7F3FF;
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */
.loading-state,
.empty-state {
    padding: 40px;
    text-align: center;
    color: #6C757D;
}

.loading-state i {
    font-size: 24px;
    margin-bottom: 12px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state i {
    font-size: 48px;
    color: #CED4DA;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .kpi-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-row {
        grid-template-columns: 1fr;
    }
    
    .chart-large {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px;
    }
    
    .kpi-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .kpi-card {
        padding: 16px;
    }
    
    .kpi-icon {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
    
    .kpi-value {
        font-size: 24px;
    }
    
    .chart-header {
        padding: 16px;
    }
    
    .chart-body {
        padding: 16px;
        min-height: 250px;
    }
    
    .customer-row {
        flex-wrap: wrap;
    }
    
    .customer-value {
        width: 100%;
        text-align: left;
        margin-top: 8px;
        margin-left: 48px;
    }
    
    .alert-item {
        flex-direction: column;
    }
}

/* ============================================
   DATE FILTER STYLING
   ============================================ */
.date-filter {
    margin-right: 12px;
}

.form-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid #CED4DA;
    border-radius: 6px;
    font-size: 14px;
    color: #495057;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23495057' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    appearance: none;
    cursor: pointer;
    transition: all 0.2s;
}

.form-select:hover {
    border-color: #0066CC;
}

.form-select:focus {
    outline: none;
    border-color: #0066CC;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.top-customers-list::-webkit-scrollbar {
    width: 6px;
}

.top-customers-list::-webkit-scrollbar-track {
    background: #F8F9FA;
    border-radius: 3px;
}

.top-customers-list::-webkit-scrollbar-thumb {
    background: #CED4DA;
    border-radius: 3px;
}

.top-customers-list::-webkit-scrollbar-thumb:hover {
    background: #ADB5BD;
}

/* ============================================
   EMPTY STATE FOR CHARTS
   ============================================ */
.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #6C757D;
    text-align: center;
    padding: 40px 20px;
}

.chart-empty-state i {
    font-size: 64px;
    color: #DEE2E6;
    margin-bottom: 20px;
}

.chart-empty-state h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
    margin: 0 0 10px 0;
}

.chart-empty-state p {
    font-size: 0.9375rem;
    color: #6C757D;
    margin: 0;
    max-width: 300px;
}

/* ============================================
   ACTIVITY FEED ENHANCEMENTS
   ============================================ */
.recent-activities {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 24px;
    margin-bottom: 24px;
}

.recent-activities h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.recent-activities h3 i {
    color: #0066CC;
    font-size: 1.5rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    border: 1px solid #F1F3F5;
}

.activity-item:hover {
    background: #F8F9FA;
    border-color: #E9ECEF;
    transform: translateX(4px);
}

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

.activity-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.activity-icon.green {
    background: linear-gradient(135deg, #28A745 0%, #1e7e34 100%);
}

.activity-icon.blue {
    background: linear-gradient(135deg, #0066CC 0%, #004a99 100%);
}

.activity-icon.orange {
    background: linear-gradient(135deg, #FFC107 0%, #d39e00 100%);
}

.activity-icon.purple {
    background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.activity-description {
    font-size: 0.9375rem;
    color: #6C757D;
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.activity-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.875rem;
    color: #868E96;
}

.activity-meta i {
    margin-right: 4px;
}

/* ============================================
   HEADER/TOP BAR IMPROVEMENTS
   ============================================ */
.top-bar {
    padding: 1.25rem 1.5rem !important;
    margin-bottom: 1.5rem;
}

.top-bar-left h1 {
    font-size: 1.75rem !important;
    margin-bottom: 0.375rem;
}

.top-bar-left .page-description {
    font-size: 0.9375rem;
    color: #6C757D;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet and below (< 1024px) */
@media (max-width: 1024px) {
    .kpi-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-row {
        grid-template-columns: 1fr;
    }
    
    .chart-large,
    .chart-medium {
        grid-column: span 1;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px;
    }
    
    .kpi-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .kpi-card {
        padding: 20px;
    }
    
    .kpi-icon {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }
    
    .kpi-value {
        font-size: 2.25rem;
    }
    
    .kpi-label {
        font-size: 0.875rem;
    }
    
    .top-bar {
        padding: 1rem !important;
    }
    
    .top-bar-left h1 {
        font-size: 1.5rem !important;
    }
    
    .top-bar-right {
        flex-direction: column;
        width: 100%;
        gap: 12px;
    }
    
    .top-bar-right .date-filter,
    .top-bar-right button {
        width: 100%;
    }
    
    .chart-header h3 {
        font-size: 1rem;
    }
    
    .chart-body {
        padding: 16px;
        min-height: 250px;
    }
    
    .activity-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .activity-icon {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
    
    .activity-title {
        font-size: 1rem;
    }
    
    .activity-description {
        font-size: 0.875rem;
    }
}

/* Small mobile (< 480px) */
@media (max-width: 480px) {
    .kpi-value {
        font-size: 1.875rem;
    }
    
    .kpi-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    
    .chart-empty-state i {
        font-size: 48px;
    }
    
    .chart-empty-state h4 {
        font-size: 1.125rem;
    }
    
    .chart-empty-state p {
        font-size: 0.875rem;
    }
}
