/*
 * Unified Dashboard Stylesheet
 * Bold tech visual system for AI-powered dashboard
 */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Core palette */
    --color-ink: #0a0f1f;
    --color-surface: #0f172a;
    --color-panel: #111827;
    --color-panel-2: #0b1222;
    --color-border: rgba(148, 163, 184, 0.15);
    --color-glow: rgba(34, 211, 238, 0.35);

    --color-primary: #22d3ee;
    --color-primary-2: #3b82f6;
    --color-secondary: #a3a3ff;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #38bdf8;

    /* Sentiment */
    --color-positive: #22c55e;
    --color-negative: #ef4444;
    --color-neutral: #94a3b8;

    /* Platform */
    --color-youtube: #ff3b30;
    --color-twitter: #1da1f2;
    --color-instagram: #ff5da2;

    /* Party */
    --color-tdp: #ffe066;
    --color-ysrcp: #60a5fa;
    --color-bjp: #ffb44c;
    --color-congress: #94a3b8;
    --color-jsp: #c084fc;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Radius */
    --radius-sm: 0.35rem;
    --radius-md: 0.6rem;
    --radius-lg: 0.9rem;
    --radius-xl: 1.25rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 25px 45px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 24px rgba(34, 211, 238, 0.25);

    /* Fonts */
    --font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-family-display: 'Space Grotesk', 'IBM Plex Sans', system-ui, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Transitions */
    --transition-fast: 140ms ease;
    --transition-base: 260ms ease;
    --transition-slow: 520ms ease;

    /* AI Gradient System */
    --gradient-ai-primary: linear-gradient(135deg, #22d3ee 0%, #3b82f6 50%, #a855f7 100%);
    --gradient-ai-secondary: linear-gradient(90deg, #22d3ee 0%, #3b82f6 100%);

    /* Sentiment Gradients */
    --gradient-positive: linear-gradient(135deg, #22c55e 0%, #10b981 100%);
    --gradient-negative: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-neutral: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);

    /* Surface Gradients */
    --gradient-surface: linear-gradient(135deg, rgba(17, 24, 39, 0.95) 0%, rgba(11, 18, 34, 0.92) 100%);
    --gradient-surface-hover: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(17, 24, 39, 0.92) 100%);

    /* Glow Effects */
    --glow-ai: 0 0 30px rgba(34, 211, 238, 0.4), 0 0 60px rgba(59, 130, 246, 0.2);
    --glow-success: 0 0 20px rgba(34, 197, 94, 0.4);
    --glow-warning: 0 0 20px rgba(245, 158, 11, 0.4);
    --glow-danger: 0 0 20px rgba(239, 68, 68, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: #e2e8f0;
    background: radial-gradient(circle at 10% 10%, rgba(59, 130, 246, 0.25) 0%, rgba(10, 15, 31, 0.9) 35%),
        radial-gradient(circle at 90% 20%, rgba(34, 211, 238, 0.2) 0%, rgba(10, 15, 31, 0.9) 45%),
        linear-gradient(160deg, #05070f 0%, #0a0f1f 45%, #070b18 100%);
    min-height: 100vh;
    line-height: 1.6;
}

.dashboard-grid-layer {
    position: fixed;
    inset: 0;
    background-image: repeating-linear-gradient(0deg, rgba(59, 130, 246, 0.08) 0, rgba(59, 130, 246, 0.08) 1px, transparent 1px, transparent 24px),
        repeating-linear-gradient(90deg, rgba(14, 165, 233, 0.06) 0, rgba(14, 165, 233, 0.06) 1px, transparent 1px, transparent 24px);
    opacity: 0.3;
    pointer-events: none;
    mix-blend-mode: screen;
    z-index: -1;
}

.dashboard-page-shell {
    position: relative;
    min-height: 100vh;
    padding-bottom: var(--spacing-xl);
    display: flex;
    flex-direction: column;
}

/* Global loader */
.global-loader {
    background-color: rgba(5, 7, 15, 0.85);
    backdrop-filter: blur(8px);
}

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--color-primary);
}

/* Header */
.dashboard-header {
    flex-shrink: 0;
    background: linear-gradient(120deg, rgba(15, 23, 42, 0.95), rgba(10, 15, 31, 0.9));
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    padding-top: var(--spacing-md, 1rem);
    padding-bottom: var(--spacing-md, 1rem);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md, 1rem);
}

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

