/* ============================================================
 * assets/css/admin.css — 后台页面样式
 * ============================================================
 * 系统名称 : 白遇光 · 授权代表服务自助办理系统
 * 开发者 : 白遇光
 * 创建时间 : 2026-04-03
 * 更新时间 : 2026-04-04  迁移至 Bootstrap 5，补充后台专属自定义类
 * 说    明 : 承载后台动画、侧边栏激活态、品牌图标、模态层与移动端适配。
 *            Bootstrap 5 基础类由 CDN 提供，本文件仅补充框架未覆盖的部分。
 * ============================================================ */

/* ── CSS 变量 ──────────────────────────────────────────────── */
:root {
    --brand-primary:       #165DFF;
    --brand-secondary:     #0A2463;
    --brand-primary-rgb:   22, 93, 255;
    --sidebar-width:       256px;
    --neutral-100: #F5F7FA;
    --neutral-200: #E4E7ED;
    --neutral-300: #C0C6CF;
    --neutral-400: #909399;
    --neutral-500: #606266;
    --neutral-600: #303133;
}

/* ── 通用工具 ──────────────────────────────────────────────── */
.content-auto {
    content-visibility: auto;
}

/* ── 动画 ──────────────────────────────────────────────────── */
.animate-fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* ── 侧边栏导航激活态 ──────────────────────────────────────── */
.nav-item-link {
    color: var(--neutral-500);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
    font-size: 14px;
}

.nav-item-link:hover {
    background-color: rgba(var(--brand-primary-rgb), 0.06);
    color: var(--brand-primary);
}

.nav-item-link.sidebar-active {
    background-color: rgba(var(--brand-primary-rgb), 0.10);
    color: var(--brand-primary);
    border-left: 3px solid var(--brand-primary);
    padding-left: calc(0.75rem - 3px) !important; /* 补偿 border-left 占宽 */
    font-weight: 600;
}

/* ── 后台品牌图标（侧边栏顶部小尺寸）─────────────────────── */
.brand-icon-sm {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(var(--brand-primary-rgb), 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--brand-primary);
    flex-shrink: 0;
}

/* ── 管理员头像 ────────────────────────────────────────────── */
.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

/* ── 自定义模态遮罩层 ──────────────────────────────────────── */
/* 使用自定义 modal-overlay 而非 Bootstrap modal 组件，
   以保持原有 JS 逻辑（classList.add/remove('d-none')）不变。 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.50);
    z-index: 1055;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--neutral-200);
}

.modal-box-header h3,
.modal-box-header .modal-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--neutral-600);
}

.modal-box-body {
    padding: 20px 24px;
}

.modal-box-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--neutral-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ── 内容区占位（主体偏移量）──────────────────────────────── */
.main-content-area {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--neutral-100);
    transition: margin-left 0.3s;
}

