/* ============================================================
   FastCore Suite 控制管理端 - 样式
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f0f2f5;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --blue: #3b82f6;
    --green: #22c55e;
    --orange: #f59e0b;
    --purple: #8b5cf6;
    --red: #ef4444;
    --gray: #94a3b8;
}

body {
    font-family: -apple-system, "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

/* ====== 登录页 ====== */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo { text-align: center; margin-bottom: 30px; }
.logo-big {
    width: 64px; height: 64px;
    background: var(--blue);
    color: #fff;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}
.login-title { font-size: 20px; font-weight: 600; }
.login-sub { color: var(--text-light); font-size: 13px; margin-top: 4px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border 0.2s;
}
.login-form input:focus { outline: none; border-color: var(--blue); }

.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-login:hover { background: #2563eb; }

.alert-error {
    background: #fef2f2;
    color: var(--red);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* ====== 主布局 ====== */
.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo {
    width: 36px; height: 36px;
    background: var(--blue);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.logo-title { color: #fff; font-weight: 600; font-size: 15px; }
.logo-sub { color: rgba(255,255,255,0.5); font-size: 11px; }

.nav { flex: 1; padding: 12px 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); }
.nav-item.logout { color: rgba(255,255,255,0.4); }
.nav-item.logout:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* 主内容 */
.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.page-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.search-box { position: relative; width: 280px; }
.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}
.search-box input:focus { outline: none; border-color: var(--blue); }
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    max-height: 300px;
    overflow-y: auto;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
}
.search-result-item:hover { background: #f8fafc; }
.search-result-item:last-child { border-bottom: none; }

.user-info {
    color: var(--text-light);
    font-size: 13px;
    white-space: nowrap;
}

.content { padding: 24px; flex: 1; }

/* ====== 统计卡片 ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    border-left: 4px solid var(--blue);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card.stat-blue { border-left-color: var(--blue); }
.stat-card.stat-green { border-left-color: var(--green); }
.stat-card.stat-orange { border-left-color: var(--orange); }
.stat-card.stat-purple { border-left-color: var(--purple); }
.stat-card.stat-red { border-left-color: var(--red); }
.stat-card.stat-gray { border-left-color: var(--gray); }

.stat-label { color: var(--text-light); font-size: 12px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-sub { color: var(--text-light); font-size: 12px; }

/* ====== 图表 ====== */
.chart-section { margin-bottom: 24px; }
.chart-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.chart-header h3 { font-size: 15px; font-weight: 600; }
.chart-legend { font-size: 12px; color: var(--text-light); display: flex; gap: 12px; align-items: center; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot-blue { background: var(--blue); }
.dot-green { background: var(--green); }
.chart-body { height: 280px; }

/* ====== 快捷操作 ====== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.action-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.action-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.action-icon { font-size: 24px; color: var(--blue); }
.action-text { font-weight: 600; font-size: 15px; }
.action-desc { color: var(--text-light); font-size: 12px; }

/* ====== 数据表格 ====== */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.badge-info {
    background: #eff6ff;
    color: var(--blue);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
}
.hint { color: var(--text-light); font-size: 12px; }

.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-collapse: collapse;
}
.data-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.mono { font-family: "Cascadia Code", "Consolas", monospace; font-size: 12px; }
.num { font-weight: 600; }
.empty-row { text-align: center; color: var(--text-light); padding: 40px 16px; }
.action-cell { white-space: nowrap; }

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.status-active { background: #dcfce7; color: #16a34a; }
.status-expired { background: #fee2e2; color: #dc2626; }
.status-suspended { background: #fef3c7; color: #d97706; }
.status-inactive { background: #f1f5f9; color: #64748b; }
.status-pending { background: #fef3c7; color: #d97706; }

/* 按钮 */
.btn-sm {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    transition: opacity 0.15s;
}
.btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm:hover { opacity: 0.85; }
.btn-view { background: var(--blue); }
.btn-danger { background: var(--red); }
.btn-save { background: var(--green); }
.btn-refresh { background: var(--text-light); }
.btn-back { background: var(--gray); }
.btn-page { background: var(--blue); }
.pagination { display: flex; gap: 8px; }

/* ====== 参数配置 ====== */
.config-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.config-layout {
    display: flex;
    gap: 16px;
    height: calc(100vh - 200px);
}

.config-sidebar {
    width: 240px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow-y: auto;
}
.config-sidebar-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.config-file-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.config-file-item:hover { background: #f8fafc; }
.config-file-item.active { background: #eff6ff; color: var(--blue); }
.file-icon { font-size: 14px; }
.file-error { color: var(--red); font-size: 11px; margin-left: auto; }

.config-editor {
    flex: 1;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.editor-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.editor-filename { font-weight: 600; font-size: 13px; }
.code-editor {
    flex: 1;
    border: none;
    padding: 16px;
    font-family: "Cascadia Code", "Consolas", monospace;
    font-size: 13px;
    resize: none;
    outline: none;
    line-height: 1.6;
    background: #fafafa;
}
.editor-status {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-light);
}
.editor-status.status-ok { color: var(--green); }
.editor-status.status-error { color: var(--red); }

/* ====== 系统监控 ====== */
.health-overview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.health-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 32px;
    border-radius: 10px;
}
.health-summary.all-healthy { background: #dcfce7; }
.health-summary.has-issues { background: #fef3c7; }
.health-big-num { font-size: 36px; font-weight: 700; }
.health-label { font-size: 14px; color: var(--text-light); }

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.health-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-left: 4px solid var(--green);
}
.health-card.unhealthy { border-left-color: var(--red); }
.health-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.health-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
}
.icon-ok { background: var(--green); }
.icon-err { background: var(--red); }
.health-card-name { font-weight: 600; font-size: 14px; }
.health-card-status { color: var(--text-light); font-size: 13px; }

.health-info {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.health-info h3 { font-size: 15px; margin-bottom: 12px; }
.info-table { width: 100%; }
.info-table td { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-table td.info-label { font-weight: 600; width: 140px; }

/* 设备管理: 在线态圆点 */
.dev-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dev-dot.green { background: var(--green); }
.dev-dot.gray { background: var(--gray); }
.dev-dot.red { background: var(--red); }