.dashboard-logo {
    height: 40px;
    width: auto;
    display: block;
    object-fit: contain;
}

.dashboard-title {
    font-family: var(--font-family-display);
    font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem);
    letter-spacing: -0.02em;
}

.dashboard-subtitle {
    font-size: var(--font-size-sm);
    color: rgba(226, 232, 240, 0.65);
    margin-top: 0.2rem;
    font-weight: 500;
}

.data-freshness {
    color: rgba(226, 232, 240, 0.7);
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.header-actions .btn-primary,
.header-actions .btn-secondary {
    box-shadow: var(--shadow-sm);
}

.header-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: rgba(226, 232, 240, 0.7);
}

.ai-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #e2e8f0;
    font-weight: 600;
}

.ai-status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 1.6s infinite;
}

.header-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-status span {
    font-size: var(--font-size-xs);
    letter-spacing: 0.2em;
    color: rgba(226, 232, 240, 0.6);
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Filter bar: top right under navigation */
.filter-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: linear-gradient(120deg, rgba(15, 23, 42, 0.9), rgba(10, 15, 31, 0.85));
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    backdrop-filter: blur(8px);
}

/* Sticky Filter Bar */
.filter-bar-sticky {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(120deg, rgba(15, 23, 42, 0.95), rgba(10, 15, 31, 0.92));
    backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-base);
}

.filter-bar-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

/* Filters + Presets toolbar (conventional single row) */
.filter-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    width: 100%;
}

.filter-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-primary .filter-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: rgba(226, 232, 240, 0.9);
    margin: 0;
    white-space: nowrap;
}

.filter-primary .filter-select {
    min-width: 140px;
    max-width: 200px;
    padding: 0.5rem 0.75rem;
    font-size: var(--font-size-sm);
}

.filter-toolbar-divider {
    width: 1px;
    height: 1.5rem;
    background: rgba(148, 163, 184, 0.25);
    flex-shrink: 0;
}

.filter-presets-inline {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.filter-presets-inline .filter-section-label {
    margin: 0;
    flex-shrink: 0;
}

.filter-presets-inline .filter-presets-buttons {
.filter-clear-inline {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: rgba(148, 163, 184, 0.95);
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.filter-clear-inline:hover {
    color: rgba(226, 232, 240, 0.95);
    border-color: rgba(148, 163, 184, 0.5);
    background: rgba(148, 163, 184, 0.08);
}

    flex: 0 1 auto;
}

/* Quick Filters Section (legacy / advanced usage) */
.filter-quick-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.filter-section-label {
    font-family: var(--font-family-display);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: rgba(226, 232, 240, 0.8);
    margin: 0;
    flex-shrink: 0;
}

.filter-quick-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    flex: 1;
}

.filter-control-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.filter-control-inline .filter-label {
    font-size: var(--font-size-xs);
    white-space: nowrap;
    margin: 0;
}

.filter-control-inline .filter-select,
.filter-control-inline .filter-input {
    min-width: 120px;
    max-width: 180px;
    padding: 0.4rem 0.7rem;
    font-size: var(--font-size-sm);
}

/* Advanced Filters Toggle */
.filter-advanced-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.4rem 0.9rem;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    color: #e2e8f0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-advanced-toggle:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
}

.filter-advanced-toggle .toggle-chevron {
    transition: transform var(--transition-fast);
}

.filter-advanced-toggle.expanded .toggle-chevron {
    transform: rotate(180deg);
}

/* Advanced Filters Section */
.filter-advanced-section {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height var(--transition-base), opacity var(--transition-base);
}

.filter-advanced-section.expanded {
    max-height: 600px;
    opacity: 1;
}

.filter-advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(11, 18, 34, 0.6);
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.filter-control-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.filter-control-grid .filter-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: rgba(226, 232, 240, 0.8);
}

/* Filter Actions Bar */
.filter-actions-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

.btn-compact {
    padding: 0.4rem 1rem;
    font-size: var(--font-size-sm);
}

/* Active Filters Bar */
.active-filters-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
    padding: var(--spacing-sm);
    background: rgba(11, 18, 34, 0.4);
    border-radius: var(--radius-md);
    min-height: 36px;
}

.active-filters-bar:empty {
    display: none;
}

/* Filter Presets Section */
.filter-presets-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    padding: var(--spacing-sm) 0;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.filter-presets-buttons {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
    flex: 1;
}