/* ── 数据概览卡片 ─────────────────────────────────────────── */
.stat-card {
    border-radius: 16px;
    border: 1px solid var(--neutral-200);
    background: #fff;
    padding: 20px 24px;
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 16px rgba(var(--brand-primary-rgb), 0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ── 表格行悬浮 ────────────────────────────────────────────── */
.table > tbody > tr {
    transition: background-color 0.15s;
}

/* ── 表格表头横向显示 ────────────────────────────────────── */
.table thead th {
    white-space: nowrap;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}

/* ── 表格单元格内容单行显示 ───────────────────────────────── */
.table tbody td {
    white-space: nowrap !important;
}

/* ── 表格响应式容器内的单元格强制单行 ──────────────────────── */
.table-responsive .table tbody td,
.table-responsive .table thead th {
    white-space: nowrap !important;
}

/* ── 表单元素统一聚焦色 ────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.15);
}

/* ── 主色按钮 ─────────────────────────────────────────────── */
.btn-primary {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: #0d4de0;
    --bs-btn-hover-border-color: #0d4de0;
    --bs-btn-active-bg: #0a3dbf;
}

/* ── 分页 ─────────────────────────────────────────────────── */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: 1px solid var(--neutral-200);
    color: var(--neutral-600);
}

.pagination .page-item.active .page-link {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* ── Toast / 状态提示 ─────────────────────────────────────── */
.toast-progress {
    height: 3px;
    border-radius: 0 0 8px 8px;
    background: var(--brand-primary);
    transition: width linear;
}

.toast-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
}

.toast-icon-success {
    background: var(--bs-success);
    color: #fff;
}

.toast-icon-error {
    background: var(--bs-danger);
    color: #fff;
}

.toast-icon-info {
    background: var(--brand-primary);
    color: #fff;
}

/* ── 状态徽章 / 行内标签 ──────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.status-badge-primary {
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

.status-badge-success {
    background: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
}

.status-badge-danger {
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

.status-badge-warning {
    background: var(--bs-warning-bg-subtle);
    color: #8a5a00;
}

.status-badge-info {
    background: var(--bs-info-bg-subtle);
    color: var(--bs-info-text-emphasis);
}

.status-badge-secondary {
    background: var(--bs-secondary-bg-subtle);
    color: var(--neutral-500);
}

/* ── 表格交互按钮 ─────────────────────────────────────────── */
.table-action-group {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.table-action-btn {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.table-action-btn:hover {
    text-decoration: none;
}

.table-action-btn-primary {
    color: var(--brand-primary);
}

.table-action-btn-primary:hover {
    color: #0d4de0;
}

.table-action-btn-danger {
    color: var(--bs-danger);
}

.table-action-btn-danger:hover {
    color: var(--bs-danger-text-emphasis);
}

.table-action-btn-warning {
    color: #b26a00;
}

.table-action-btn-warning:hover {
    color: #8a5200;
}

.table-action-btn-success {
    color: var(--bs-success);
}

.table-action-btn-success:hover {
    color: var(--bs-success-text-emphasis);
}

.table-action-btn-secondary {
    color: var(--neutral-500);
}

.table-action-btn-secondary:hover {
    color: var(--brand-primary);
}

.table-action-btn-muted,
.table-action-btn.is-disabled {
    color: var(--neutral-400);
    opacity: 0.65;
    pointer-events: none;
    cursor: not-allowed;
}

.table-code-cell,
.table-password-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-password-value {
    word-break: break-all;
}

.dashboard-quick-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--neutral-200);
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--neutral-600);
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-quick-action:hover {
    color: var(--brand-primary);
    border-color: rgba(var(--brand-primary-rgb), 0.22);
    box-shadow: 0 6px 18px rgba(var(--brand-primary-rgb), 0.08);
    text-decoration: none;
}

.dashboard-quick-action:focus-visible {
    outline: 0;
    color: var(--brand-primary);
    border-color: rgba(var(--brand-primary-rgb), 0.35);
    box-shadow: 0 0 0 0.2rem rgba(var(--brand-primary-rgb), 0.15);
}

.dashboard-icon-tone-primary {
    background: rgba(var(--brand-primary-rgb), 0.12);
    color: var(--brand-primary);
}

.dashboard-icon-tone-info {
    background: rgba(13, 202, 240, 0.14);
    color: #0a7b91;
}

.dashboard-icon-tone-violet {
    background: rgba(111, 66, 193, 0.14);
    color: #6f42c1;
}

.dashboard-icon-tone-success {
    background: rgba(25, 135, 84, 0.12);
    color: #198754;
}

.dashboard-icon-tone-success-strong {
    background: rgba(16, 185, 129, 0.14);
    color: #0f8f64;
}

.dashboard-icon-tone-warning {
    background: rgba(255, 193, 7, 0.18);
    color: #9a6700;
}

.dashboard-icon-tone-secondary {
    background: rgba(108, 117, 125, 0.12);
    color: #495057;
}

.dashboard-icon-tone-danger {
    background: rgba(220, 53, 69, 0.12);
    color: #c0394d;
}

.dashboard-icon-tone-pink {
    background: rgba(214, 51, 132, 0.12);
    color: #d63384;
}

/* ── 后台统计概览组件 ─────────────────────────────────────── */
.dashboard-hero {
    border-radius: 1.5rem;
    background: linear-gradient(135deg, rgba(var(--brand-primary-rgb), 0.10), #ffffff 38%, #ffffff 100%);
    border: 1px solid rgba(var(--brand-primary-rgb), 0.12);
    padding: 1.5rem;
    box-shadow: var(--bs-box-shadow-sm);
}

.dashboard-hero-kicker {
    letter-spacing: 0.22em;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgba(var(--brand-primary-rgb), 0.72);
    font-weight: 700;
}

.dashboard-section-card {
    height: 100%;
    background: #fff;
    border: 1px solid var(--neutral-200);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--bs-box-shadow-sm);
}

.dashboard-empty-state {
    border: 1px dashed var(--neutral-200);
    border-radius: 1rem;
    background: #fff;
    color: var(--neutral-400);
    padding: 2rem 1rem;
    text-align: center;
}

.dashboard-card-grid > [class*="col-"] {
    display: flex;
}

.dashboard-stat-card {
    height: 100%;
    width: 100%;
    border: 1px solid var(--neutral-200);
    border-radius: 1rem;
    background: #fff;
    padding: 1.25rem;
    box-shadow: var(--bs-box-shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(var(--brand-primary-rgb), 0.10);
}

.dashboard-stat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.dashboard-stat-title {
    margin: 0;
    color: var(--neutral-500);
    font-size: 0.875rem;
    font-weight: 500;
}

.dashboard-stat-value {
    margin: 0.75rem 0 0;
    color: var(--neutral-600);
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-stat-helper {
    margin: 1rem 0 0;
    color: var(--neutral-400);
    font-size: 0.75rem;
    line-height: 1.6;
}

.dashboard-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dashboard-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--neutral-400);
}

.dashboard-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

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

.dashboard-trend-day {
    height: 100%;
    background: var(--neutral-100);
    border-radius: 1rem;
    padding: 1rem 0.75rem;
}

.dashboard-trend-bars {
    height: 112px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.375rem;
}

.dashboard-trend-metrics {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--neutral-500);
}

