/* Timeline Viewer Styles */
/* OpenAI-style conversation viewer with purple gradient theme */

/* Page Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.2rem;
    margin: 0 0 10px 0;
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: 2px solid transparent;
}

.btn-secondary:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.timeline-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
    height: calc(100vh - 180px);
}

/* Left Panel: Timeline List */
.timeline-list-panel {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.panel-header h2 {
    margin: 0 0 15px 0;
    font-size: 1.5rem;
}

.search-bar {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.search-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.filter-controls {
    margin-top: 10px;
}

.filter-controls label {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.sort-select {
    width: 100%;
    padding: 8px 12px;
    margin-top: 5px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    cursor: pointer;
}

.sort-select:focus {
    outline: none;
    background: white;
}

.timeline-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Timeline Cards */
.timeline-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.timeline-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.timeline-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.timeline-time {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.timeline-badges {
    font-size: 14px;
}

.timeline-card-body {
    font-size: 13px;
}

.timeline-info {
    margin-bottom: 8px;
    color: #6b7280;
}

.timeline-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.stat {
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 3px 8px;
    border-radius: 4px;
}

.timeline-tools {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.tool-badge {
    font-size: 11px;
    background: #fef3c7;
    color: #92400e;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.timeline-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.timeline-meta small {
    color: #9ca3af;
    font-size: 11px;
}

/* Right Panel: Timeline Detail */
.timeline-detail-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.timeline-detail {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
    padding: 40px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    color: #6b7280;
    margin-bottom: 10px;
}

.empty-state p {
    color: #9ca3af;
    max-width: 400px;
}

.empty-state-small {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

/* Detail Header */
.detail-header {
    margin-bottom: 25px;
}

.detail-header h2 {
    margin: 0 0 20px 0;
    color: #111827;
    font-size: 1.75rem;
}

.detail-meta {
    background: #f9fafb;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    color: #374151;
}

.meta-row:last-child {
    margin-bottom: 0;
}

/* Recording Player */
.recording-player {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.recording-player h3 {
    color: white;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

.audio-player {
    width: 100%;
    margin-bottom: 15px;
    border-radius: 8px;
}

.recording-player .btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.recording-player .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.recording-player .recording-note {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* Summary Stats */
.detail-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.summary-stat {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 10px;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Conversation Timeline */
.conversation-timeline h3 {
    margin: 0 0 20px 0;
    color: #111827;
    font-size: 1.3rem;
}

.events-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Event Styles */
.event {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.event-time {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    padding-top: 8px;
    min-width: 40px;
    text-align: right;
}

.event-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

/* User Speech - Right aligned, blue/purple */
.event-user {
    flex-direction: row-reverse;
}

.event-user .event-time {
    text-align: left;
}

.event-bubble-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Agent Response - Left aligned, gray */
.event-agent {
    flex-direction: row;
}

.event-bubble-agent {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 4px;
}

/* Tool Call - Yellow/orange card */
.event-tool-call {
    flex-direction: row;
}

.event-bubble-tool {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 10px;
    padding: 12px;
    max-width: 80%;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #92400e;
}

.tool-icon {
    font-size: 16px;
}

.tool-name {
    flex: 1;
    font-size: 14px;
}

.tool-call-toggle {
    background: none;
    border: none;
    color: #92400e;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.tool-call-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.tool-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 0;
}

.tool-details.expanded {
    max-height: 500px;
    margin-top: 10px;
}

.tool-details pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #92400e;
    overflow-x: auto;
    margin: 0;
}

/* Tool Result */
.event-tool-result {
    flex-direction: row;
}

.event-bubble-tool-result {
    background: #d1fae5;
    border: 1px solid #10b981;
    border-radius: 10px;
    padding: 12px;
    max-width: 80%;
}

.event-bubble-tool-result.error {
    background: #fee2e2;
    border-color: #ef4444;
}

.tool-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    color: #065f46;
}

.event-bubble-tool-result.error .tool-result-header {
    color: #991b1b;
}

.tool-duration {
    font-size: 11px;
    font-weight: normal;
    color: #6b7280;
}

.tool-result-content {
    font-size: 13px;
    color: #047857;
    line-height: 1.5;
}

.event-bubble-tool-result.error .tool-result-content {
    color: #991b1b;
}

/* System Events */
.event-system {
    justify-content: center;
    text-align: center;
}

.event-system-message {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Loading and Error States */
.loading {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-size: 14px;
}

.error-message {
    text-align: center;
    padding: 40px;
    color: #ef4444;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .timeline-container {
        grid-template-columns: 300px 1fr;
    }

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

@media (max-width: 768px) {
    .timeline-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .timeline-list-panel {
        max-height: 400px;
    }

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

    .event-bubble {
        max-width: 85%;
    }
}

/* Custom Scrollbar */
.timeline-list::-webkit-scrollbar,
.timeline-detail::-webkit-scrollbar {
    width: 8px;
}

.timeline-list::-webkit-scrollbar-track,
.timeline-detail::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.timeline-list::-webkit-scrollbar-thumb,
.timeline-detail::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.timeline-list::-webkit-scrollbar-thumb:hover,
.timeline-detail::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Transcript Toggle Tabs */
.transcript-tabs {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e5e7eb;
    background: white;
    color: #6b7280;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
