/**
 * SideMind Hub - Design System
 * Synaptica Dark Theme (matches SideMind Bot design system)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --brand-primary: #007acc;
    --brand-light: #00aaff;
    --brand-accent: #00d4ff;
    --brand-dark: #0a0a0f;

    --surface-dark: #0d0d14;
    --surface-card: #12121a;
    --surface-hover: #1a1a24;
    --surface-border: rgba(255, 255, 255, 0.1);

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-tertiary: #6b6b80;

    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--brand-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* --- Layout --- */
.hub-header {
    background: var(--surface-dark);
    border-bottom: 1px solid var(--surface-border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hub-header__title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hub-header__subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: 12px;
}

.hub-nav {
    display: flex;
    gap: 8px;
}

.hub-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.hub-nav a:hover { background: var(--surface-hover); color: var(--text-primary); }
.hub-nav a.active { background: var(--brand-primary); color: white; }

.hub-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* --- Stats Row --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-card__value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card__label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card--success .stat-card__value { color: var(--success); }
.stat-card--danger .stat-card__value { color: var(--danger); }
.stat-card--warning .stat-card__value { color: var(--warning); }
.stat-card--info .stat-card__value { color: var(--info); }
.stat-card--primary .stat-card__value { color: var(--brand-accent); }

/* --- Instance Grid --- */
.instance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.instance-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.instance-card:hover {
    border-color: var(--brand-primary);
    transform: translateY(-2px);
}

.instance-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.instance-card__name {
    font-size: 16px;
    font-weight: 600;
}

.instance-card__id {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: monospace;
}

.instance-card__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.instance-card__field {
    font-size: 12px;
}

.instance-card__field-label {
    color: var(--text-tertiary);
    display: block;
    margin-bottom: 2px;
}

.instance-card__field-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge--online { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge--offline { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge--degraded { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge--unknown { background: rgba(107, 107, 128, 0.15); color: var(--text-tertiary); }

.badge--active { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge--trial { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge--expired { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge--suspended { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.badge--critical { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge--error { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge--warning { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge--info { background: rgba(107, 107, 128, 0.15); color: var(--text-tertiary); }

/* --- Table --- */
.hub-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--surface-border);
}

.hub-table th {
    background: var(--surface-dark);
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--surface-border);
}

.hub-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--surface-border);
}

.hub-table tr:hover td {
    background: var(--surface-hover);
}

.hub-table tr:last-child td {
    border-bottom: none;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn--primary {
    background: var(--brand-primary);
    color: white;
}

.btn--primary:hover {
    background: var(--brand-light);
}

.btn--sm {
    padding: 4px 10px;
    font-size: 11px;
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
}

.btn--ghost:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* --- Filters --- */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filters select,
.filters input {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
}

.filters select option {
    background: var(--surface-card);
    color: var(--text-primary);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal__title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal__close {
    float: right;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 20px;
    cursor: pointer;
}

.modal__close:hover { color: var(--text-primary); }

pre.stack-trace {
    background: var(--surface-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    color: var(--danger);
    max-height: 300px;
    overflow-y: auto;
}

/* --- Utilities --- */
.text-muted { color: var(--text-tertiary); }
.text-sm { font-size: 12px; }
.text-mono { font-family: monospace; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-tertiary);
}

.empty-state__icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* --- Refresh indicator --- */
.refresh-indicator {
    font-size: 11px;
    color: var(--text-tertiary);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading { animation: pulse 1.5s infinite; }