/* Preset Button Base Styles */
.preset-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: var(--radius-md);
    color: #e2e8f0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.preset-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(34, 211, 238, 0.15), rgba(59, 130, 246, 0.15));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.preset-btn:hover::before {
    opacity: 1;
}

.preset-btn:hover {
    border-color: rgba(34, 211, 238, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.2);
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.preset-icon {
    font-size: 1rem;
    line-height: 1;
}

.preset-text {
    position: relative;
    z-index: 1;
}

/* AI Recommended Preset - Special Styling */
.preset-btn-ai {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(59, 130, 246, 0.15));
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.preset-btn-ai::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(
        45deg,
        #22d3ee,
        #3b82f6,
        #a855f7,
        #22d3ee
    );
    background-size: 300% 300%;
    animation: gradientShift 3s ease infinite;
    z-index: -1;
    border-radius: inherit;
}

.preset-btn-ai::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.95));
    border-radius: calc(var(--radius-md) - 2px);
    z-index: 0;
}

.preset-btn-ai .preset-icon,
.preset-btn-ai .preset-text,
.preset-btn-ai .preset-badge {
    position: relative;
    z-index: 1;
}

.preset-btn-ai:hover {
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.4), 0 0 60px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px) scale(1.02);
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.preset-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.4rem;
    background: linear-gradient(120deg, #22d3ee, #3b82f6);
    color: #0b1222;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Preset Loading State */
.preset-btn.preset-loading {
    pointer-events: none;
}

.preset-btn.preset-loading .preset-icon {
    animation: spin 1s linear infinite;
}

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

/* Preset Applied State */
.preset-btn.preset-applied {
    background: linear-gradient(120deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.2));
    border-color: var(--color-success);
}

.preset-btn.preset-applied::before {
    opacity: 1;
    background: linear-gradient(120deg, rgba(34, 197, 94, 0.3), rgba(16, 185, 129, 0.3));
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-md);
    color: #e2e8f0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--transition-base);
}

.toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast.toast-error {
    border-left: 4px solid var(--color-danger);
}

.toast.toast-info {
    border-left: 4px solid var(--color-info);
}

/* Responsive Preset Buttons */
@media (max-width: 1024px) {
    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-toolbar-divider {
        width: 100%;
        height: 1px;
    }

    .filter-presets-inline {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-presets-inline .filter-presets-buttons {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .filter-presets-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .preset-btn {
        width: 100%;
        justify-content: center;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

/* AI Insights Hero Section */
.ai-insights-hero {
    flex-shrink: 0;
    position: relative;
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(11, 18, 34, 0.92));
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    overflow: hidden;
}

.ai-insights-hero::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(
        45deg,
        #22d3ee,
        #3b82f6,
        #a855f7,
        #22d3ee
    );
    background-size: 300% 300%;
    animation: gradientShift 3s ease infinite;
    z-index: 0;
    opacity: 0.3;
    filter: blur(20px);
}

.ai-insights-container {
    position: relative;
    z-index: 1;
    max-width: 1800px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-lg);
}

.ai-insights-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
}

.ai-insights-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-family: var(--font-family-display);
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.ai-icon {
    font-size: 1.5rem;
    animation: pulse 2s infinite;
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #22c55e;
}

.live-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 1.5s infinite;
}

.ai-insights-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: rgba(226, 232, 240, 0.7);
}

.ai-insights-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    color: #e2e8f0;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ai-insights-refresh-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
    transform: rotate(90deg);
}

.ai-insights-refresh-btn.refreshing {
    animation: spin 1s linear infinite;
    pointer-events: none;
}

.ai-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
}

.ai-insight-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(17, 24, 39, 0.9));
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    overflow: hidden;
}

.ai-insight-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(34, 211, 238, 0.1), transparent 60%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.ai-insight-card:hover::before {
    opacity: 1;
}

