/* ============================================================
 * Qoder 账号管理后台 - 全局样式表（暗紫主题）
 * ============================================================ */

:root {
    --bg: #0F1117;
    --card: #161922;
    --border: #1F2330;
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --text: #FAFAFA;
    --text-muted: #A1A1AA;
    --text-dim: #52525B;
    --success: #34D399;
    --warning: #FBBF24;
    --error: #F87171;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --font: "Segoe UI", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
input, button, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }

/* ---------- 页面头部 ---------- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
}
.card-title {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    font-size: 15px; font-weight: 600;
}
.card-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 8px 16px; border: 1px solid var(--border);
    background: transparent; color: var(--text); border-radius: var(--radius);
    cursor: pointer; transition: all .15s; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--text-muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: transparent; border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: var(--error); color: #fff; }
.btn-warning { background: transparent; border-color: var(--warning); color: var(--warning); }
.btn-warning:hover { background: var(--warning); color: #1a1a1a; }
.btn-default { background: transparent; color: var(--text-muted); }
.btn-success { background: var(--success); border-color: var(--success); color: #0a0a0a; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 14px; }
.form-inline { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }
.form-vertical .form-group { margin-bottom: 16px; }
.form-label {
    display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted);
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
}
.form-input::placeholder { color: var(--text-dim); }
.btn:focus-visible, .filter-tabs .tab:focus-visible, .form-input:focus-visible,
.form-select:focus-visible, .form-textarea:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
textarea.form-input { resize: vertical; min-height: 80px; }
.form-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.form-error {
    margin-bottom: 12px; padding: 8px 12px; background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--error); border-radius: var(--radius);
    color: var(--error); font-size: 13px;
}

/* ---------- 表格 ---------- */
.table-wrap {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow-x: auto; margin-top: 12px;
}
.data-table { width: 100%; border-collapse: collapse; }
.account-table { min-width: 1080px; }
.card-table { min-width: 980px; }
.action-cell { vertical-align: middle; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-actions-account {
    flex-wrap: nowrap;
    justify-content: flex-start;
}
.row-actions-account .btn {
    flex: 0 0 auto;
    min-width: auto;
    padding: 4px 10px;
    white-space: nowrap;
}
.row-actions-card {
    flex-wrap: nowrap;
    justify-content: flex-start;
}
.row-actions-card .btn {
    flex: 0 0 auto;
    min-width: auto;
    padding: 4px 10px;
    white-space: nowrap;
}
.account-card-cell { min-width: 150px; max-width: 240px; }
.account-card-cell > * { display: block; overflow-wrap: anywhere; }
.account-card-cell .mono { color: var(--text); }
.data-table th, .data-table td {
    padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.data-table th {
    background: rgba(255, 255, 255, 0.02); color: var(--text-muted);
    font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
}
.data-table tbody tr:hover { background: rgba(139, 92, 246, 0.04); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-empty {
    text-align: center; color: var(--text-dim); padding: 32px 0;
}

/* ---------- 标签 ---------- */
.tag {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 12px; line-height: 20px; background: var(--bg);
    color: var(--text-muted); border: 1px solid var(--border);
}
.tag-success { color: var(--success); border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.08); }
.tag-warning { color: var(--warning); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.08); }
.tag-error   { color: var(--error);   border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.08); }
.tag-primary { color: var(--primary); border-color: rgba(139, 92, 246, 0.3); background: rgba(139, 92, 246, 0.08); }
.tag-default { color: var(--text-muted); }

