/* ============================================================
   Gateway 管理页 — 样式
   ============================================================ */

:root {
    --bg-dark: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #252830;
    --bg-hover: #2a2d38;
    --border: #2e3140;
    --text: #e1e4ec;
    --text-dim: #8b8fa3;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --blue: #3b82f6;
    --cyan: #06b6d4;
    --purple: #a855f7;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ============================================================
   顶部导航
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 16px; font-weight: 600; }
.topbar-logo { font-size: 24px; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-dim); }

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 6px;
    transition: all 0.2s;
}
.back-link:hover { background: rgba(99, 102, 241, 0.2); color: var(--accent-hover); }

.version-badge {
    font-size: 11px;
    color: var(--text-dim);
    padding: 2px 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
}

.conn-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.conn-badge.online { background: rgba(34,197,94,0.15); color: var(--green); }
.conn-badge.offline { background: rgba(239,68,68,0.15); color: var(--red); }
.conn-badge.checking { background: rgba(234,179,8,0.15); color: var(--yellow); }

/* ============================================================
   页面内容
   ============================================================ */
.page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 60px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.section-header h3 { font-size: 18px; font-weight: 600; }

section { margin-bottom: 32px; }

/* ============================================================
   基本信息
   ============================================================ */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.info-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.5;
}

/* ============================================================
   请求统计
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(99,102,241,0.06) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}
.stat-number {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, var(--cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-label {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 4px;
}
.stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 24px;
    opacity: 0.3;
}
.stat-total {
    text-align: center;
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 12px;
    padding: 8px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
}

/* ============================================================
   Redis 状态
   ============================================================ */
.redis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.redis-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.redis-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.redis-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   Workflow 管理
   ============================================================ */
.workers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.worker-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}
.worker-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.worker-card.online { border-left: 3px solid var(--green); }
.worker-card.offline { border-left: 3px solid var(--red); }
.worker-card.disabled { border-left: 3px solid var(--text-dim); opacity: 0.6; }

.worker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.worker-name {
    font-size: 15px;
    font-weight: 600;
}
.worker-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.worker-status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.worker-status-dot.offline { background: var(--red); }
.worker-status-dot.disabled { background: var(--text-dim); }

.worker-meta {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 2;
}
.worker-meta strong { color: var(--text); font-weight: 500; }

.worker-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.workers-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
    font-size: 15px;
}

/* ============================================================
   日志查看器
   ============================================================ */
.log-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}
.log-search-input {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    width: 200px;
    outline: none;
}
.log-search-input:focus { border-color: var(--accent); }

.time-range-picker {
    display: flex;
    gap: 4px;
}
.time-value-input {
    width: 60px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    text-align: center;
}
.time-unit-select {
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.log-output {
    background: #0a0c10;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    height: 300px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.8;
}
.log-placeholder {
    color: var(--text-dim);
    text-align: center;
    padding: 60px 0;
}

/* ============================================================
   弹窗
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 440px;
    max-width: 90%;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}
.modal-close:hover { color: var(--text); background: var(--bg-hover); }

.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.input-group { margin-bottom: 16px; }
.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.input-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border 0.2s;
}
.input-group input:focus { border-color: var(--accent); }
.input-hint {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ============================================================
   按钮
   ============================================================ */
.btn-primary {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-sm {
    padding: 6px 14px;
    background: var(--bg-input);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-sm:hover { background: var(--bg-hover); color: var(--text); }

.btn-add {
    background: rgba(34,197,94,0.1);
    color: var(--green);
    border-color: rgba(34,197,94,0.3);
}
.btn-add:hover { background: rgba(34,197,94,0.2); }

.btn-enable { background: rgba(34,197,94,0.1); color: var(--green); border-color: rgba(34,197,94,0.3); }
.btn-disable { background: rgba(234,179,8,0.1); color: var(--yellow); border-color: rgba(234,179,8,0.3); }
.btn-delete { background: rgba(239,68,68,0.1); color: var(--red); border-color: rgba(239,68,68,0.3); }

/* ============================================================
   底部状态栏
   ============================================================ */
.status-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 28px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 11px;
    color: var(--text-dim);
    z-index: 100;
}
.status-bar-left, .status-bar-right { display: flex; align-items: center; gap: 16px; }

.heartbeat-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 4px;
    animation: heartbeat 2s ease-in-out infinite;
    box-shadow: 0 0 4px var(--green);
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================================
   滚动条
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
