/* AI Insights Category Sections */
.ai-content-all {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
    overflow: visible;
}

/* Light Theme Overrides for Category Sections */
/* Light Theme Overrides for Category Sections */
[data-theme="light"] .category-section {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .high-performance-section {
    background: rgba(67, 233, 123, 0.05);
    border-color: rgba(67, 233, 123, 0.2);
}

[data-theme="light"] .high-performance-section .category-header {
    background: linear-gradient(90deg, rgba(67, 233, 123, 0.3) 0%, transparent 100%);
}

[data-theme="light"] .monitor-section {
    background: rgba(250, 187, 5, 0.05);
    border-color: rgba(250, 187, 5, 0.2);
}

[data-theme="light"] .monitor-section .category-header {
    background: linear-gradient(90deg, rgba(250, 187, 5, 0.3) 0%, transparent 100%);
}

[data-theme="light"] .declining-winner-section {
    background: rgba(249, 115, 22, 0.05);
    border-color: rgba(249, 115, 22, 0.2);
}

[data-theme="light"] .declining-winner-section .category-header {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.3) 0%, transparent 100%);
}

[data-theme="light"] .low-performance-section {
    background: rgba(245, 87, 108, 0.05);
    border-color: rgba(245, 87, 108, 0.2);
}

[data-theme="light"] .low-performance-section .category-header {
    background: linear-gradient(90deg, rgba(245, 87, 108, 0.3) 0%, transparent 100%);
}

[data-theme="light"] .insufficient-section {
    background: rgba(113, 128, 150, 0.05);
    border-color: rgba(113, 128, 150, 0.2);
}

[data-theme="light"] .insufficient-section .category-header {
    background: linear-gradient(90deg, rgba(113, 128, 150, 0.3) 0%, transparent 100%);
}


[data-theme="light"] .category-section:hover {
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .category-count {
    background: rgba(255, 255, 255, 0.5);
}


[data-theme="light"] .adset-table thead th {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

[data-theme="light"] .adset-table tbody tr {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .adset-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .tooltip-icon {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .tooltip-icon:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .day-of-week-table thead th {
    color: var(--text-primary);
    background: rgba(248, 250, 252, 1);
}

[data-theme="light"] .day-of-week-table thead th:first-child {
    background: rgba(248, 250, 252, 1);
}

[data-theme="light"] .day-of-week-table tbody td:first-child {
    color: var(--text-primary);
    background: rgba(248, 250, 252, 1);
}

[data-theme="light"] .day-of-week-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .day-of-week-table tbody tr:nth-child(even) td:first-child {
    background: rgba(243, 244, 246, 1);
}

[data-theme="light"] .day-of-week-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.08);
}

[data-theme="light"] .day-of-week-table tbody tr:hover td:first-child {
    background: rgba(226, 232, 240, 1);
}

[data-theme="light"] .trends-table-container {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .adset-table-scroll {
    scrollbar-color: rgba(102, 126, 234, 0.4) rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .adset-table-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}


.category-section {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: visible;
    transition: all var(--transition-base);
    min-width: 0;
    /* Important for flexbox overflow handling */
    width: 100%;
    /* Force width to respect parent container */
}

.category-section:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.category-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 2px solid var(--glass-border);
    overflow: visible;
    position: relative;
    z-index: 20;
}

.category-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    position: relative;
}

.category-icon {
    font-size: 1.5rem;
}

.category-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.category-count {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
}

.tooltip-container {
    margin-left: auto;
}

/* High Performance Section */
.high-performance-section {
    border-left: 4px solid #43e97b;
}

.high-performance-section .category-header {
    background: linear-gradient(90deg, rgba(67, 233, 123, 0.1) 0%, transparent 100%);
}

.high-performance-section .category-count {
    background: rgba(67, 233, 123, 0.2);
    color: #43e97b;
}

/* Low Performance Section */
.low-performance-section {
    border-left: 4px solid #f5576c;
}

.low-performance-section .category-header {
    background: linear-gradient(90deg, rgba(245, 87, 108, 0.1) 0%, transparent 100%);
}

.low-performance-section .category-count {
    background: rgba(245, 87, 108, 0.2);
    color: #f5576c;
}

/* Needs Monitoring Section */
.monitor-section {
    border-left: 4px solid #fabb05;
}

.monitor-section .category-header {
    background: linear-gradient(90deg, rgba(250, 187, 5, 0.1) 0%, transparent 100%);
}

.monitor-section .category-count {
    background: rgba(250, 187, 5, 0.2);
    color: #fabb05;
}

/* Declining Winners Section (NEW) */
.declining-winner-section {
    border-left: 4px solid #f97316;
    /* Deep amber/orange */
}

.declining-winner-section .category-header {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.1) 0%, transparent 100%);
}

