/* ============================================
   WAFEKA DIGITAL AGENCY - ANALYSIS DASHBOARD
   Customer Satisfaction Study 2023-2025
   ============================================ */

/* === IMPORTS & VARIABLES === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Color Palette - Professional Analytics */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #7c3aed;
    --accent: #06b6d4;
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Neutrals */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --bg-hover: #475569;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #475569;
    
    /* Chart Colors */
    --chart-1: #3b82f6;
    --chart-2: #10b981;
    --chart-3: #f59e0b;
    --chart-4: #ef4444;
    --chart-5: #8b5cf6;
    --chart-6: #06b6d4;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-danger: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    --gradient-info: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.5);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* === LAYOUT === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .container { padding: 1rem; }
}

/* === HEADER === */
.header {
    background: var(--gradient-primary);
    padding: 3rem 2rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    position: relative;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
}

.header .badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    margin-top: 1rem;
    position: relative;
}

/* === NAVIGATION === */
.nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.9rem;
}

.nav a:hover, .nav a.active {
    background: var(--primary);
    color: white;
}

/* === CARDS === */
.card {
    background: var(--bg-secondary);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* === KPI CARDS === */
.kpi-card {
    background: var(--bg-secondary);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.info::before { background: var(--info); }

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

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.kpi-card.success .kpi-value { color: var(--success); }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-card.danger .kpi-value { color: var(--danger); }
.kpi-card.info .kpi-value { color: var(--info); }

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

.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--danger); }
.kpi-change.neutral { color: var(--warning); }