.ai-insight-card:hover {
    border-color: rgba(34, 211, 238, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(34, 211, 238, 0.15);
}

.ai-insight-card.updating {
    animation: pulseCard 1s ease-in-out;
}

@keyframes pulseCard {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.insight-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: var(--radius-md);
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.trending-icon {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
}

.sentiment-icon {
    background: rgba(34, 211, 238, 0.15);
    border-color: rgba(34, 211, 238, 0.3);
}

.prediction-icon {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
}

.alert-icon {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite;
}

.insight-content {
    flex: 1;
    min-width: 0;
}

.insight-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: rgba(226, 232, 240, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.insight-value {
    font-family: var(--font-family-display);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.insight-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: rgba(34, 211, 238, 0.15);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #22d3ee;
}

.meta-badge.positive {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.meta-badge.negative {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.meta-badge.high-confidence {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
    color: #a855f7;
}

.meta-badge.critical {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
    animation: pulse 1.5s infinite;
}

.meta-text {
    font-size: var(--font-size-xs);
    color: rgba(226, 232, 240, 0.6);
}

.ai-insights-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    background: rgba(11, 18, 34, 0.9);
    backdrop-filter: blur(8px);
    z-index: 10;
    font-size: var(--font-size-sm);
    color: rgba(226, 232, 240, 0.8);
}

.loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive AI Insights */
@media (max-width: 1024px) {
    .ai-insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .ai-insights-container {
        padding: var(--spacing-md);
    }
    
    .ai-insights-grid {
        grid-template-columns: 1fr;
    }
    
    .ai-insights-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
}

.platform-pills {
    display: inline-flex;
    gap: var(--spacing-xs);
}

.platform-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-xs);
}

.platform-pill input[type="checkbox"] {
    display: none;
}

.platform-pill:has(input:checked) {
    background: linear-gradient(120deg, rgba(34, 211, 238, 0.2), rgba(59, 130, 246, 0.2));
    border-color: var(--color-primary);
}

.platform-pill:hover {
    border-color: var(--color-primary);
    transform: translateY(-1px);
}

.pill-icon {
    font-size: 0.9rem;
}

.pill-text {
    font-weight: 600;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.3rem 0.7rem;
    background: linear-gradient(120deg, #22d3ee 0%, #3b82f6 100%);
    color: #0b1222;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    animation: slideInChip 0.3s ease-out;
}

@keyframes slideInChip {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.filter-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-chip-remove:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: scale(1.1);
}

.filter-chip-remove svg {
    width: 10px;
    height: 10px;
}

.filter-panel-title {
    margin: 0;
    margin-right: var(--spacing-sm);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.filter-group {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.filter-group .filter-label {
    white-space: nowrap;
    font-size: var(--font-size-xs);
    margin: 0;
}

.filter-group .filter-select,
.filter-group .filter-input {
    min-width: 0;
    max-width: 140px;
    padding: 0.35rem 0.6rem;
    font-size: var(--font-size-sm);
}

.filter-group .filter-slider {
    width: 80px;
}

.filter-actions {
    display: inline-flex;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.filter-actions .btn-full {
    padding: 0.35rem 0.75rem;
    font-size: var(--font-size-sm);
}

.platform-checkboxes,
.sentiment-radio {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.platform-checkboxes .checkbox-label,
.sentiment-radio .radio-label {
    font-size: var(--font-size-xs);
    margin: 0;
}

.active-filters-section {
    width: 100%;
    flex-basis: 100%;
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.active-filters-section .active-filters-title {
    font-size: var(--font-size-xs);
    margin-bottom: var(--spacing-xs);
}

/* Modern multiselect in filter bar: compact */
.filter-group .modern-multiselect {
    min-width: 120px;
    max-width: 180px;
}

/* Layout: confine tab content to viewport so each tab scrolls within its area */
.dashboard-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
}

/* 12-Column CSS Grid System */
.dashboard-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: var(--spacing-xl);
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
}

.tabs-container {
    flex-shrink: 0;
}

/* Only the active tab is visible; its content scrolls within the remaining viewport */
.tab-content {
    display: none;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--spacing-lg);
    flex: 1;
    min-height: 0;
}

.tab-content.active {
    display: grid;
}

.tab-content > * {
    grid-column: 1 / -1;
}

/* Charts Grid - Default 2-column layout */
.charts-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--spacing-lg);
}

/* Grid Column Utilities */
.chart-card-primary {
    grid-column: 1 / -1; /* Full width */
    min-height: 400px;
}

.chart-card-half {
    grid-column: span 6; /* Half width */
    min-height: 350px;
}

.chart-card-third {
    grid-column: span 4; /* Third width */
    min-height: 320px;
}

.chart-card-two-thirds {
    grid-column: span 8;
    min-height: 350px;
}

/* Default chart card spans 6 columns (half) */
.charts-grid > .chart-card:not([class*="chart-card-"]) {
    grid-column: span 6;
}

/* Wide charts span full width */
.chart-wide {
    grid-column: 1 / -1;
}

/* KPI Cards Responsive Grid */
.kpi-cards-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.filter-panel-title,
.filter-label {
    color: #e2e8f0;
}

.filter-input,
.filter-select,
.control-select,
.control-input {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    text-align: center;
}

.filter-input::placeholder,
.control-input::placeholder {
    color: rgba(226, 232, 240, 0.5);
}

.filter-input:focus,
.filter-select:focus,
.control-select:focus,
.control-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

.checkbox-label,
.radio-label {
    color: #cbd5f5;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    border-radius: var(--radius-md);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(120deg, #22d3ee 0%, #3b82f6 100%);
    color: #0b1222;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.btn-secondary:hover {
    background: rgba(30, 41, 59, 0.95);
}

/* Enhanced Button Interactions */
.btn-primary,
.btn-secondary,
.preset-btn,
.filter-apply-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary::before,
.preset-btn.ai-recommended::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before,
.preset-btn.ai-recommended:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.95);
}

/* Ripple Effect */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Modern Pill-Style Tabs */
.tabs-container {
    display: inline-flex;
    align-self: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-full);
    padding: 4px;
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.15);
    gap: 0;
    margin-bottom: var(--spacing-xl);
}