.declining-winner-section .category-count {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

/* Row highlight style for declining winners */
.row-highlight-declining-winner {
    background: rgba(249, 115, 22, 0.03);
}

/* Insufficient Data Section */
.insufficient-section {
    border-left: 4px solid #718096;
}

.insufficient-section .category-header {
    background: linear-gradient(90deg, rgba(113, 128, 150, 0.1) 0%, transparent 100%);
}

.insufficient-section .category-count {
    background: rgba(113, 128, 150, 0.2);
    color: #a0aec0;
}

/* Table Styles */
.table-responsive {
    padding: var(--spacing-md);
    padding-top: 80px;
    /* Extra space for tooltips above */
    margin-top: -60px;
    /* Compensate for the extra padding */
    position: relative;
    z-index: 10;
    pointer-events: auto;
    /* Allow clicks to pass through padding to header */
    overflow: visible !important;
}

/* Fix for Adset Performance table overflow - allow horizontal scrolling */
.category-section .table-responsive {
    overflow-x: auto !important;
}

.adset-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    pointer-events: auto;
    /* Restore clicks for the table */
}

.adset-table thead th {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
}

.adset-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-fast);
}

.adset-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 20;
}

.adset-table tbody td {
    padding: var(--spacing-md);
    color: var(--text-secondary);
    position: relative;
}

/* Elevate the cell being hovered to ensure tooltip sits on top of everything */
.adset-table tbody td:hover {
    z-index: 50;
}

.adset-name-cell {
    color: var(--text-primary);
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-checkbox.active {
    background: rgba(67, 233, 123, 0.2);
    color: #43e97b;
    border: 2px solid #43e97b;
}

.status-checkbox.paused {
    background: rgba(245, 87, 108, 0.1);
    border: 2px solid rgba(245, 87, 108, 0.3);
}

/* Light theme - make active checkmark more visible */
[data-theme="light"] .status-checkbox.active {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
    border: 2px solid #16a34a;
}

.font-weight-bold {
    font-weight: 700;
    color: var(--text-primary);
}

/* Rank Badge for Top Ads Table */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 700;
    border: 1px solid rgba(102, 126, 234, 0.4);
}

/* Ad Name with Link Button */
.ad-name-with-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ad-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ad-link-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary-blue);
}

.ad-link-btn .icon {
    width: 14px;
    height: 14px;
}

/* Row Highlights */
.row-highlight-high {
    background: rgba(67, 233, 123, 0.03);
}

.row-highlight-high td:first-child {
    border-left: 3px solid #43e97b;
}

.row-highlight-low {
    background: rgba(245, 87, 108, 0.03);
}

.row-highlight-monitor {
    background: rgba(250, 187, 5, 0.03);
}

.row-highlight-insufficient {
    background: rgba(113, 128, 150, 0.03);
}

.row-highlight-normal {
    background: transparent;
}

/* Responsive */
@media (max-width: 768px) {
    .table-responsive {
        padding: var(--spacing-sm);
    }

    .adset-table {
        font-size: 0.75rem;
    }

    .adset-table thead th,
    .adset-table tbody td {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .category-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .category-title h3 {
        font-size: 1rem;
    }
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: help;
    transition: all var(--transition-fast);
    margin-left: var(--spacing-xs);
}

.tooltip-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Sticky Table Headers */
.adset-table thead th {
    position: sticky;
    top: 0;
    z-index: 1000;
    /* Ensure header sits above content */
    background: #0a0e27;
    /* Match --bg-primary or card bg to prevent see-through */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    /* Optional: shadow for depth */
}

/* Tooltip text is now handled by JS Portal - hide CSS version interactions */
.tooltip-text {
    display: none;
    /* Hide from CSS layout completely */
}

.tooltip-container {
    cursor: help;
}

.adset-table .tooltip-container .tooltip-text,
.tooltip-container:hover .tooltip-text {
    display: none;
    visibility: hidden;
    opacity: 0;
}

/* Global Portal Tooltip - Injected by JS */
#global-tooltip-portal {
    position: fixed;
    z-index: 99999;
    background: rgba(21, 27, 61, 0.98);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-line;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 200px;
    max-width: 500px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    visibility: hidden;
}

