/* ============================================================
   dingCS 管理后台公共样式
   供 admin/ 下各页面引用：<link rel="stylesheet" href="/static/assets/style.css">
   ============================================================ */

:root {
    --c-primary: #4f46e5;
    --c-primary-dark: #4338ca;
    --c-primary-light: #eef2ff;
    --c-success: #10b981;
    --c-success-light: #d1fae5;
    --c-warning: #f59e0b;
    --c-warning-light: #fef3c7;
    --c-danger: #ef4444;
    --c-danger-light: #fee2e2;
    --c-info: #3b82f6;
    --c-info-light: #dbeafe;

    --c-text: #1f2937;
    --c-text-secondary: #6b7280;
    --c-text-muted: #9ca3af;
    --c-border: #e5e7eb;
    --c-border-light: #f3f4f6;
    --c-bg: #f8fafc;
    --c-bg-card: #ffffff;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.15);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.page { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header .desc { color: var(--c-text-secondary); font-size: 13px; margin-top: 2px; }

.back-link {
    display: inline-block;
    font-size: 13px;
    color: var(--c-text-secondary);
    margin-bottom: 4px;
    transition: color 0.15s;
}
.back-link:hover { color: var(--c-primary); text-decoration: none; }

.card {
    background: var(--c-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--c-border-light);
}
.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--c-border-light);
}
.card h3 .icon { margin-right: 8px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger  { background: var(--c-danger); color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #dc2626; }
.btn-warning { background: var(--c-warning); color: #fff; }
.btn-ghost {
    background: transparent;
    color: var(--c-text-secondary);
    border: 1px solid var(--c-border);
}
.btn-ghost:hover { background: var(--c-border-light); color: var(--c-text); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

/* ---------- 表单 ---------- */
.form-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 200px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-secondary);
}
.form-group label .required { color: var(--c-danger); }

.input,
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--c-text);
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.form-group input[readonly] { background: var(--c-border-light); color: var(--c-text-muted); }
.form-group .hint { font-size: 12px; color: var(--c-text-muted); margin-top: 4px; }

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}
.switch input { display: none; }
.switch .slider {
    position: absolute; inset: 0;
    background: #d1d5db;
    border-radius: var(--radius-full);
    transition: 0.2s;
    cursor: pointer;
}
.switch .slider::before {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}
.switch input:checked + .slider { background: var(--c-success); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--c-border-light);
    white-space: nowrap;
}
tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--c-border-light);
    font-size: 13px;
    vertical-align: middle;
}
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #fafbfe; }
tbody tr:last-child td { border-bottom: none; }

.mono { font-family: var(--font-mono); font-size: 12px; }

/* ---------- 徽章 / 状态 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.badge-success { background: var(--c-success-light); color: #065f46; }
.badge-warning { background: var(--c-warning-light); color: #92400e; }
.badge-danger  { background: var(--c-danger-light);  color: #991b1b; }
.badge-info    { background: var(--c-info-light);    color: #1e40af; }
.badge-gray    { background: var(--c-border-light);  color: var(--c-text-secondary); }
.badge-purple  { background: var(--c-primary-light); color: var(--c-primary-dark); }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.dot-online { background: var(--c-success); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.dot-offline { background: #d1d5db; }

/* ---------- 提示框 ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert-success { background: var(--c-success-light); color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: var(--c-danger-light);  color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--c-warning-light); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--c-info-light);    color: #1e40af; border-color: #bfdbfe; }

/* Toast（由 app.js 驱动） */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    min-width: 240px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--c-info);
    font-size: 14px;
    animation: toastIn 0.25s ease;
}
.toast.success { border-left-color: var(--c-success); }
.toast.error   { border-left-color: var(--c-danger); }
.toast.warning { border-left-color: var(--c-warning); }
.toast.fade-out { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to   { opacity: 0; transform: translateX(20px); }
}

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-mask.show { display: flex; animation: fadeIn 0.15s ease; }
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 440px;
    max-width: 92vw;
    max-height: 86vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--c-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none;
    font-size: 22px; color: var(--c-text-muted);
    cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--c-text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--c-border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- 统计卡片 ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--c-bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--c-border-light);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .label { color: var(--c-text-secondary); font-size: 13px; }