/* ---------- 进度条 ---------- */
.progress {
    position: relative; width: 100%; height: 6px;
    background: var(--bg); border-radius: 3px; overflow: hidden;
}
.progress-bar {
    height: 100%; background: var(--primary); border-radius: 3px;
    transition: width .3s ease;
}
.progress-ok .progress-bar       { background: var(--success); }
.progress-warning .progress-bar  { background: var(--warning); }
.progress-danger .progress-bar   { background: var(--error); }
.progress-text {
    display: inline-block; margin-top: 4px; font-size: 12px; color: var(--text-muted);
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tabs .tab {
    padding: 6px 14px; background: transparent; border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-muted); cursor: pointer;
    font-size: 13px; transition: all .15s;
}
.filter-tabs .tab:hover { color: var(--text); }
.filter-tabs .tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 统计胶囊 ---------- */
.stats-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-pill {
    padding: 6px 14px; background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; font-size: 13px; color: var(--text-muted);
}
.stat-pill b { color: var(--text); margin-left: 4px; }
.stat-pill.stat-success b { color: var(--success); }
.stat-pill.stat-error b   { color: var(--error); }
.stat-pill.stat-primary b { color: var(--primary); }

/* ---------- 分页 ---------- */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; margin-top: 16px; flex-wrap: wrap;
}
.pagination .page-btn {
    min-width: 32px; padding: 6px 10px; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-muted); cursor: pointer; text-align: center; font-size: 13px;
}
.pagination .page-btn:hover { color: var(--text); border-color: var(--text-muted); }
.pagination .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }
.pagination .page-info { color: var(--text-dim); font-size: 12px; padding: 0 8px; }

/* ---------- 弹窗 ---------- */
.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal-dialog {
    width: 100%; max-width: 480px; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
}
.modal-lg { max-width: 720px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 10px 16px; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 13px;
    min-width: 220px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toastIn .2s ease;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--error); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info    { border-left: 3px solid var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- 信息列表 ---------- */
.info-list .info-row {
    display: flex; padding: 8px 0; border-bottom: 1px solid var(--border);
}
.info-list .info-row:last-child { border-bottom: none; }
.info-list .info-label { width: 120px; color: var(--text-muted); }
.info-list .info-value { flex: 1; color: var(--text); }
.oauth-entry-btn {
    flex: 0 0 auto;
    gap: 8px;
    padding: 7px 14px;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.18);
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.oauth-entry-btn:hover {
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}
.oauth-entry-btn span {
    transition: transform .15s ease;
}
.oauth-entry-btn:hover span {
    transform: translateX(2px);
}
.dashboard-stat-total {
    padding-bottom: 14px; margin-bottom: 8px; border-bottom: 1px solid var(--border);
}
.dashboard-stat-total .stat-label { color: var(--text-muted); font-size: 13px; }
.dashboard-stat-total .stat-value {
    display: block; margin-top: 4px; font-size: 30px; line-height: 1.1;
}
.dashboard-stat-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.dashboard-stat-details .info-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--border);
}
.dashboard-stat-details .info-label { color: var(--text-muted); }
.dashboard-stat-details b { font-variant-numeric: tabular-nums; }
.card-info p { margin-bottom: 8px; }
.card-info b { color: var(--text-muted); display: inline-block; min-width: 90px; }