#global-tooltip-portal.visible {
    opacity: 1;
    visibility: visible;
}

/* Light theme tooltip styling */
[data-theme="light"] #global-tooltip-portal {
    background: rgba(255, 255, 255, 0.98);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] #global-tooltip-portal .tooltip-status {
    border-top-color: rgba(0, 0, 0, 0.1);
}

#global-tooltip-portal strong {
    color: var(--text-primary);
    font-weight: 600;
}

#global-tooltip-portal .tooltip-metric {
    color: var(--accent-cyan);
    font-weight: 600;
}

#global-tooltip-portal .tooltip-status {
    display: block;
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-style: italic;
    color: var(--text-muted);
}

/* Info icon in table rows - Green to indicate Trackable is enabled */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(67, 233, 123, 0.2);
    color: #43e97b;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
    transition: all var(--transition-fast);
}

.info-icon:hover {
    background: rgba(67, 233, 123, 0.3);
    transform: scale(1.15);
}

/* Ensure hovered row is always on top */
.adset-table tbody tr {
    position: relative;
    z-index: 1;
}

.adset-table tbody tr:hover {
    z-index: 100;
}

/* ===== Scrollable Adset Table ===== */
.adset-table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    /* Changed from 'thin' to 'auto' for thicker scrollbar in Firefox */
    scrollbar-color: rgba(102, 126, 234, 0.4) rgba(255, 255, 255, 0.05);
}

.adset-table-scroll::-webkit-scrollbar {
    height: 24px !important;
}

.adset-table-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.adset-table-scroll::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.4);
    border-radius: 6px;
}

.adset-table-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.6);
}

/* Ensure table is wide enough to require scrolling */
.adset-table-scroll .adset-table {
    min-width: 100%;
    table-layout: auto;
}

.adset-table-scroll .adset-table th,
.adset-table-scroll .adset-table td {
    white-space: nowrap;
}

/* Cost value styling */
.metric-cost-value {
    color: var(--accent-cyan);
    font-size: 0.875rem;
}

/* ===== Day of Week Performance Trends Table ===== */

/* Weekly Insight Card */
.weekly-insight-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    padding: var(--spacing-lg);
    margin: 0 var(--spacing-xl) var(--spacing-lg) var(--spacing-xl);
    display: flex;
    gap: var(--spacing-lg);
    align-items: flex-start;
    animation: slideDown 0.4s ease-out;
}

.insight-icon {
    background: rgba(34, 197, 94, 0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.insight-content {
    flex: 1;
}

.insight-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.insight-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.insight-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.insight-text .highlight-day {
    color: #22c55e;
    font-weight: 600;
}

/* Elevated Table Container */
.trends-table-container {
    background: rgba(51, 65, 85, 0.4);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Add padding to ai-header when inside trends container */
.trends-table-container .ai-header {
    padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-lg) var(--spacing-xl);
    margin-bottom: 0;
}

.day-of-week-content {
    padding: 0 0 var(--spacing-lg) 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.day-of-week-content .table-responsive {
    padding-top: 0;
    margin-top: 0;
}

.day-of-week-table {
    width: 100%;
    border-collapse: collapse;
}

.day-of-week-table thead th {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(51, 65, 85, 1);
    position: relative;
    z-index: 1;
}

.day-of-week-table thead th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
    background: rgba(51, 65, 85, 1);
}

.day-of-week-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-fast);
}

.day-of-week-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.day-of-week-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.06);
}

.day-of-week-table tbody td {
    padding: var(--spacing-sm) var(--spacing-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    font-weight: 400;
}

.day-of-week-table tbody td:first-child {
    color: #ffffff;
    font-weight: 600;
    text-align: left;
    padding-left: var(--spacing-md);
    position: sticky;
    left: 0;
    z-index: 1;
    background: rgba(51, 65, 85, 1);
}

/* Sticky column background for even rows */
.day-of-week-table tbody tr:nth-child(even) td:first-child {
    background: rgba(48, 62, 80, 1);
}

/* Sticky column background on hover */
.day-of-week-table tbody tr:hover td:first-child {
    background: rgba(62, 76, 114, 1);
}

/* Heatmap Conditional Formatting Classes */

/* Good value (green) - for metrics where the value is favorable */
.heatmap-good {
    color: #4ade80 !important;
    font-weight: 500;
}

/* Bad value (magenta/pink) - for metrics where the value is unfavorable */
.heatmap-bad {
    color: #f472b6 !important;
    font-weight: 500;
}

/* Neutral/middle value - slightly muted */
.heatmap-neutral {
    color: var(--text-secondary);
}

/* Pill highlight for standout best values */
.heatmap-pill-good {
    display: inline-block;
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80 !important;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* Pill highlight for standout worst values */
.heatmap-pill-bad {
    display: inline-block;
    background: rgba(244, 114, 182, 0.15);
    color: #f472b6 !important;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* Bold highlight for spend (highest) */
.heatmap-spend-high {
    font-weight: 700;
    color: var(--text-primary) !important;
}

.day-of-week-table .text-center {
    text-align: center;
}

/* ===== Metric Trends Line Chart Section ===== */
.metric-trends-section {
    background: rgba(51, 65, 85, 0.4);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: var(--spacing-lg);
}

.metric-trends-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-lg);
    margin-bottom: 0;
    flex-wrap: wrap;
    padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-lg) var(--spacing-xl);
}

