/**
 * Observability Dashboard Styles
 * LLM call tracking, statistics, and debugging interface
 */

/* Container */
.obs-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    overflow: hidden;
}

/* Header */
.obs-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

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

.obs-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close-obs {
    background: none;
    border: none;
    color: var(--text-secondary, #aaa);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close-obs:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #fff);
}

/* Filters */
.obs-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.obs-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.obs-filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
}

.obs-filter-group select {
    padding: 0.4rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-primary, #fff);
    font-size: 0.85rem;
}

.btn-apply-filters {
    padding: 0.4rem 1rem;
    background: var(--primary, #4a90d9);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-apply-filters:hover {
    background: var(--primary-hover, #5da0e9);
}

#obsAutoRefreshBtn {
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: var(--text-primary, #fff);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

#obsAutoRefreshBtn.active {
    background: var(--success, #28a745);
    border-color: var(--success, #28a745);
}

/* Content */
.obs-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Stats Grid */
.obs-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.obs-stat-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    transition: transform 0.2s;
}

.obs-stat-card:hover {
    transform: translateY(-2px);
}

.obs-stat-card.warning {
    border-color: var(--warning, #ffc107);
}

.obs-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary, #4a90d9);
    margin-bottom: 0.25rem;
}

.obs-stat-card.warning .obs-stat-value {
    color: var(--warning, #ffc107);
}

.obs-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
    margin-bottom: 0.25rem;
}

.obs-stat-detail,
.obs-stat-period {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Breakdown Section */
.obs-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.obs-breakdown-section h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #aaa);
}

.obs-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.obs-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(74, 144, 217, 0.2);
    border: 1px solid rgba(74, 144, 217, 0.3);
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-primary, #fff);
}

/* Calls Table */
.obs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.obs-table th {
    text-align: left;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary, #aaa);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.obs-table td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.obs-call-row {
    cursor: pointer;
    transition: background 0.2s;
}

.obs-call-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.obs-call-row.error {
    background: rgba(220, 53, 69, 0.1);
}

.obs-call-row.error:hover {
    background: rgba(220, 53, 69, 0.2);
}

.obs-timestamp {
    white-space: nowrap;
    color: var(--text-secondary, #aaa);
}

.obs-provider {
    font-weight: 500;
}

.obs-model {
    font-family: monospace;
    font-size: 0.8rem;
}

.obs-status {
    text-align: center;
}

.obs-duration {
    font-family: monospace;
    text-align: right;
}

.obs-duration.fast {
    color: var(--success, #28a745);
}

.obs-duration.medium {
    color: var(--warning, #ffc107);
}

.obs-duration.slow {
    color: var(--danger, #dc3545);
}

.obs-tokens {
    font-family: monospace;
    text-align: right;
    color: var(--text-secondary, #aaa);
}

.obs-preview {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary, #aaa);
}

/* Empty State */
.obs-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary, #aaa);
}

.obs-empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.obs-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Error State */
.obs-error {
    text-align: center;
    padding: 2rem;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 8px;
    margin: 1rem;
}

.obs-error-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.obs-error-detail {
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
    margin-bottom: 1rem;
}

.btn-retry {
    padding: 0.5rem 1.5rem;
    background: var(--primary, #4a90d9);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

/* Detail Modal */
.obs-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.obs-modal.active {
    display: flex;
}

.obs-modal-content {
    background: var(--bg-primary, #1a1a2e);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.obs-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.obs-modal-header h3 {
    margin: 0;
}

.obs-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #aaa);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.obs-modal-close:hover {
    color: var(--text-primary, #fff);
}

.obs-modal-body {
    padding: 1.5rem;
}

/* Detail View */
.obs-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.obs-status-large {
    font-size: 1.1rem;
    font-weight: 600;
}

.obs-status-large.success {
    color: var(--success, #28a745);
}

.obs-status-large.error {
    color: var(--danger, #dc3545);
}

.obs-timestamp-large {
    color: var(--text-secondary, #aaa);
}

.obs-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.obs-detail-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem;
    border-radius: 6px;
}

.obs-detail-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary, #aaa);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.obs-detail-item span {
    font-size: 0.95rem;
    font-weight: 500;
}

.obs-detail-section {
    margin-bottom: 1rem;
}

.obs-detail-section h4 {
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
}

.obs-detail-section pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.obs-detail-section.error {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 8px;
    padding: 1rem;
}

.obs-detail-section.error h4 {
    color: var(--danger, #dc3545);
}

/* Responsive */
@media (max-width: 768px) {
    .obs-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .obs-filter-group {
        justify-content: space-between;
    }

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

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

    .obs-table th,
    .obs-table td {
        padding: 0.5rem;
    }

    .obs-preview {
        display: none;
    }
}
