/**
 * ÉMERGENCE Cockpit - Unified Styles
 * A comprehensive, mobile-responsive interface for system analytics
 * Combines metrics, charts, insights, and monitoring capabilities
 */

/* ========================================================================
   BASE STYLES & THEME VARIABLES
   ======================================================================== */

.cockpit-metrics,
.cockpit-charts,
.cockpit-insights,
.cockpit-container {
    /* Background colors */
    --bg-card: var(--glass-bg);
    --bg-secondary: rgba(255, 255, 255, 0.04);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --bg-light: rgba(255, 255, 255, 0.06);
    --bg-tooltip: rgba(0, 0, 0, 0.85);

    /* Text colors */
    --text-primary: var(--color-text-primary);
    --text-secondary: var(--color-text-secondary);
    --text-tertiary: var(--color-text-muted);

    /* Border colors */
    --border-color: var(--border-color);
    --border-light: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);

    /* Accent colors */
    --accent-color: var(--color-primary);
    --accent-light: var(--color-primary-hover);
    --accent-dark: #3a7bc8;

    /* Status colors */
    --error-color: var(--color-error);
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: rgba(239, 68, 68, 0.3);
}

/* Ensure parent containers don't clip tabs */
#tab-content-analytics,
#tab-content-cockpit.active,
#tab-content-cockpit {
    overflow: visible !important;
    min-height: auto !important;
}

/* Cockpit views need their own overflow handling */
.cockpit-view {
    overflow-x: hidden;
    overflow-y: auto;
    min-height: auto;
}

/* ========================================================================
   LAYOUT - CONTAINER
   ======================================================================== */

.cockpit-container {
    padding: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: visible;
}

/* ========================================================================
   LAYOUT - HEADER
   ======================================================================== */

.cockpit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px 24px 20px 24px;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.cockpit-title h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    margin: 0 0 8px 0;
}

.cockpit-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #666666);
    margin: 0;
}

.cockpit-actions {
    display: flex;
    gap: 12px;
}

.btn-refresh-all,
.btn-export-report {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh-all:hover,
.btn-export-report:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px);
}

.btn-refresh-all:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-export-report {
    background: var(--color-primary) !important;
    color: #ffffff;
    border-color: var(--color-primary) !important;
}

.btn-export-report:hover {
    background: var(--color-primary-hover) !important;
}

/* ========================================================================
   LAYOUT - TABS
   ======================================================================== */

.cockpit-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding: 8px 24px 16px 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    z-index: 10;
}

.cockpit-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.cockpit-tab:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--color-text-primary);
}

.cockpit-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0, 170, 255, 0.3);
    z-index: 2;
}

.tab-icon {
    font-size: 18px;
}

.tab-label {
    font-size: 14px;
}

/* ========================================================================
   LAYOUT - CONTENT
   ======================================================================== */

.cockpit-content {
    position: relative;
    min-height: 500px;
    padding: 0 24px 24px 24px;
}

.cockpit-view {
    display: none;
    animation: fadeIn 0.3s ease;
    width: 100%;
}

.cockpit-view.active {
    display: block;
}

.overview-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.overview-section {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-color) !important;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--glass-shadow) !important;
}

/* ========================================================================
   METRICS SECTION
   ======================================================================== */

.cockpit-metrics {
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    min-height: 100%;
    box-sizing: border-box;
}

.cockpit-metrics::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.cockpit-metrics::-webkit-scrollbar-track {
    background: transparent;
}

.cockpit-metrics::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.cockpit-metrics::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Metrics Header */
.metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.metrics-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.metrics-actions {
    display: flex;
    gap: 12px;
}

.metrics-actions button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.metrics-actions button:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px);
}

.metrics-actions button .icon {
    font-size: 16px;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Metric Card */
.metric-card {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-color) !important;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--glass-shadow) !important;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color, #4a90e2), var(--accent-light, #6aa8f0));
}

.metric-card:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(-2px);
}