.dashboard-trend-metrics p {
    margin-bottom: 0.25rem;
}

.dashboard-trend-metrics p:last-child {
    margin-bottom: 0;
}

.dashboard-bar {
    width: 12px;
    display: block;
    border-radius: 12px 12px 0 0;
}

.dashboard-bar-customers {
    background: #38bdf8;
}

.dashboard-bar-auth-codes {
    background: #8b5cf6;
}

.dashboard-bar-applications {
    background: #10b981;
}

.dashboard-progress-track {
    height: 0.625rem;
    background: var(--neutral-200);
    border-radius: 999px;
    overflow: hidden;
}

.dashboard-progress-fill {
    height: 100%;
    background: var(--brand-primary);
    border-radius: 999px;
}

.dashboard-mini-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--neutral-400);
    background: var(--neutral-100);
}

.dashboard-mini-table tbody td {
    color: var(--neutral-500);
}

.dashboard-mini-table tbody tr:hover {
    background: rgba(var(--brand-primary-rgb), 0.03);
}

.dashboard-metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.dashboard-metric-row:last-child {
    margin-bottom: 0;
}

.dashboard-metric-label {
    color: var(--neutral-500);
    font-weight: 500;
}

.dashboard-metric-value {
    color: var(--neutral-400);
}

.dashboard-metric-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.application-detail-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--neutral-200);
}

.application-detail-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.application-detail-label {
    color: var(--neutral-400);
    font-weight: 500;
    flex: 0 0 38%;
}

.application-detail-value {
    color: var(--neutral-600);
    text-align: right;
    word-break: break-word;
}

.application-detail-value--wrap {
    max-width: 18rem;
}

/* ── 系统设置状态文本 ─────────────────────────────────────── */
.system-settings-status--idle {
    color: var(--neutral-400);
}

.system-settings-status--saving {
    color: var(--brand-primary);
}

.system-settings-status--success {
    color: var(--bs-success);
}

.system-settings-status--error {
    color: var(--bs-danger);
}

/* ── 数据库管理卡片 ───────────────────────────────────────── */
.database-management-intro {
    border: 1px dashed rgba(var(--brand-primary-rgb), 0.24);
    background: linear-gradient(135deg, rgba(var(--brand-primary-rgb), 0.07) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.database-management-eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(var(--brand-primary-rgb), 0.78);
}

.database-management-action {
    border: 1px solid var(--neutral-200);
    border-radius: 1rem;
    background: #fff;
    padding: 1.5rem;
    box-shadow: var(--bs-box-shadow-sm);
}

.database-management-action--info {
    border-color: rgba(var(--brand-primary-rgb), 0.18);
    background: linear-gradient(180deg, rgba(var(--brand-primary-rgb), 0.04) 0%, #fff 100%);
}

.database-management-action--danger {
    border-color: rgba(220, 53, 69, 0.18);
    background: linear-gradient(180deg, rgba(220, 53, 69, 0.05) 0%, #fff 100%);
}

.database-management-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.9rem;
    font-size: 1.1rem;
}

.database-management-icon--info {
    color: var(--brand-primary);
    background: rgba(var(--brand-primary-rgb), 0.12);
}

.database-management-icon--danger {
    color: var(--bs-danger);
    background: rgba(220, 53, 69, 0.12);
}

.database-management-status--idle {
    color: var(--neutral-500);
}

.database-management-status--loading {
    color: var(--brand-primary);
}

.database-management-status--success {
    color: var(--bs-success);
}

.database-management-status--error {
    color: var(--bs-danger);
}

.database-management-status--warning {
    color: #b26a00;
}

/* ────────────────────────────────────────────────────────────
 * 移动端适配
 * ────────────────────────────────────────────────────────────*/
@media (max-width: 768px) {
    /* 侧边栏默认隐藏在屏幕左侧 */
    aside {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    aside.mobile-show {
        transform: translateX(0);
    }

    /* 主内容区不偏移 */
    .main-content-area {
        margin-left: 0 !important;
    }

    /* 表格横向滚动 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 模态框在小屏全宽 */
    .modal-box {
        max-width: 100% !important;
        border-radius: 12px;
    }

    .application-detail-item {
        flex-direction: column;
        gap: 0.35rem;
    }

    .application-detail-label,
    .application-detail-value {
        text-align: left;
        max-width: none;
    }
}
