/**
 * Lianjie Admin — 后台管理专用样式
 * 
 * 设计理念：专业暗色面板，完全独立于前端主题系统。
 * 切换前端主题不会影响后台样式。
 * 
 * 风格：GitHub Dark — 深蓝灰底 + 蓝色点缀，信息密度高，长时间操作不疲劳
 */

/* ── CSS Variables ── */
:root {
    --bg-body: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c232d;
    --bg-input: #0d1117;
    --bg-overlay: rgba(0,0,0,0.7);
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --text-dim: #484f58;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-glow: rgba(88,166,255,0.15);
    --accent-dim: rgba(88,166,255,0.08);
    --border: #30363d;
    --border-hover: #58a6ff;
    --danger: #f85149;
    --danger-bg: rgba(248,81,73,0.1);
    --success: #3fb950;
    --success-bg: rgba(63,185,80,0.1);
    --warning: #d29922;
    --warning-bg: rgba(210,153,34,0.1);
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 8px 24px rgba(0,0,0,0.4);
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }

/* ── Layout Utilities ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.inline { display: inline; }
.inline-flex { display: inline-flex; }

/* ── Spacing ── */
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.py-20 { padding-top: 5rem; padding-bottom: 5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }

/* ── Typography ── */
.text-xs  { font-size: 0.75rem; }
.text-sm  { font-size: 0.8125rem; }
.text-base { font-size: 0.875rem; }
.text-lg  { font-size: 1.0625rem; }
.text-xl  { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.75rem; }
.text-4xl { font-size: 2.25rem; }
.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4375rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.25rem;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.15s ease;
    background: var(--bg-card);
    color: var(--text-main);
    white-space: nowrap;
    user-select: none;
}
.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-dim);
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: #238636;
    color: #fff;
    border-color: rgba(240,246,252,0.1);
}
.btn-primary:hover {
    background: #2ea043;
    border-color: rgba(240,246,252,0.1);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--accent);
}
.btn-ghost:hover {
    background: var(--accent-dim);
    border-color: transparent;
    color: var(--accent-hover);
}
.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.75rem; border-radius: var(--radius-sm); }
.btn-xs { padding: 0.125rem 0.5rem; font-size: 0.6875rem; border-radius: var(--radius-sm); }
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(248,81,73,0.3);
}
.btn-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: #ff7b72;
}
.btn-success {
    background: transparent;
    color: var(--success);
    border-color: rgba(63,185,80,0.3);
}
.btn-success:hover {
    background: var(--success-bg);
    border-color: var(--success);
}
.btn-block { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-main);
}
.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.input {
    width: 100%;
    padding: 0.4375rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 0.875rem;
    line-height: 1.25rem;
    transition: all 0.15s;
    outline: none;
    font-family: inherit;
}
.input::placeholder { color: var(--text-dim); }
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-lg { padding: 0.625rem 1rem; font-size: 1rem; }
textarea.input { min-height: 80px; resize: vertical; }
select.input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 2rem;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.card-body { padding: 1.25rem; }
.card + .card { margin-top: 1rem; }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    line-height: 1.5;
}
.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(63,185,80,0.3);
}
.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(248,81,73,0.3);
}
.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(210,153,34,0.3);
}

/* ── Admin Navigation ── */
.admin-nav {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    padding: 0;
    background: transparent;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-nav::-webkit-scrollbar { height: 0; }
.admin-nav a {
    position: relative;
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.admin-nav a:hover {
    color: var(--text-main);
    border-bottom-color: var(--text-dim);
}
.admin-nav a.active {
    color: var(--text-main);
    border-bottom-color: var(--accent);
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}
thead { border-bottom: 1px solid var(--border); }
th {
    padding: 0.625rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid rgba(48,54,61,0.5);
    color: var(--text-main);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(88,166,255,0.03); }
.table-actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}
.code-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
}
.url-ell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: slideUp 0.15s ease;
}
.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
}
.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.75rem;
    padding-right: 2rem;
}
.modal-close {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modal-close:hover {
    background: var(--bg-card-hover);
    border-color: var(--border);
    color: var(--text-main);
}
.modal-body {
    padding: 1rem 1.25rem;
}
.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.modal-content-compact {
    max-width: 560px;
}
.modal-content-compact .modal-header {
    padding: 0.75rem 1rem;
}
.modal-content-compact .modal-body {
    padding: 0.875rem 1rem;
}
.modal-content-compact .modal-footer {
    padding: 0.625rem 1rem;
}
.modal-content-compact .form-group {
    margin-bottom: 0.75rem;
}
.modal-content-compact .form-group label {
    margin-bottom: 0.25rem;
}
.modal-content-compact .input {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}
.modal-content-compact textarea.input {
    min-height: 58px;
    resize: vertical;
}
.compact-form-grid {
    display: grid;
    column-gap: 0.75rem;
}
#modal-create-bm .compact-form-grid-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px;
}
#modal-create-bm .compact-form-grid-short {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 128px;
}
.compact-toggle-row {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    padding-top: 1.5625rem;
}
.compact-toggle-row label {
    margin: 0;
}

/* ── Toggle Switch ── */
.toggle {
    appearance: none;
    width: 38px;
    height: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.toggle::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.15s;
}
.toggle:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle:checked::after {
    left: calc(100% - 17px);
    background: #fff;
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Toast ── */
#toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1c2128;
    color: var(--text-main);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 0.8125rem;
    z-index: 200;
    opacity: 0;
    transition: all 0.25s ease;
    box-shadow: var(--shadow);
    pointer-events: none;
}
#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.5rem; }
    .admin-nav { gap: 0; }
    .admin-nav a { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
    .modal-content { margin: 1rem; max-height: calc(100vh - 2rem); }
    .table-wrap { margin: 0 -16px; border-radius: 0; border-left: none; border-right: none; }
    .url-ell { max-width: 160px; }
    th, td { padding: 0.5rem 0.75rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .container > .flex.justify-between.items-center.mb-6 {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }
    .compact-form-grid,
    #modal-create-bm .compact-form-grid-group,
    #modal-create-bm .compact-form-grid-short { grid-template-columns: 1fr; }
    .compact-toggle-row { padding-top: 0; }
    .btn { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
    .card-body { padding: 1rem; }
    .admin-nav a { padding: 0.4375rem 0.625rem; font-size: 0.75rem; }
}