/* Card variants */
.messages-card::before {
    background: linear-gradient(90deg, #4a90e2, #6aa8f0);
}

.threads-card::before {
    background: linear-gradient(90deg, #9b59b6, #bb6bd9);
}

.tokens-card::before {
    background: linear-gradient(90deg, #e74c3c, #ff6b6b);
}

.costs-card::before {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

/* Metric Icon */
.metric-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.9;
}

/* Metric Content */
.metric-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary, #666666);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Main Metric */
.metric-main {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.metric-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    line-height: 1.2;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary, #999999);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Metric Details */
.metric-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #666666);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

/* Metric Update Animation */
.metric-updated {
    animation: metricPulse 0.3s ease;
}

@keyframes metricPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
        color: var(--accent-color, #4a90e2);
    }
}

/* Summary Section */
.metrics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary, #f9f9f9);
    border-radius: 12px;
    border: 1px solid var(--border-light, #f0f0f0);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-color) !important;
    border-radius: 8px;
    box-shadow: var(--glass-shadow) !important;
}

.summary-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #666666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
}

/* ========================================================================
   CHARTS SECTION
   ======================================================================== */

.cockpit-charts {
    padding: 24px;
    width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    min-height: 100%;
    box-sizing: border-box;
}

.cockpit-charts::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.cockpit-charts::-webkit-scrollbar-track {
    background: transparent;
}

.cockpit-charts::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.cockpit-charts::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Charts Header */
.charts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 0 20px 0;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.charts-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.charts-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.period-selector {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-selector:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.period-selector option {
    background: #1a1a1a !important;
    color: white !important;
}

.btn-refresh {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    transform: rotate(180deg);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: 24px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: 0 0 24px 0;
}

/* Chart Container */
.chart-container {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-color) !important;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--glass-shadow) !important;
    transition: all 0.3s ease;
    animation: chartFadeIn 0.3s ease;
}

.chart-container:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(-2px);
}

/* Full width charts */
.timeline-chart,
.usage-chart,
.cost-chart {
    grid-column: 1 / -1;
}

/* Chart Header */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.chart-filter {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text-primary) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-filter:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.chart-filter option {
    background: #1a1a1a !important;
    color: white !important;
}

/* Chart Legend */
.chart-legend {
    display: flex;
    gap: 20px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #666666);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.messages {
    background: #4a90e2;
}

.legend-dot.threads {
    background: #9b59b6;
}

.legend-dot.input {
    background: #4a90e2;
}

.legend-dot.output {
    background: #e74c3c;
}

.legend-dot.total {
    background: #27ae60;
}

/* Canvas Wrapper */
.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    margin-bottom: 16px;
}

.chart-canvas-wrapper:hover {
    cursor: crosshair;
}

.chart-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Chart specific heights */
.timeline-chart .chart-canvas-wrapper {
    height: 350px;
}

.usage-chart .chart-canvas-wrapper {
    height: 300px;
}

.distribution-chart .chart-canvas-wrapper {
    height: 280px;
}

.cost-chart .chart-canvas-wrapper {
    height: 280px;
}

/* Distribution Stats */
.chart-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, #f0f0f0);
    max-width: 100%;
    box-sizing: border-box;
}

.stat-row {
    display: grid;
    grid-template-columns: 16px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
}

.stat-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.stat-percent {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary, #999999);
    min-width: 50px;
    text-align: right;
}

/* Cost Summary */
.cost-summary {
    display: flex;
    gap: 24px;
    align-items: center;
}

.cost-total,
.cost-avg {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #666666);
}

.cost-total strong,
.cost-avg strong {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-color, #27ae60);
    margin-left: 4px;
}