.metric-trends-title-area h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-xs) 0;
}

.metric-trends-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin: 0;
}

.metric-trends-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/* Toggle Button Group */
.trends-toggle-group {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 4px;
    border: 1px solid var(--glass-border);
}

.trends-toggle-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.trends-toggle-btn:hover {
    color: var(--text-primary);
}

.trends-toggle-btn.active {
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
}

/* Select Metrics Button */
.select-metrics-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 10px 16px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.select-metrics-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Metric Cards */
.metric-trends-cards {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    padding: 0 var(--spacing-xl);
}

.metric-trend-card {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    position: relative;
    overflow: hidden;
}

.metric-trend-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

.metric-trend-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-xs);
}

.metric-trend-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-trend-card-icon {
    width: 32px;
    height: 32px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
}

.metric-trend-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.metric-trend-card-comparison {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-trend-card-comparison.positive {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.metric-trend-card-comparison.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.metric-trend-card-comparison.neutral {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

/* Chart Container */
.metric-trends-chart-container {
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl);
    min-height: 350px;
    position: relative;
}

.metric-trends-chart-container canvas {
    max-height: 350px;
}

/* Chart Loading Overlay */
.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    z-index: 10;
}

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

[data-theme="light"] .chart-loading-overlay {
    background: rgba(255, 255, 255, 0.7);
}

/* Chart Legend Custom Styling */
.metric-trends-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.solid {
    background: #667eea;
}

.legend-line.dashed {
    background: linear-gradient(to right, #a78bfa 0%, #a78bfa 50%, transparent 50%, transparent 100%);
    background-size: 8px 100%;
}

/* Light Theme Overrides */
[data-theme="light"] .metric-trends-section {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .trends-toggle-group {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .trends-toggle-btn {
    color: var(--text-secondary);
}

[data-theme="light"] .trends-toggle-btn:hover {
    color: var(--text-primary);
}

[data-theme="light"] .trends-toggle-btn.active {
    color: white;
}

[data-theme="light"] .metric-trend-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-color: rgba(102, 126, 234, 0.2);
}

[data-theme="light"] .metric-trends-chart-container {
    background: rgba(0, 0, 0, 0.02);
}

/* Metric Selection Modal - Checkbox Styles */
.metric-option-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.metric-option-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.metric-option-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.metric-option-item label {
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.metric-option-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

[data-theme="light"] .metric-option-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Responsive */
@media (max-width: 768px) {
    .metric-trends-section {
        margin: var(--spacing-md);
        padding: var(--spacing-md);
    }

    .metric-trends-header {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .metric-trends-controls {
        width: 100%;
        justify-content: space-between;
    }

    .metric-trend-card {
        min-width: 100%;
    }
}

/* Top 3 Ads Highlight in Ad Performance Table */
#table-wrapper-top-ads .row-highlight-high {
    background: rgba(67, 233, 123, 0.1) !important;
    /* Green at 10% opacity */
}

#table-wrapper-top-ads .row-highlight-high:hover {
    background: rgba(67, 233, 123, 0.15) !important;
}

#table-wrapper-top-ads .row-highlight-high td:first-child {
    border-left: 3px solid #43e97b !important;
    /* Green accent line */
}

/* Light theme adjustments for Top 3 Ads */
[data-theme="light"] #table-wrapper-top-ads .row-highlight-high {
    background: rgba(67, 233, 123, 0.15) !important;
    /* Slightly stronger in light mode */
}

[data-theme="light"] #table-wrapper-top-ads .row-highlight-high:hover {
    background: rgba(67, 233, 123, 0.2) !important;
}