.tabs-container::before {
    content: '';
    position: absolute;
    height: calc(100% - 8px);
    background: var(--gradient-ai-secondary);
    border-radius: var(--radius-full);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
    /* Position will be set dynamically via JavaScript */
}

.tab-indicator {
    position: absolute;
    height: calc(100% - 8px);
    background: var(--gradient-ai-secondary);
    border-radius: var(--radius-full);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
    top: 4px;
    left: 4px;
}

.tab-button {
    position: relative;
    overflow: hidden;
    z-index: 1;
    padding: 0.6rem 1.2rem;
    border: none;
    background: transparent;
    color: rgba(226, 232, 240, 0.6);
    font-family: var(--font-family-display);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    color: #e2e8f0;
}

.tab-button.active {
    color: #0b1222;
    font-weight: 600;
}

/* Responsive Tabs */
@media (max-width: 1024px) {
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tabs-container::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 768px) {
    .tab-button {
        padding: 0.5rem 1rem;
        font-size: var(--font-size-xs);
    }
}

/* KPI Cards */
.kpi-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.kpi-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(15, 23, 42, 0.85));
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-left: 4px solid var(--color-primary);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: slideInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.kpi-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    z-index: -1;
    background: linear-gradient(135deg, #22d3ee, #3b82f6, #a855f7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.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:hover {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px) saturate(180%);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(34, 211, 238, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card:hover::before {
    opacity: 0.3;
}

.kpi-card-highlight {
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.2);
}

.kpi-icon {
    font-size: 2rem;
    opacity: 0.8;
    margin-bottom: var(--spacing-xs);
}

.kpi-content {
    flex: 1;
}

.kpi-label {
    color: rgba(148, 163, 184, 0.8);
}

.kpi-value {
    color: #f8fafc;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    margin-top: var(--spacing-xs);
}

.trend-indicator {
    font-weight: 600;
    text-shadow: 0 0 8px currentColor;
}

.trend-indicator.positive {
    color: #22c55e;
    animation: pulse 2s ease-in-out infinite;
}

.trend-indicator.negative {
    color: #ef4444;
    animation: pulse 2s ease-in-out infinite;
}

.trend-indicator.neutral {
    color: #94a3b8;
}

.trend-period {
    color: rgba(148, 163, 184, 0.6);
    font-size: var(--font-size-xs);
}

.kpi-sparkline-container {
    height: 40px;
    margin-top: var(--spacing-sm);
    position: relative;
}

.kpi-sparkline-container canvas {
    width: 100%;
    height: 100%;
}

.kpi-sparkline-loading,
.kpi-sparkline-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted, #666);
}