/* Chart Tooltips */
.chart-tooltip {
    position: absolute;
    background: var(--bg-tooltip, rgba(0, 0, 0, 0.85));
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.chart-tooltip.visible {
    opacity: 1;
}

/* ========================================================================
   INSIGHTS SECTION
   ======================================================================== */

.cockpit-insights {
    padding: 24px;
    width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    min-height: 100%;
    box-sizing: border-box;
}

.cockpit-insights::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.cockpit-insights::-webkit-scrollbar-track {
    background: transparent;
}

.cockpit-insights::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.cockpit-insights::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Insights Header */
.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 0 20px 0;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.insights-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.insights-period {
    display: flex;
    align-items: center;
    gap: 12px;
}

.period-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #666666);
}

/* Insights Grid */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
    gap: 24px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: 0 0 24px 0;
}

/* Insight Section */
.insight-section {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-color) !important;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--glass-shadow) !important;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.insight-section:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(-2px);
}

/* Full width sections */
.trends-section,
.activity-section,
.recommendations-section {
    grid-column: 1 / -1;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 12px;
    background: var(--accent-light, #e3f2fd);
    color: var(--accent-color, #4a90e2);
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
}

/* Section Content */
.section-content {
    flex: 1;
    overflow-y: auto;
    max-height: 500px;
    min-height: 200px;
}

/* Insight Items */
.insight-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-secondary, #f9f9f9);
    border: 1px solid var(--border-light, #f0f0f0);
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.insight-item:hover {
    background: var(--bg-hover, #f0f0f0);
    border-color: var(--border-hover, #d0d0d0);
    transform: translateX(4px);
}

.insight-item:last-child {
    margin-bottom: 0;
}

/* Item Rank */
.item-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent-light, #e3f2fd);
    color: var(--accent-color, #4a90e2);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Item Icon */
.item-icon {
    font-size: 24px;
    flex-shrink: 0;
}

/* Item Content */
.item-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.item-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary, #666666);
    flex-wrap: wrap;
}

.stat-mentions,
.stat-messages,
.stat-views,
.stat-time {
    font-weight: 500;
}

/* Trend Indicator */
.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.trend-up {
    background: #e8f5e9;
    color: #27ae60;
}

.trend-down {
    background: #ffebee;
    color: #e74c3c;
}

.trend-stable {
    background: #f5f5f5;
    color: #999999;
}

/* Status Badge */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: #e8f5e9;
    color: #27ae60;
}

.status-archived {
    background: #f5f5f5;
    color: #999999;
}

/* Item Action */
.item-action {
    flex-shrink: 0;
}

.btn-explore,
.btn-open-thread,
.btn-view-doc {
    padding: 8px 16px;
    background: var(--accent-color, #4a90e2);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-explore:hover,
.btn-open-thread:hover,
.btn-view-doc:hover {
    background: var(--accent-dark, #3a7bc8);
    transform: translateY(-1px);
}

/* Section Footer */
.section-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, #f0f0f0);
}

.btn-view-all {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-color, #4a90e2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-view-all:hover {
    background: var(--accent-light, #e3f2fd);
    border-color: var(--accent-color, #4a90e2);
}

/* Trends Grid */
.trends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    max-width: 100%;
    box-sizing: border-box;
}

.trend-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--bg-secondary, #f9f9f9);
    border: 1px solid var(--border-light, #f0f0f0);
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s ease;
}

.trend-card:hover {
    background: var(--bg-hover, #f0f0f0);
    transform: translateY(-2px);
}

.trend-icon {
    font-size: 36px;
}

.trend-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #666666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.trend-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
}

/* Activity Heatmap */
.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    box-sizing: border-box;
}

.heatmap-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.heatmap-day {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #666666);
}

.heatmap-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.heatmap-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--bg-secondary, #f5f5f5);
    transition: all 0.2s ease;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
}

.intensity-0 {
    background: #f5f5f5;
}

.intensity-1 {
    background: #c8e6c9;
}

.intensity-2 {
    background: #81c784;
}

.intensity-3 {
    background: #4caf50;
}

.intensity-4 {
    background: #2e7d32;
}

/* Recommendations */
.recommendation-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--accent-color, #4a90e2);
    background: var(--bg-secondary, #f9f9f9);
    border-radius: 0 8px 8px 0;
    transition: all 0.2s ease;
}

.recommendation-item:hover {
    background: var(--bg-hover, #f0f0f0);
    transform: translateX(4px);
}

.recommendation-item:last-child {
    margin-bottom: 0;
}

.priority-high {
    border-left-color: #e74c3c;
}

.priority-medium {
    border-left-color: #f39c12;
}

.priority-low {
    border-left-color: #95a5a6;
}

.rec-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.rec-content {
    flex: 1;
}

.rec-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
    margin-bottom: 6px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.rec-priority {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #666666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-rec-action {
    padding: 8px 16px;
    background: var(--accent-color, #4a90e2);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-rec-action:hover {
    background: var(--accent-dark, #3a7bc8);
    transform: translateY(-1px);
}

/* ========================================================================
   LOADING & EMPTY STATES
   ======================================================================== */

.cockpit-loading,
.metrics-loading,
.chart-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.cockpit-loading::after,
.metrics-loading::after,
.chart-loading::after {
    content: '';
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-light, #f0f0f0);
    border-top-color: var(--accent-color, #4a90e2);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.chart-loading {
    min-height: 300px;
}

.chart-loading::after {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.cockpit-empty,
.chart-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    color: var(--text-tertiary, #999999);
    gap: 16px;
}

.chart-empty {
    min-height: 300px;
    gap: 12px;
}

.cockpit-empty::before,
.chart-empty::before {
    content: '📊';
    font-size: 64px;
    opacity: 0.5;
}

.chart-empty::before {
    font-size: 48px;
}

.cockpit-empty-text,
.chart-empty-text {
    font-size: 16px;
    font-weight: 500;
}

.chart-empty-text {
    font-size: 14px;
}

.loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--text-tertiary, #999999);
    font-size: 14px;
}

/* Error State */
.metrics-error {
    padding: 32px;
    text-align: center;
    color: var(--error-color, #e74c3c);
    background: var(--error-bg, #fee);
    border-radius: 12px;
    border: 1px solid var(--error-border, #fcc);
}

.metrics-error::before {
    content: '⚠️';
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

/* ========================================================================
   ANIMATIONS
   ======================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================================================
   RESPONSIVE BREAKPOINTS - TABLETS (≤1200px)
   ======================================================================== */

@media (max-width: 1200px) {
    .cockpit-container {
        max-width: 100%;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .timeline-chart,
    .usage-chart {
        grid-column: span 1;
    }

    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .trends-section,
    .activity-section,
    .recommendations-section {
        grid-column: span 2;
    }
}

/* Tablet and mobile improvements (≤1024px) */
@media (max-width: 1024px) {
    .insights-grid,
    .charts-grid,
    .metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .trends-section,
    .activity-section,
    .recommendations-section,
    .timeline-chart,
    .usage-chart,
    .cost-chart {
        grid-column: 1 !important;
    }

    .insight-item,
    .metric-card,
    .chart-container {
        max-width: 100%;
        overflow-x: hidden;
    }

    .metrics-summary {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================================================
   RESPONSIVE BREAKPOINTS - MOBILE (≤768px)
   ======================================================================== */

@media (max-width: 768px) {
    .cockpit-container {
        padding: 16px;
    }

    .cockpit-metrics,
    .cockpit-charts,
    .cockpit-insights {
        padding: 16px;
    }

    .cockpit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .cockpit-title h1 {
        font-size: 24px;
    }

    .cockpit-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn-refresh-all,
    .btn-export-report {
        width: 100%;
        justify-content: center;
    }

    .cockpit-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cockpit-tab {
        flex-shrink: 0;
    }

    .tab-label {
        display: none;
    }

    .tab-icon {
        font-size: 20px;
    }

    .metrics-header,
    .charts-header,
    .insights-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metrics-summary {
        grid-template-columns: 1fr;
    }

    .metric-value {
        font-size: 28px;
    }

    .metric-icon {
        font-size: 36px;
    }

    .charts-controls {
        width: 100%;
        flex-direction: column;
    }

    .period-selector {
        width: 100%;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .chart-legend {
        flex-wrap: wrap;
        width: 100%;
    }

    .cost-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-canvas-wrapper {
        height: 250px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    canvas {
        max-width: 100%;
    }

    .insights-grid {
        grid-template-columns: 1fr;
    }

    .trends-section,
    .activity-section,
    .recommendations-section {
        grid-column: span 1;
    }

    .trends-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .insight-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .item-action {
        width: 100%;
    }

    .btn-explore,
    .btn-open-thread,
    .btn-view-doc {
        width: 100%;
    }

    .insights-period,
    .metrics-actions,
    .charts-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .chart-filter {
        width: 100%;
    }

    .heatmap-grid {
        font-size: 12px;
    }

    .heatmap-cell {
        min-width: 0;
    }

    .overview-section {
        padding: 16px;
    }
}

/* ========================================================================
   RESPONSIVE BREAKPOINTS - SMALL MOBILE (≤480px)
   ======================================================================== */

@media (max-width: 480px) {
    .cockpit-title h1 {
        font-size: 20px;
    }

    .cockpit-subtitle {
        font-size: 12px;
    }

    .cockpit-tabs {
        padding: 4px !important;
    }

    .cockpit-tab {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    .tab-icon {
        font-size: 16px !important;
    }

    .metrics-actions {
        flex-direction: column;
        width: 100%;
    }

    .metrics-actions button {
        width: 100%;
        justify-content: center;
    }

    .metric-card {
        padding: 20px;
    }

    .chart-container {
        padding: 16px;
    }

    .chart-header h3 {
        font-size: 16px;
    }

    .legend-item {
        font-size: 12px;
    }

    .stat-row {
        grid-template-columns: 12px 1fr auto;
        gap: 8px;
    }

    .stat-percent {
        grid-column: 2 / 4;
        text-align: left;
        margin-top: 4px;
    }

    .trends-grid {
        grid-template-columns: 1fr !important;
    }

    .item-stats {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .recommendation-item {
        flex-direction: column;
        gap: 12px;
    }

    .rec-content {
        width: 100%;
    }

    .btn-rec-action {
        width: 100%;
    }

    .metric-card,
    .chart-container,
    .insight-section {
        padding: 16px !important;
    }

    .metric-value {
        font-size: 28px !important;
    }

    .metric-icon {
        font-size: 36px !important;
    }

    .cost-summary {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .chart-stats {
        font-size: 12px;
    }
}

/* ========================================================================
   OVERFLOW PROTECTION
   ======================================================================== */

.cockpit-container,
.cockpit-content {
    max-width: 100%;
    overflow-x: hidden;
}

.cockpit-view {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.section-content,
.metrics-summary,
.trends-grid,
.heatmap-grid,
.chart-stats {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure all text doesn't overflow */
.item-title,
.rec-text,
.trend-label,
.stat-label {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========================================================================
   DARK MODE SUPPORT
   ======================================================================== */

@media (prefers-color-scheme: dark) {
    .cockpit-container {
        --bg-card: #2a2a2a;
        --bg-secondary: #1e1e1e;
        --bg-hover: #353535;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --border-color: #404040;
        --border-hover: #505050;
    }

    .cockpit-tab.active {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .overview-section {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .cockpit-metrics,
    .cockpit-charts,
    .cockpit-insights {
        --bg-card: #2a2a2a;
        --bg-secondary: #1e1e1e;
        --bg-hover: #353535;
        --bg-tooltip: rgba(255, 255, 255, 0.9);
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --text-tertiary: #808080;
        --border-color: #404040;
        --border-light: #353535;
        --border-hover: #505050;
        --accent-light: rgba(74, 144, 226, 0.2);
    }

    .metric-card,
    .chart-container,
    .insight-section {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .metric-card:hover,
    .chart-container:hover,
    .insight-section:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }

    .chart-tooltip {
        background: rgba(255, 255, 255, 0.9);
        color: #1a1a1a;
    }
}