.stat-card .value {
    font-size: 30px;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.stat-card .trend { font-size: 12px; margin-top: 4px; }
.stat-card .trend.up { color: var(--c-success); }
.stat-card .trend.down { color: var(--c-danger); }

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 16px;
}
.pagination button {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--c-border);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--c-text-secondary);
    transition: all 0.15s;
}
.pagination button:hover:not(:disabled) {
    border-color: var(--c-primary);
    color: var(--c-primary);
}
.pagination button.active {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .total { font-size: 13px; color: var(--c-text-muted); margin-right: 8px; }

/* ---------- 空状态 / 加载 ---------- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--c-text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }
.empty-state .text { font-size: 14px; }

.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 工具类 ---------- */
.text-muted { color: var(--c-text-muted); }
.text-secondary { color: var(--c-text-secondary); }
.text-success { color: var(--c-success); }
.text-danger { color: var(--c-danger); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }

/* ---------- 导航网格（控制台首页） ---------- */
.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    min-height: 100px;
    text-align: center;
    border-radius: var(--radius-lg);
    text-decoration: none !important;
    transition: all 0.15s ease;
}
.nav-btn .nav-icon {
    font-size: 28px;
    line-height: 1;
}
.nav-btn .nav-label {
    font-size: 14px;
    font-weight: 500;
}
.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ---------- 自定义复选框（记住密码） ---------- */
.remember-row {
    display: flex;
    align-items: center;
    margin-top: 6px;
    margin-bottom: 4px;
}
.remember-row .checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 400;
    color: var(--c-text-secondary);
    user-select: none;
    margin-bottom: 0;
}
.remember-row .checkbox-label input[type="checkbox"] {
    display: none;
}
.remember-row .checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--c-border);
    border-radius: 4px;
    position: relative;
    transition: all 0.15s;
    flex-shrink: 0;
}
.remember-row .checkbox-label input:checked + .checkbox-custom {
    background: var(--c-primary);
    border-color: var(--c-primary);
}
.remember-row .checkbox-label input:checked + .checkbox-custom::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .page { padding: 14px; }
    .form-row { flex-direction: column; gap: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* 手机端：更大按钮、更大字体 */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 48px;
    }
    .btn-sm { padding: 8px 14px; font-size: 14px; min-height: 40px; }
    .btn-lg { padding: 14px 26px; font-size: 17px; min-height: 52px; }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 16px;
    }

    .card { padding: 18px; }
    .card h3 { font-size: 18px; }

    .page-header h2 { font-size: 22px; }
    .page-header .desc { font-size: 15px; }

    .stat-card { padding: 16px; }
    .stat-card .label { font-size: 14px; }
    .stat-card .value { font-size: 28px; }

    .nav-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .nav-btn { min-height: 90px; padding: 16px 12px; }
    .nav-btn .nav-icon { font-size: 24px; }
    .nav-btn .nav-label { font-size: 14px; }

    .flex.gap-12 { gap: 10px; flex-wrap: wrap; }
    .flex.gap-12 .btn { flex: 1 1 auto; min-width: 120px; text-align: center; justify-content: center; }

    .modal { max-width: 96vw; }
    .modal-body { padding: 16px 18px; }

    .pagination button {
        min-width: 40px;
        height: 40px;
        font-size: 15px;
    }

    thead th { font-size: 13px; padding: 12px 10px; }
    tbody td { font-size: 14px; padding: 12px 10px; }

    .toast { min-width: 200px; max-width: 300px; font-size: 15px; }

    .remember-row .checkbox-label { font-size: 15px; }
    .remember-row .checkbox-custom { width: 18px; height: 18px; }
}

/* 超小屏手机 */
@media (max-width: 480px) {
    .page { padding: 10px; }
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .nav-grid { grid-template-columns: 1fr; }
    .nav-btn { min-height: 80px; padding: 14px 12px; }
    .flex.gap-12 { flex-direction: column; }
    .flex.gap-12 .btn { width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header .btn { align-self: stretch; text-align: center; justify-content: center; }
}