/* ===== VARIABLES ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #475569;
    --border-light: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-progress-container {
    width: 300px;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.loading-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.loading-percentage {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loading-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Loading Info - Layout horizontal compacto */
.loading-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 300px;
}

.loading-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-light);
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
        box-shadow: 0 0 8px 2px rgba(99, 102, 241, 0.3);
    }
}

/* ===== LAYOUT ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.75rem 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 0.75rem;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.375rem;
    font-size: 0.9rem;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-input);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-item i {
    width: 22px;
    text-align: center;
    font-size: 1rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem 3rem;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1.25rem;
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.status-badge.healthy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--secondary);
    border-color: rgba(34, 197, 94, 0.3);
}

.status-badge.degraded {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ===== GRID ===== */
.grid {
    display: grid;
    gap: 1.75rem;
}

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

@media (max-width: 1400px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .main-content { padding: 2rem; }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 1.5rem; }
}

/* ===== STATS CARDS ===== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.75rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 1.25rem;
}

.stat-icon.blue { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.stat-icon.green { background: rgba(34, 197, 94, 0.15); color: var(--secondary); }
.stat-icon.orange, .stat-icon.yellow { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.stat-icon.gray { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== TABLES ===== */
.table-container {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 1.125rem 1.25rem;
    text-align: left;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border);
}

td {
    border-bottom: 1px solid var(--border);
}

tr:hover td {
    background: rgba(51, 65, 85, 0.5);
}

tr:last-child td {
    border-bottom: none;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    border-color: var(--border-light);
}

.btn-sm {
    padding: 0.625rem 1.125rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.875rem 1.125rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

.form-textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.6;
}

/* ===== CHAT ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 650px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.chat-message {
    max-width: 75%;
    padding: 1.125rem 1.375rem;
    border-radius: var(--radius-lg);
    line-height: 1.65;
    font-size: 0.925rem;
}

.chat-message.user {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.chat-message.assistant {
    background: var(--bg-input);
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border);
}

.chat-message pre {
    background: var(--bg-dark);
    padding: 1.125rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.75rem 0;
    border: 1px solid var(--border);
}

.chat-message code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
}

.chat-input-container {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(30, 41, 59, 0.5);
}

.chat-input {
    flex: 1;
}

/* Chat Details (collapsible) */
.chat-details-container {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.chat-details {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.chat-details summary {
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.4rem 0;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-details summary:hover {
    color: var(--primary-light);
}

.chat-details summary i {
    font-size: 0.8rem;
}

.chat-details .details-content {
    padding: 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
}

.chat-details .details-content p {
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chat-details .details-content p:last-child {
    margin-bottom: 0;
}

/* ===== LOADING ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0.625rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 1rem 1.75rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-weight: 500;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(51, 65, 85, 0.3);
}

.tab.active {
    background: var(--primary);
    color: white;
    border-bottom-color: var(--primary);
}

/* ===== JSON VIEWER ===== */
.json-viewer {
    background: #0d1117;
    padding: 1.5rem;
    border-radius: var(--radius);
    font-family: 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    line-height: 1.8;
    white-space: pre;
    tab-size: 2;
}

.json-viewer::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.json-viewer::-webkit-scrollbar-track {
    background: #161b22;
    border-radius: 5px;
}

.json-viewer::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 5px;
}

.json-viewer::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

.json-key {
    color: #79c0ff;
    font-weight: 500;
}

.json-string {
    color: #a5d6ff;
}

.json-number {
    color: #ffa657;
    font-weight: 500;
}

.json-boolean {
    color: #ff7b72;
    font-weight: 600;
}

.json-null {
    color: #8b949e;
    font-style: italic;
}

/* ===== SECTIONS ===== */
.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== COLLECTION LIST ===== */
.collection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.125rem 1.25rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    margin-bottom: 0.625rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.collection-item:hover {
    background: var(--border);
    border-color: var(--border-light);
    transform: translateX(4px);
}

.collection-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.collection-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 1.125rem 1.5rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    font-size: 0.9rem;
}

.toast.success { border-left: 4px solid var(--secondary); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== MARKDOWN CONTENT ===== */
.markdown-content {
    line-height: 1.75;
}

.markdown-content h1, .markdown-content h2, .markdown-content h3 {
    margin: 1.25rem 0 0.75rem;
    line-height: 1.3;
}

.markdown-content h1 { font-size: 1.6rem; }
.markdown-content h2 { font-size: 1.35rem; color: var(--primary-light); }
.markdown-content h3 { font-size: 1.15rem; }

.markdown-content ul, .markdown-content ol {
    margin: 0.75rem 0;
    padding-left: 1.75rem;
}

.markdown-content li {
    margin: 0.375rem 0;
}

.markdown-content p {
    margin: 0.75rem 0;
}

.markdown-content strong {
    color: var(--primary-light);
    font-weight: 600;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ===== QUICK ACTIONS ===== */
.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ===== UTILITY CLASSES ===== */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-small { font-size: 0.85rem; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* ===== STATUS DOT ===== */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    background: var(--text-secondary);
}

.status-dot.online,
.status-badge.healthy .status-dot {
    background: var(--secondary);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-dot.offline,
.status-badge.error .status-dot {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.status-badge.warning .status-dot {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-info {
    background: rgba(6, 182, 212, 0.15);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-secondary {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ===== API MONITOR STYLES ===== */
.api-card {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.api-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.api-card.online {
    border-left: 3px solid var(--secondary);
}

.api-card.offline {
    border-left: 3px solid var(--danger);
}

/* ===== BG TERTIARY ===== */
:root {
    --bg-tertiary: rgba(51, 65, 85, 0.4);
}
