/*
 * 灵犀系统 — 仪表盘样式
 * 设计基准：Linear DESIGN.md（dark-mode-native）
 * 颜色体系：极暗画布 + 半透明白边框 + 靛紫强调色
 */

/* ─── Fonts ──────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* Background Surfaces */
    --bg-canvas: #08090a;
    --bg-panel: #0f1011;
    --bg-elevated: #191a1b;
    --bg-hover: #28282c;

    /* Text */
    --text-primary: #f7f8f8;
    --text-secondary: #d0d6e0;
    --text-tertiary: #8a8f98;
    --text-quaternary: #62666d;

    /* Brand Accent */
    --accent: #5e6ad2;
    --accent-bright: #7170ff;
    --accent-hover: #828fff;

    /* Status */
    --green: #27a644;
    --emerald: #10b981;
    --red: #ef4444;
    --amber: #f59e0b;

    /* Border */
    --border-subtle: rgba(255,255,255,0.05);
    --border-standard: rgba(255,255,255,0.08);
    --border-solid: #23252a;

    /* Surfaces */
    --surface-1: rgba(255,255,255,0.02);
    --surface-2: rgba(255,255,255,0.04);
    --surface-3: rgba(255,255,255,0.05);

    /* Layout */
    --sidebar-w: 220px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    font-feature-settings: "cv01", "ss03";
    font-weight: 400;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-canvas);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar ────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.logo {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: -0.3px;
    padding: 20px 20px 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.nav-list {
    list-style: none;
    flex: 1;
    padding: 4px 8px;
}

.nav-item {
    padding: 8px 12px;
    margin: 1px 0;
    cursor: pointer;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.13px;
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text-secondary);
}
.nav-item.active {
    background: var(--surface-3);
    color: var(--text-primary);
}
.nav-icon { font-size: 16px; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-quaternary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}
.status-dot.degraded { background: var(--amber); }
.status-dot.offline { background: var(--red); }

/* ─── Main Content ───────────────────────── */
.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar h1 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: var(--text-primary);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn {
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid var(--border-solid);
    background: var(--surface-1);
    color: var(--text-secondary);
    letter-spacing: -0.13px;
}
.btn:hover { background: var(--surface-3); color: var(--text-primary); }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.center-content {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
}

/* ─── Cards ──────────────────────────────── */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    transition: border-color 0.15s ease;
}
.card:hover { border-color: rgba(255,255,255,0.12); }

.card-header {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-quaternary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

/* ─── Stat Grid ──────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface-1);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.stat-value {
    font-size: 32px;
    font-weight: 500;
    letter-spacing: -0.704px;
    color: var(--text-primary);
    line-height: 1.1;
}
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-quaternary);
    margin-top: 6px;
    letter-spacing: 0.2px;
}

/* ─── Badges ─────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: -0.1px;
    gap: 4px;
}
.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
}
.badge-ok { background: rgba(39,166,68,0.12); color: var(--green); }
.badge-ok::before { background: var(--green); }
.badge-warn { background: rgba(245,158,11,0.12); color: var(--amber); }
.badge-warn::before { background: var(--amber); }
.badge-err { background: rgba(239,68,68,0.12); color: var(--red); }
.badge-err::before { background: var(--red); }
.badge-info { background: rgba(94,106,210,0.12); color: var(--accent-bright); }
.badge-info::before { background: var(--accent-bright); }

/* ─── Table ──────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    padding: 8px 12px;
    font-weight: 500;
    font-size: 11px;
    color: var(--text-quaternary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-subtle);
}
.table td {
    padding: 10px 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}
.table tr:hover td { background: var(--surface-1); }

/* ─── Device Cards ───────────────────────── */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.device-card {
    background: var(--surface-1);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.device-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.device-meta {
    font-size: 12px;
    color: var(--text-quaternary);
    line-height: 1.8;
}

/* ─── Chat Panel ─────────────────────────── */
.chat-panel {
    position: fixed;
    right: 0; top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: rgba(0,0,0,0.4) -4px 0 24px;
}
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-header h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}
.chat-close {
    cursor: pointer;
    color: var(--text-quaternary);
    font-size: 18px;
    background: none;
    border: none;
}
.chat-close:hover { color: var(--text-primary); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.chat-msg {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: 1.6;
    max-width: 85%;
}
.chat-msg.user {
    background: var(--accent);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: var(--radius-sm);
}
.chat-msg.assistant {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 8px;
}
.chat-input-area input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.chat-input-area input:focus { border-color: var(--accent); }
.chat-input-area input::placeholder { color: var(--text-quaternary); }
.chat-input-area button {
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.chat-input-area button:hover { background: var(--accent-hover); }

/* ─── Misc ───────────────────────────────── */
.loading {
    text-align: center;
    color: var(--text-quaternary);
    padding: 60px 20px;
    font-size: 13px;
}
.empty-state {
    text-align: center;
    color: var(--text-quaternary);
    padding: 40px;
    font-size: 13px;
}

.progress-bar {
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ─── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