.kpi-sparkline-error {
    color: var(--error-color, #c00);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (min-width: 1920px) {
    .kpi-cards-row {
        grid-template-columns: repeat(6, 1fr);
        max-width: 1800px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (min-width: 1024px) and (max-width: 1919px) {
    .kpi-cards-row {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .kpi-cards-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .kpi-card {
        min-height: 180px;
    }
}

@media (max-width: 767px) {
    .kpi-cards-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    .kpi-card {
        min-height: 160px;
    }
    .kpi-sparkline-container {
        height: 30px;
    }
}

/* Cards */
.chart-card,
.comparison-card,
.party-comparison-card,
.issue-card,
.detection-params-card,
.speech-input-details,
.detected-issue-card,
.report-item {
    position: relative;
    background: var(--gradient-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInUp 0.5s ease-out;
}

.chart-card:hover,
.comparison-card:hover,
.party-comparison-card:hover,
.issue-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(34, 211, 238, 0.2);
    background: var(--gradient-surface-hover);
}

.chart-card::after,
.issue-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--gradient-ai-secondary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.chart-card:hover::after,
.issue-card:hover::after {
    opacity: 0.15;
}

.chart-title,
.section-header h2,
.filter-panel-title {
    font-family: var(--font-family-display);
    color: #f8fafc;
}

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

.chart-container canvas {
    cursor: crosshair;
}

.chart-container canvas:active {
    cursor: grabbing;
}

/* Reset Zoom Button */
.reset-zoom-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.4rem 0.8rem;
    background: rgba(34, 211, 238, 0.2);
    border: 1px solid rgba(34, 211, 238, 0.4);
    border-radius: var(--radius-md);
    color: #22d3ee;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.reset-zoom-btn:hover {
    background: rgba(34, 211, 238, 0.3);
    border-color: rgba(34, 211, 238, 0.6);
    transform: translateY(-1px);
}

.reset-zoom-btn:active {
    transform: translateY(0);
}

/* Drill-down cursor hint */
.chart-card[data-drilldown="true"] canvas {
    cursor: pointer;
}

.chart-card[data-drilldown="true"]:hover::after {
    content: '💡 Click to filter';
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 0.3rem 0.6rem;
    background: rgba(34, 211, 238, 0.9);
    color: #0b1222;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    pointer-events: none;
    animation: fadeIn 0.3s ease;
}

/* Keyword sentiment tiles */
/* AI-Powered Section Styling */
.tab-content[data-tab="issue-discovery"],
.tab-content[data-tab="advanced-analytics"] {
    position: relative;
}

.tab-content[data-tab="advanced-analytics"] .section-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Animated Gradient Border for Election Prediction */
.chart-card.ai-powered-section {
    position: relative;
    background: var(--gradient-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    overflow: visible;
}

.chart-card.ai-powered-section::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(
        45deg,
        #22d3ee,
        #3b82f6,
        #a855f7,
        #22d3ee
    );
    background-size: 300% 300%;
    animation: gradientShift 3s ease infinite;
    z-index: -1;
    opacity: 0.6;
}

.chart-card.ai-powered-section:hover::before {
    opacity: 1;
    box-shadow: var(--glow-ai);
}

/* AI Election Prediction: party highlights side by side, centered to chart */
.party-highlights-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: var(--spacing-xl, 32px);
    margin-top: var(--spacing-lg, 24px);
    padding: 0 var(--spacing-lg);
}

.party-highlights-row .party-highlights-section {
    flex: 0 1 auto;
    min-width: 280px;
    max-width: 400px;
}

.party-highlights-section h4 {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.party-highlights-section table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.party-highlights-section table th,
.party-highlights-section table td {
    text-align: center;
    padding: 10px 12px;
}

.party-highlights-section table th {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid rgba(34, 211, 238, 0.3);
}

.party-highlights-section table td {
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.party-highlights-section table tr:hover td {
    background: rgba(30, 41, 59, 0.8);
    transition: background 0.2s ease;
}

.party-highlights-section table tbody tr:first-child td {
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

/* Issue Discovery Section Enhancement */
.detection-params-card,
.detected-issue-card {
    position: relative;
    background: var(--gradient-surface);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.detection-params-card::before,
.detected-issue-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--gradient-ai-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.detection-params-card:hover::before,
.detected-issue-card:hover::before {
    opacity: 0.3;
}

/* AI Badge for AI-Powered Features */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--gradient-ai-primary);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #0b1222;
    animation: pulse 2s infinite;
}

.keyword-sentiment-tile,
.issue-sentiment-tile {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(11, 18, 34, 0.9));
    border: 1px solid rgba(148, 163, 184, 0.15);
    box-shadow: var(--shadow-md);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.issue-sentiment-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(148, 163, 184, 0.3);
}

.issue-sentiment-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Scrollbar styling for issue sentiment tiles */
.issue-sentiment-tiles-grid::-webkit-scrollbar {
    width: 8px;
}

.issue-sentiment-tiles-grid::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 4px;
}

.issue-sentiment-tiles-grid::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
}

.issue-sentiment-tiles-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.issue-sentiment-tile .tile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
}

