/* ═══════════════════════════════════════════
   飞鹰总控系统 - Dashboard 样式
   ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-card-hover: #252839;
    --bg-input: #252839;
    --border: #2a2d3e;
    --text-primary: #e4e6f0;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6078;
    --accent: #4f7cff;
    --accent-hover: #3d6af0;
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.15);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.15);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251, 191, 36, 0.15);
    --orange: #fb923c;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ─── 登录页 ──────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1d27 50%, #0f1117 100%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 400px;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-logo {
    color: var(--accent);
    margin-bottom: 16px;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.input-group {
    margin-bottom: 16px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--accent);
}

.error-text {
    color: var(--red);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* ─── 按钮 ────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover { background: var(--bg-card-hover); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-block { width: 100%; margin-top: 8px; padding: 12px; }

.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }

/* ─── 顶部导航 ────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-center { display: flex; }

.tabs {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 6px 16px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover { color: var(--text-primary); background: var(--bg-card); }
.tab.active { color: var(--accent); background: rgba(79, 124, 255, 0.1); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }

.badge {
    background: var(--red);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.user-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ─── 内容区 ──────────────────────────────── */
.content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ─── 统计卡片 ────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.servers { background: rgba(79, 124, 255, 0.15); }
.stat-icon.devices { background: var(--green-dim); }
.stat-icon.total { background: var(--yellow-dim); }
.stat-icon.alerts { background: var(--red-dim); }

.stat-icon::after {
    font-size: 20px;
}

.stat-icon.servers::after { content: '🖥'; }
.stat-icon.devices::after { content: '📱'; }
.stat-icon.total::after { content: '📊'; }
.stat-icon.alerts::after { content: '🔔'; }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ─── 服务器卡片 ──────────────────────────── */
.server-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.server-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.2s;
}

.server-card:hover { border-color: var(--accent); }

.server-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.server-card-name {
    font-size: 15px;
    font-weight: 600;
}

.server-card-status {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.server-card-status.online { background: var(--green-dim); color: var(--green); }
.server-card-status.offline { background: var(--red-dim); color: var(--red); }
.server-card-status.maintenance { background: var(--yellow-dim); color: var(--yellow); }

.server-card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.metric-item {
    text-align: center;
}

.metric-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.metric-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.metric-fill.green { background: var(--green); }
.metric-fill.yellow { background: var(--yellow); }
.metric-fill.red { background: var(--red); }

.metric-value {
    font-size: 13px;
    font-weight: 600;
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
}

.server-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.device-count {
    font-size: 13px;
    color: var(--text-secondary);
}

.device-count strong {
    color: var(--accent);
    font-size: 18px;
}

/* ─── 数据表格 ────────────────────────────── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.input-sm {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    min-width: 140px;
}

.input-sm:focus { border-color: var(--accent); }

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.online { background: var(--green-dim); color: var(--green); }
.status-badge.offline { background: var(--red-dim); color: var(--red); }
.status-badge.pending { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.in_progress { background: rgba(79, 124, 255, 0.15); color: var(--accent); }
.status-badge.completed { background: var(--green-dim); color: var(--green); }
.status-badge.failed { background: var(--red-dim); color: var(--red); }
.status-badge.info { background: rgba(79, 124, 255, 0.15); color: var(--accent); }
.status-badge.warning { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.critical { background: var(--red-dim); color: var(--red); }

/* ─── 分页 ────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}

.pagination button:hover { background: var(--bg-card-hover); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ─── 弹窗 ────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    min-width: 380px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}

.modal-content h3 {
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ─── Toast ───────────────────────────────── */
.toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast.success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.toast.error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.3); }
.toast.warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.3); }
.toast.info { background: rgba(79, 124, 255, 0.15); color: var(--accent); border: 1px solid rgba(79, 124, 255, 0.3); }

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

/* ─── 可点击元素 ─────────────────────────── */
.clickable { cursor: pointer; }

.server-card.clickable:active {
    transform: scale(0.98);
}

.server-tag {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    white-space: nowrap;
}

.server-tag.clickable:hover {
    opacity: 0.8;
    cursor: pointer;
}

.link-devices {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.link-devices:hover {
    text-decoration: underline;
}

/* ─── 筛选提示条 ─────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: rgba(79, 124, 255, 0.08);
    border: 1px solid rgba(79, 124, 255, 0.2);
    border-radius: var(--radius);
}

.filter-bar-text {
    font-size: 13px;
    color: var(--accent);
}

.filter-bar-text strong {
    color: var(--text-primary);
}

/* ─── 响应式 ──────────────────────────────── */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .server-cards-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .content { padding: 16px; }
    .tab { padding: 6px 10px; font-size: 13px; }
    .topbar-title { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