/* ---------- 授权相关 ---------- */
.oauth-page { max-width: 1440px; margin: 0 auto; }
.oauth-page-header { margin-bottom: 24px; }
.eyebrow {
    display: block; margin-bottom: 4px; color: var(--primary);
    font-size: 11px; font-weight: 700; letter-spacing: 1.6px;
}
.oauth-page-header .page-title { font-size: 26px; letter-spacing: .2px; }
.page-subtitle { margin-top: 4px; color: var(--text-muted); font-size: 13px; }
.oauth-ready {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px;
    border: 1px solid rgba(52, 211, 153, .24); border-radius: 999px;
    background: rgba(52, 211, 153, .07); color: var(--success); font-size: 12px;
}
.oauth-ready-dot, .oauth-live-dot {
    width: 7px; height: 7px; border-radius: 50%; background: currentColor;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, .12);
}
.oauth-grid { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); gap: 18px; align-items: stretch; }
.oauth-card { position: relative; display: flex; flex-direction: column; margin-bottom: 0; overflow: hidden; }
.oauth-card-primary { background: linear-gradient(145deg, rgba(139, 92, 246, .12), var(--card) 38%); }
.oauth-card-accent { position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--primary), #C084FC, transparent); }
.oauth-card-title { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; }
.oauth-card-title h3 { font-size: 16px; font-weight: 600; }
.oauth-card-title p { margin-top: 3px; color: var(--text-muted); font-size: 12px; font-weight: 400; }
.oauth-step {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 30px;
    height: 30px; border: 1px solid rgba(139, 92, 246, .35); border-radius: 8px;
    background: rgba(139, 92, 246, .12); color: var(--primary); font-size: 11px; font-weight: 700;
}
.oauth-card-body { display: flex; flex: 1; flex-direction: column; padding: 22px; }
.oauth-feature-list { display: grid; gap: 12px; margin-bottom: 28px; color: var(--text-muted); font-size: 13px; }
.oauth-feature-list > div { display: flex; align-items: center; gap: 10px; }
.oauth-feature-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
    border: 1px solid rgba(139, 92, 246, .28); border-radius: 7px;
    background: rgba(139, 92, 246, .1); color: var(--primary); font-size: 13px;
}
.oauth-main-btn { align-self: flex-start; padding: 10px 16px; box-shadow: 0 8px 20px rgba(139, 92, 246, .2); }
.oauth-main-btn span, .oauth-import-footer .btn span { transition: transform .15s ease; }
.oauth-main-btn:hover span, .oauth-import-footer .btn:hover span { transform: translateX(3px); }
.auth-result { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.oauth-result-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--text); font-size: 13px; font-weight: 600; }
.oauth-live-dot { color: var(--warning); box-shadow: 0 0 0 4px rgba(251, 191, 36, .12); }
.auth-result textarea { margin-top: 0; }
.auth-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.file-dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 142px; padding: 18px; border: 1px dashed #3A4052; border-radius: var(--radius);
    background: rgba(15, 17, 23, .58); color: var(--text-muted); text-align: center; cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.file-dropzone:hover, .file-dropzone.is-dragging, .file-dropzone.has-file { border-color: var(--primary); background: rgba(139, 92, 246, .08); }
.file-dropzone.has-file .file-dropzone-title { color: var(--primary); }
.file-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-dropzone-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    margin-bottom: 8px; border-radius: 10px; background: rgba(139, 92, 246, .14);
    color: var(--primary); font-size: 20px; font-weight: 600;
}
.file-dropzone-title { color: var(--text); font-size: 13px; }
.file-dropzone-hint { margin-top: 4px; color: var(--text-dim); font-size: 12px; }
.oauth-divider { display: flex; align-items: center; gap: 12px; margin: 2px 0 14px; color: var(--text-dim); font-size: 12px; }
.oauth-divider::before, .oauth-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.oauth-json-group { margin-bottom: 16px; }
.oauth-json-input { min-height: 130px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
.oauth-import-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; }
.oauth-import-footer .text-muted { font-size: 12px; }
.import-result { min-height: 24px; margin-top: 14px; font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-right { width: 100%; }
    .filter-right .form-input { flex: 1 1 220px; width: auto !important; min-width: 0; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-actions { width: 100%; justify-content: flex-start; }
    .page-actions .btn { flex: 1 1 auto; }
    .row-actions { min-width: 170px; }
    .dashboard-stat-details { grid-template-columns: 1fr; }
    .oauth-grid { grid-template-columns: 1fr; }
    .oauth-page-header { align-items: flex-start; }
    .oauth-card-body { padding: 18px; }
    .oauth-import-footer { align-items: flex-start; flex-direction: column; }
    .oauth-import-footer .btn { width: 100%; }
}
@media (max-width: 480px) {
    .oauth-page-header .page-title { font-size: 22px; }
    .oauth-ready { align-self: flex-start; }
    .oauth-card-title { padding: 16px 18px; }
    .oauth-main-btn { width: 100%; }
}