.issue-sentiment-tile .tile-title {
    font-size: 18px;
    font-weight: 600;
    color: #F3F4F6;
    margin: 0;
    flex: 1;
}

.keyword-badge,
.meta-date,
.meta-leader,
.meta-party {
    background: rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
}

.keyword-sentiment-label {
    background: rgba(34, 211, 238, 0.2);
    color: #bae6fd;
}

/* Tables */
.table-container {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.data-table thead {
    background: rgba(11, 18, 34, 0.98);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.data-table th {
    color: #e2e8f0;
    background-color: transparent;
}

.data-table td {
    color: rgba(226, 232, 240, 0.9);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.7);
}

.data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.12);
}

/* AC Author Insights tab: center section header and filters */
.tab-content[data-tab="ac-authors"] .section-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tab-content[data-tab="ac-authors"] .ac-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.tab-content[data-tab="ac-authors"] .kpi-cards-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.tab-content[data-tab="ac-authors"] .kpi-cards-row .kpi-card {
    min-width: 200px;
    max-width: 280px;
    flex: 1 1 240px;
}

/* Political issues grid (AC Authors) */
.political-issues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-lg);
    padding: var(--spacing-md) 0;
}

.political-issue-tile {
    background: var(--gradient-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInUp 0.5s ease-out;
}

.political-issue-tile:hover {
    transform: translateY(-4px);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(34, 211, 238, 0.2);
}

.political-issue-tile .tile-issue-name {
    font-family: var(--font-family-display);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: #f8fafc;
    margin: var(--spacing-sm) 0;
}

.political-issue-tile .tile-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin: var(--spacing-xs) 0;
}

.political-issue-tile .tile-sentiment {
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin: var(--spacing-xs) 0;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-md);
    display: inline-block;
}

.political-issue-tile .tile-sentiment.sentiment-positive {
    color: #86efac;
    background: rgba(34, 197, 94, 0.2);
}

.political-issue-tile .tile-sentiment.sentiment-negative {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.2);
}

.political-issue-tile .tile-sentiment.sentiment-neutral {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.2);
}

.political-issue-tile .tile-meta-small {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

.confidence-bar-track {
    background: rgba(148, 163, 184, 0.15);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
}

.confidence-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-ai-secondary);
    transition: width 0.6s ease;
}

.confidence-label {
    display: block;
    font-size: var(--font-size-xs);
    color: rgba(226, 232, 240, 0.8);
    margin-top: 0.25rem;
    margin-bottom: var(--spacing-sm);
}

.sentiment-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: capitalize;
}

.sentiment-badge.sentiment-positive {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-positive);
}

.sentiment-badge.sentiment-negative {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-negative);
}

.sentiment-badge.sentiment-neutral {
    background: rgba(148, 163, 184, 0.2);
    color: var(--color-neutral);
}

