/* Clean, Professional Analytics Design */

/* Main Analytics Container */
.analytics-page {
    background: #f8fafc;
    min-height: 100vh;
    padding: 2rem;
}

/* Clean Navigation */
.analytics-navigation {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

.analytics-nav-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: #64748b;
    font-size: 0.9rem;
}

.analytics-nav-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #f0f9ff;
}

.analytics-nav-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Clean Filters */
.analytics-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

.analytics-filter {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #475569;
    font-size: 0.9rem;
}

.analytics-filter:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Clean Layout */
.analytics-grid {
    display: grid;
    gap: 1.5rem;
}

.analytics-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

.analytics-section h3 {
    margin-bottom: 1.5rem;
    color: #1e293b;
    font-size: 1.125rem;
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.75rem;
}

/* Clean Overview Cards */
.overview-cards .insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.insight-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s ease;
    border-left: 3px solid #3b82f6;
}

.insight-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.insight-icon {
    font-size: 1.5rem;
    color: #3b82f6;
    margin-bottom: 0.5rem;
}

.insight-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.insight-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

/* Clean Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1.5rem 0;
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e2e8f0;
}

.chart-container canvas {
    max-height: 100%;
}

/* Trends Summary */
.trends-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.trend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.875rem;
}

.trend-date {
    color: #64748b;
    font-family: 'Monaco', 'Menlo', monospace;
}

.trend-sessions {
    font-weight: 600;
    color: #1e293b;
}

.trend-completion {
    color: #059669;
    font-weight: 500;
}

/* Summary Analysis - Replaces Word Cloud */
.summary-analysis {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.theme-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s ease;
}

.theme-card:hover {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

.theme-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 1rem;
}

.theme-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.theme-count {
    background: #3b82f6;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.theme-metrics {
    display: flex;
    gap: 1rem;
    color: #64748b;
}

.theme-examples {
    margin-top: 0.75rem;
}

.example-summary {
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    border-left: 2px solid #3b82f6;
}

.example-session {
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Intent Analysis */
.intent-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.intent-chart-container {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1.5rem;
    height: 300px;
    border: 1px solid #e2e8f0;
}

.success-correlation h4 {
    margin-bottom: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.intent-performance {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.intent-performance:hover {
    background: white;
    border-color: #3b82f6;
}

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

.intent-name {
    font-weight: 600;
    color: #1e293b;
    text-transform: capitalize;
}

.success-rate {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.success-rate.high {
    background: #dcfce7;
    color: #166534;
}

.success-rate.medium {
    background: #fef3c7;
    color: #92400e;
}

.success-rate.low {
    background: #fee2e2;
    color: #dc2626;
}

.intent-metrics {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #64748b;
}

/* Behavior Patterns */
.behavior-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.behavior-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
}

.behavior-card h4 {
    margin-bottom: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.pattern-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.metric:last-child {
    border-bottom: none;
}

.metric-label {
    font-size: 0.875rem;
    color: #64748b;
}

.metric-value {
    font-weight: 600;
    color: #1e293b;
}

.complexity-analysis {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.complexity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.complexity-level {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.complexity-level.simple {
    background: #dcfce7;
    color: #166534;
}

.complexity-level.medium {
    background: #fef3c7;
    color: #92400e;
}

.complexity-level.complex {
    background: #fee2e2;
    color: #dc2626;
}

/* Usage Patterns */
.usage-chart-container {
    position: relative;
    height: 200px;
    margin-bottom: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e2e8f0;
}

.usage-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.usage-period {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.usage-period:hover {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.period-name {
    min-width: 120px;
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.period-bar {
    flex: 1;
    height: 20px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
}

.period-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.period-count {
    min-width: 60px;
    text-align: right;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
}

/* Predictions Section */
.prediction-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.prediction-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 3px solid #3b82f6;
}

.prediction-card h4 {
    margin-bottom: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.prediction-metric {
    text-align: center;
    margin-bottom: 1rem;
}

.prediction-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #3b82f6;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.prediction-label {
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
}

.prediction-confidence {
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
    font-style: italic;
}

.intent-forecast {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.intent-prediction {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.intent-name {
    font-weight: 600;
    color: #1e293b;
    text-transform: capitalize;
    font-size: 0.875rem;
}

.predicted-count {
    font-weight: 700;
    color: #3b82f6;
}

.trend-indicator {
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.trend-indicator.up {
    background: #dcfce7;
    color: #166534;
}

.trend-indicator.down {
    background: #fee2e2;
    color: #dc2626;
}

.trend-indicator.stable {
    background: #f1f5f9;
    color: #64748b;
}

/* Recommendations */
.recommendations-section h4 {
    margin-bottom: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.recommendation-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.recommendation-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    border-left: 3px solid #3b82f6;
}

.recommendation-card h5 {
    margin-bottom: 0.5rem;
    color: #3b82f6;
    font-size: 0.875rem;
    font-weight: 600;
}

.recommendation-card p {
    color: #475569;
    line-height: 1.5;
    margin: 0;
    font-size: 0.875rem;
}

/* Conversations Section */
.conversation-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.conversation-search {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
}

.conversation-filter {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.conversation-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s ease;
}

.conversation-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #3b82f6;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.conversation-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.session-id {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    color: #64748b;
    background: #f8fafc;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.intent-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.intent-badge.debug { background: #fee2e2; color: #dc2626; }
.intent-badge.modify { background: #dbeafe; color: #2563eb; }
.intent-badge.create { background: #dcfce7; color: #166534; }
.intent-badge.ask { background: #fef3c7; color: #92400e; }

.conversation-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
}

.timestamp {
    font-family: 'Monaco', 'Menlo', monospace;
}

.status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status.completed { background: #dcfce7; color: #166534; }
.status.failed { background: #fee2e2; color: #dc2626; }
.status.processing { background: #dbeafe; color: #2563eb; }

.conversation-summary {
    margin-bottom: 1rem;
    color: #475569;
    line-height: 1.5;
    font-size: 0.875rem;
}

.conversation-metrics {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.conversation-metrics .metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.conversation-metrics .metric-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
}

.conversation-metrics .metric-value {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
}

.metric-value.frustration.low { color: #166534; }
.metric-value.frustration.medium { color: #92400e; }
.metric-value.frustration.high { color: #dc2626; }

/* Deep Dive Modal */
.analytics-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: #3b82f6;
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* Loading States */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    color: #64748b;
    font-style: italic;
}

.error {
    color: #dc2626;
    background: #fee2e2;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #fecaca;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .analytics-page {
        padding: 1rem;
    }
    
    .analytics-navigation {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .analytics-nav-btn {
        width: 100%;
        text-align: center;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
    
    .intent-grid,
    .behavior-grid,
    .prediction-cards {
        grid-template-columns: 1fr;
    }
    
    .intent-metrics {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .recommendation-cards {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 1rem;
    }
}