/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary-color);
    animation: pulse 2s infinite;
}

.status-indicator.connected .status-dot {
    background: var(--success-color);
}

.status-indicator.streaming .status-dot {
    background: var(--primary-color);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-stream {
    background: var(--success-color);
    color: white;
}

.btn-stream[data-streaming="true"] {
    background: var(--error-color);
}

/* Quick Filters */
.quick-filters {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 15px 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 12px;
    align-items: center;
}

.quick-filter-group {
    min-width: 150px;
}

.quick-filter-group.flex-grow {
    flex: 1;
}


.form-control-sm {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-primary);
    width: 100%;
}

.form-control-sm:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* Advanced Filters Panel */
.filters-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 0;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
}

.filters-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.filters-content {
    padding: 20px 25px;
    overflow: visible;
}

.filters-content.collapsed {
    max-height: 0;
    padding: 0 25px;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filters-row:last-child {
    margin-bottom: 0;
    display: flex;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.filter-group.flex-grow {
    flex: 1;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-left: auto;
}

/* Stats Bar */
.stats-bar {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 15px 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 30px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 700;
}

/* Logs Container */
.logs-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-height: 600px;
    max-height: 800px;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 600px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
}

/* Log Entries */
.logs-content {
    padding: 10px;
}

.log-entry {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    padding: 15px;
    transition: all 0.2s;
    cursor: pointer;
}

.log-entry:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.log-level {
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.log-level.error { background: #fee2e2; color: #991b1b; }
.log-level.warn { background: #fef3c7; color: #92400e; }
.log-level.info { background: #dbeafe; color: #1e40af; }
.log-level.debug { background: #e0e7ff; color: #3730a3; }
.log-level.verbose { background: #f3e8ff; color: #6b21a8; }
.log-level.silly { background: #fce7f3; color: #9f1239; }

.log-timestamp {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.log-ids {
    display: flex;
    gap: 8px;
    margin-left: auto;
    font-size: 11px;
}

.log-id {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

.log-message {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

/* Group Container */
.log-group {
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
}

.log-group-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-group-title {
    font-size: 14px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.log-group-summary {
    display: flex;
    gap: 15px;
    font-size: 12px;
}

.log-group-content {
    padding: 15px;
    background: var(--bg-secondary);
}

.log-group-content .log-entry {
    margin-bottom: 10px;
}

/* Pagination */
.pagination {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-tertiary);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.detail-row {
    margin-bottom: 20px;
}

.detail-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.detail-value pre {
    margin: 0;
    white-space: pre-wrap;
}

.clickable-trace-id {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: underline;
    transition: all 0.2s;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
}

.clickable-trace-id:hover {
    background: rgba(37, 99, 235, 0.1);
    text-decoration: none;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-primary);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 15px 20px;
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: var(--success-color); }
.toast.error { border-left-color: var(--error-color); }
.toast.warning { border-left-color: var(--warning-color); }

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 14px;
    color: var(--text-secondary);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Loading Spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

/* Responsive */
@media (max-width: 1200px) {
    .filters-row {
        grid-template-columns: 1fr;
    }

    .filter-group {
        width: 100%;
    }

    .filter-actions {
        margin-left: 0;
        width: 100%;
    }

    .quick-filters {
        flex-direction: column;
        gap: 10px;
    }

    .quick-filter-group {
        width: 100%;
    }
}