/* Chips and badges */
.filter-chip,
.issue-chip {
    background: linear-gradient(120deg, #22d3ee 0%, #3b82f6 100%);
    color: #0b1222;
    font-weight: 600;
}

.issue-category,
.issue-category-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.platform-badge {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

/* Multiselect */
.multiselect-trigger {
    background: rgba(15, 23, 42, 0.7);
    color: #e2e8f0;
}

.multiselect-dropdown {
    color: #e2e8f0;
}

.multiselect-dropdown {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.multiselect-option-label:hover {
    background: rgba(59, 130, 246, 0.15);
}

.multiselect-option.selected .multiselect-option-label {
    background: rgba(34, 211, 238, 0.15);
}

.multiselect-option-text {
    color: #e2e8f0;
}

.multiselect-search {
    background: rgba(11, 18, 34, 0.6);
    backdrop-filter: blur(8px);
}

/* Glassmorphism for Dropdowns and Secondary Panels */
select.comparison-select,
select.filter-select,
.filter-control select {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all var(--transition-base);
}

select.comparison-select:hover,
select.filter-select:hover,
.filter-control select:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(34, 211, 238, 0.4);
    box-shadow: 0 4px 16px rgba(34, 211, 238, 0.15);
}

/* Tooltip Glassmorphism */
.tooltip-container,
.prediction-metadata-tooltip-trigger[title]::after {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Modal Glassmorphism (if modals exist) */
.modal-overlay {
    background: rgba(5, 7, 15, 0.85);
    backdrop-filter: blur(12px);
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.multiselect-search-input {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
}

/* Issue overlap heatmap */
.heatmap-grid {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.heatmap-header-cell,
.heatmap-issue-cell {
    background: rgba(11, 18, 34, 0.95);
    color: #e2e8f0;
}

.heatmap-cell.absent {
    background: rgba(148, 163, 184, 0.1);
}

/* Footer */
.dashboard-footer {
    background: rgba(10, 15, 31, 0.95);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    color: rgba(226, 232, 240, 0.7);
}

.api-status {
    color: #22c55e;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content.active {
    animation: fadeIn var(--transition-base);
}

/* Responsive */
@media (max-width: 1024px) {
    .filter-bar {
        justify-content: center;
    }

    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }

    .filter-toolbar-divider {
        width: 100%;
        height: 1px;
    }

    .filter-presets-inline {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-presets-inline .filter-presets-buttons {
        width: 100%;
    }

    .filter-primary .filter-select {
        min-width: 120px;
    }

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

@media (max-width: 768px) {
    .filter-bar {
        padding: var(--spacing-sm);
    }

    .filter-bar-container {
        padding: var(--spacing-sm);
    }

    .filter-quick-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-control-inline {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-control-inline .filter-select,
    .filter-control-inline .filter-input {
        width: 100%;
        max-width: none;
    }

    .filter-advanced-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions-bar {
        width: 100%;
        justify-content: stretch;
    }

    .filter-actions-bar button {
        flex: 1;
    }

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

    .kpi-cards-row {
        grid-template-columns: 1fr;
    }
}

/* Desktop Large (1920px+) */
@media (min-width: 1920px) {
    .dashboard-main {
        max-width: 1800px;
    }

    .kpi-cards-row {
        grid-template-columns: repeat(6, 1fr);
    }

    .chart-card-third {
        grid-column: span 4;
    }
}

/* Laptop (1024px - 1919px) */
@media (min-width: 1024px) and (max-width: 1919px) {
    .kpi-cards-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .chart-card-third {
        grid-column: span 6; /* Becomes half-width */
    }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .dashboard-main {
        padding: var(--spacing-md);
        gap: var(--spacing-md);
    }

    .tab-content {
        gap: var(--spacing-md);
    }

    .charts-grid {
        gap: var(--spacing-md);
    }

    .kpi-cards-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-card-half,
    .chart-card-third,
    .chart-card-two-thirds {
        grid-column: 1 / -1; /* All become full width */
    }

    .charts-grid > .chart-card {
        grid-column: 1 / -1;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    .dashboard-main {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .tab-content {
        gap: var(--spacing-sm);
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .kpi-cards-row {
        grid-template-columns: 1fr;
    }

    .chart-card-primary {
        min-height: 300px;
    }

    .chart-card-half,
    .chart-card-third {
        min-height: 280px;
    }
}

/* Advanced Analytics filter row — horizontal layout, centered */
.tab-content[data-tab="advanced-analytics"] .params-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
}

.tab-content[data-tab="advanced-analytics"] .param-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 180px;
}

.tab-content[data-tab="advanced-analytics"] .param-item label {
    text-align: center;
    width: 100%;
}

/* Leader Performance */
.leader-performance-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
}

.leader-performance-controls label {
    font-size: var(--font-size-sm);
    color: rgba(226, 232, 240, 0.7);
}

.leader-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-md);
}

.leader-insight-card {
    position: relative;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--gradient-surface);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.leader-insight-title {
    font-family: var(--font-family-display);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.leader-insight-subtitle {
    font-size: var(--font-size-xs);
    color: rgba(226, 232, 240, 0.6);
    margin-bottom: 0.5rem;
}

.leader-insight-body {
    font-size: var(--font-size-sm);
    color: rgba(226, 232, 240, 0.8);
}

.leader-insight-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: var(--font-size-xs);
    color: rgba(226, 232, 240, 0.7);
}

.leader-insight-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.support-value.support-positive {
    color: var(--color-positive);
}

.support-value.support-negative {
    color: var(--color-negative);
}

.support-value.support-neutral {
    color: var(--color-neutral);
}