/* === TABLES === */
.table-wrapper {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

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

thead {
    background: var(--bg-card);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Table Cell Variants */
.cell-positive { color: var(--success); font-weight: 600; }
.cell-negative { color: var(--danger); font-weight: 600; }
.cell-warning { color: var(--warning); font-weight: 600; }
.cell-highlight { background: var(--primary); color: white; font-weight: 600; border-radius: 0.25rem; padding: 0.25rem 0.5rem; }

/* === CORRELATION HEATMAP === */
.heatmap {
    display: grid;
    gap: 2px;
    padding: 1rem;
}

.heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    transition: var(--transition);
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
}

/* Correlation Colors */
.corr-1 { background: #1e3a5f; color: #93c5fd; }
.corr-2 { background: #1e40af; color: #bfdbfe; }
.corr-3 { background: #2563eb; color: white; }
.corr-4 { background: #3b82f6; color: white; }
.corr-5 { background: #64748b; color: white; }
.corr-6 { background: #f97316; color: white; }
.corr-7 { background: #ea580c; color: white; }
.corr-8 { background: #dc2626; color: white; }
.corr-9 { background: #991b1b; color: #fecaca; }

.heatmap-header {
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 4px;
}

/* === BAR CHARTS === */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bar-label {
    width: 120px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
}

.bar-container {
    flex: 1;
    height: 32px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.bar.primary { background: var(--gradient-primary); }
.bar.success { background: var(--gradient-success); }
.bar.warning { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
.bar.danger { background: var(--gradient-danger); }
.bar.info { background: var(--gradient-info); }

/* Horizontal Grouped Bar */
.bar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bar-group .bar {
    height: 20px;
}

/* === LINE CHARTS (CSS-based) === */
.line-chart {
    position: relative;
    height: 300px;
    padding: 2rem 3rem 3rem 4rem;
    background: var(--bg-card);
    border-radius: 0.75rem;
}

.line-chart-grid {
    position: absolute;
    inset: 2rem 3rem 3rem 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.grid-line {
    width: 100%;
    height: 1px;
    background: var(--border);
    position: relative;
}

.grid-line::before {
    content: attr(data-value);
    position: absolute;
    left: -3rem;
    top: -0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.line-chart-data {
    position: absolute;
    inset: 2rem 3rem 3rem 4rem;
}

.data-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-secondary);
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.data-point:hover {
    transform: translate(-50%, -50%) scale(1.5);
}

.data-point::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    transition: var(--transition);
}

.data-point:hover::after {
    opacity: 1;
}

.data-point.series-2 { background: var(--success); }
.data-point.series-3 { background: var(--warning); }

/* === PIE/DONUT CHARTS === */
.donut-chart {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.donut {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        var(--chart-1) 0deg,
        var(--chart-1) calc(var(--segment-1) * 3.6deg),
        var(--chart-2) calc(var(--segment-1) * 3.6deg),
        var(--chart-2) calc((var(--segment-1) + var(--segment-2)) * 3.6deg),
        var(--chart-3) calc((var(--segment-1) + var(--segment-2)) * 3.6deg),
        var(--chart-3) calc((var(--segment-1) + var(--segment-2) + var(--segment-3)) * 3.6deg),
        var(--chart-4) calc((var(--segment-1) + var(--segment-2) + var(--segment-3)) * 3.6deg),
        var(--chart-4) 360deg
    );
    position: relative;
}

.donut::before {
    content: '';
    position: absolute;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    background: var(--bg-secondary);
    border-radius: 50%;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-value {
    font-size: 2rem;
    font-weight: 800;
}

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

/* === GAUGE CHARTS === */
.gauge {
    position: relative;
    width: 200px;
    height: 120px;
    margin: 0 auto;
}

.gauge-bg {
    width: 200px;
    height: 100px;
    border-radius: 100px 100px 0 0;
    background: var(--bg-card);
    overflow: hidden;
    position: relative;
}

.gauge-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200px;
    height: 100px;
    border-radius: 100px 100px 0 0;
    background: var(--gradient-success);
    transform-origin: bottom center;
    transform: rotate(calc((1 - var(--value) / 100) * -180deg));
    transition: transform 1s ease-out;
}

.gauge-cover {
    position: absolute;
    bottom: 0;
    left: 20px;
    width: 160px;
    height: 80px;
    border-radius: 80px 80px 0 0;
    background: var(--bg-secondary);
}

.gauge-value {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: 800;
}

/* === SCATTER PLOT === */
.scatter-plot {
    position: relative;
    height: 300px;
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 2rem;
}

.scatter-point {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.8;
    cursor: pointer;
    transition: var(--transition);
    transform: translate(-50%, -50%);
}

.scatter-point:hover {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5);
}

.scatter-point.highlight {
    background: var(--danger);
    width: 20px;
    height: 20px;
}

/* === TREND LINE === */
.trend-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 0.75rem;
}

.trend-chart {
    flex: 1;
    height: 60px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.trend-bar {
    flex: 1;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    transition: var(--transition);
}

.trend-bar:hover {
    background: var(--primary-light);
}

.trend-info {
    text-align: right;
}

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

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

/* === BADGES & TAGS === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.success { background: var(--success-light); color: #065f46; }
.badge.warning { background: var(--warning-light); color: #92400e; }
.badge.danger { background: var(--danger-light); color: #991b1b; }
.badge.info { background: var(--info-light); color: #1e40af; }

/* === PROGRESS BARS === */
.progress {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.primary { background: var(--primary); }

/* === COMPARISON BOXES === */
.comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 0.75rem;
}

.comparison-item {
    text-align: center;
}

.comparison-value {
    font-size: 2rem;
    font-weight: 800;
}

.comparison-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.comparison-vs {
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 2rem;
}

/* === YEAR SELECTOR === */
.year-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.year-tab {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.year-tab:hover, .year-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* === LEGEND === */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem;
    justify-content: center;
}

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

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* === TOOLTIPS === */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* === INSIGHTS BOX === */
.insight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin: 1rem 0;
}

.insight-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.insight-text {
    opacity: 0.9;
    font-size: 0.95rem;
}

/* === STATS ROW === */
.stats-row {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* === FORMULA BOX === */
.formula {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    border-left: 4px solid var(--primary);
    margin: 1rem 0;
}

.formula-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-family: 'Inter', sans-serif;
}

.formula-content {
    font-size: 1.1rem;
    color: var(--accent);
}

/* === SECTION HEADERS === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade { animation: fadeIn 0.5s ease-out; }
.animate-slide { animation: slideIn 0.5s ease-out; }

/* Staggered animation */
.stagger > * {
    animation: fadeIn 0.5s ease-out backwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.1s; }
.stagger > *:nth-child(2) { animation-delay: 0.2s; }
.stagger > *:nth-child(3) { animation-delay: 0.3s; }
.stagger > *:nth-child(4) { animation-delay: 0.4s; }
.stagger > *:nth-child(5) { animation-delay: 0.5s; }

/* === PRINT STYLES === */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .card, .kpi-card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
    
    .nav {
        display: none;
    }
}
