/* ========================================
   Campaign Performance Dashboard - CSS
   World-Class Design System
======================================== */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color System */
    --primary-blue: #2563eb;
    --primary-dark: #1e40af;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --danger-red: #ef4444;
    --background-gray: #f8fafc;
    --card-white: #ffffff;
    --text-dark: #1e293b;
    --text-medium: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Gradients */
    --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-blue: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --gradient-green: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-yellow: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-red: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--background-gray);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* === DASHBOARD CONTAINER === */
.dashboard-container {
    max-width: 1920px;
    margin: 0 auto;
    min-height: 100vh;
}

/* === HEADER === */
.dashboard-header {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-meta {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    opacity: 0.95;
}

.date-display,
.timezone-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.last-updated {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.9;
}

.refresh-btn,
.auto-refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.refresh-btn:hover,
.auto-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.refresh-btn.spinning i {
    animation: spin 1s linear infinite;
}

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

/* === LOADING OVERLAY === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-overlay.hidden {
    display: none;
}

.spinner-container {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.spinner-container p {
    color: var(--text-medium);
    font-size: 1rem;
}

/* === ERROR MESSAGE === */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    z-index: 1001;
    text-align: center;
}

.error-message.hidden {
    display: none;
}

.error-message i {
    font-size: 3rem;
    color: var(--danger-red);
    margin-bottom: 1rem;
}

.error-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.error-content p {
    color: var(--text-medium);
    margin-bottom: 1.5rem;
}

.error-content button {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.error-content button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* === FILTER BAR === */
.filter-bar {
    background: white;
    padding: 1.5rem 2rem;
    margin: 2rem 2rem 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label i {
    color: var(--primary-blue);
}

.date-input,
.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.date-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

.export-btn {
    background: white;
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.export-btn:hover {
    background: var(--primary-blue);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* === KPI CARDS === */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 0 2rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    gap: 1.25rem;
    align-items: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.kpi-icon.status-icon.status-excellent {
    background: var(--gradient-green);
}

.kpi-icon.status-icon.status-good {
    background: var(--gradient-yellow);
}

.kpi-icon.status-icon.status-poor {
    background: var(--gradient-red);
}

.kpi-content {
    flex: 1;
}

.kpi-content h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-medium);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* === CONTENT GRID === */
.content-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    padding: 0 2rem 2rem;
}

.content-left,
.content-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* === CHART CARDS === */
.chart-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.chart-card:hover {
    box-shadow: var(--shadow-lg);
}

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

.chart-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chart-header h2 i {
    color: var(--primary-blue);
}

.chart-subtitle {
    font-size: 0.875rem;
    color: var(--text-medium);
    font-weight: 400;
}

.chart-container {
    position: relative;
    width: 100%;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

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

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-label {
    color: var(--text-medium);
}

.legend-value {
    color: var(--text-dark);
    font-weight: 600;
}

/* === DOMAIN LIST === */
.domain-list,
.country-list,
.error-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.domain-item,
.country-item {
    background: var(--background-gray);
    padding: 1rem;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

.domain-item:hover,
.country-item:hover {
    background: #e2e8f0;
    transform: translateX(3px);
}

.domain-header,
.country-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.domain-name,
.country-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1rem;
}

.domain-stats,
.country-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.stat-value {
    color: var(--text-dark);
    font-weight: 600;
}

.domain-bar,
.country-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 1rem;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 1rem;
    transition: width 0.5s ease;
}

.bar-fill.excellent {
    background: var(--gradient-green);
}

.bar-fill.good {
    background: var(--gradient-yellow);
}

.bar-fill.poor {
    background: var(--gradient-red);
}

/* === ERROR LIST === */
.error-item {
    background: #fef2f2;
    border-left: 4px solid var(--danger-red);
    padding: 1rem;
    border-radius: 0.5rem;
}

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

.error-count {
    background: var(--danger-red);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.error-message-text {
    color: var(--text-dark);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* === METRICS LIST === */
.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--background-gray);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.metric-row:hover {
    background: #e2e8f0;
}

.metric-label {
    color: var(--text-medium);
    font-size: 0.9rem;
}

.metric-value {
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.95rem;
}

/* === DATA TABLE === */
.table-container {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: var(--background-gray);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.data-table th.sortable:hover {
    background: #e2e8f0;
}

.data-table th.sortable i {
    margin-left: 0.5rem;
    color: var(--text-light);
    font-size: 0.75rem;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.data-table tbody tr:hover {
    background: var(--background-gray);
}

.data-table td {
    padding: 1rem;
    color: var(--text-dark);
}

.data-table td.cell-excellent {
    color: var(--success-green);
    font-weight: 600;
}

.data-table td.cell-good {
    color: var(--warning-yellow);
    font-weight: 600;
}

.data-table td.cell-poor {
    color: var(--danger-red);
    font-weight: 600;
}

.empty-state,
.empty-state-small {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state i,
.empty-state-small i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-small {
    padding: 2rem 1rem;
}

.empty-state-small i {
    font-size: 2rem;
}

.empty-state p,
.empty-state-small p {
    margin: 0;
}

/* === FOOTER === */
.dashboard-footer {
    background: white;
    padding: 2rem;
    margin: 2rem 2rem 0;
    border-radius: 1rem 1rem 0 0;
    text-align: center;
    color: var(--text-medium);
    font-size: 0.875rem;
    border-top: 2px solid var(--border-color);
}

.footer-links {
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-links a:hover {
    text-decoration: underline;
}

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

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-bar {
        padding: 1rem;
        margin: 1rem;
    }
    
    .filter-actions {
        width: 100%;
        margin-left: 0;
    }
    
    .export-btn {
        flex: 1;
        justify-content: center;
    }
    
    .kpi-section {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }
    
    .content-grid {
        padding: 0 1rem 1rem;
        gap: 1rem;
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .kpi-card {
        flex-direction: column;
        text-align: center;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* === REFRESH STATUS NOTIFICATION === */
.refresh-status {
    position: fixed;
    top: 80px;
    right: 2rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-dark);
    min-width: 280px;
}

.refresh-status.success {
    background: rgba(16, 185, 129, 0.95);
    color: white;
    border-color: var(--success-green);
}

.refresh-status.error {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border-color: var(--danger-red);
}

.refresh-status i {
    font-size: 1.25rem;
}

.refresh-status.success i {
    color: white;
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* === PRINT STYLES === */
@media print {
    .dashboard-header,
    .filter-bar,
    .dashboard-footer,
    .refresh-btn,
    .auto-refresh-btn,
    .export-btn,
    .refresh-status {
        display: none !important;
    }
    
    .dashboard-container {
        background: white;
    }
    
    .chart-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}