/* QingCMS 后台补充样式（Bootstrap 5 之上） */

/* 三套主题：覆盖 Bootstrap 主色（导航栏 bg-primary、按钮、链接、侧栏高亮等） */
[data-admin-theme="blue"] {
    --bs-primary: #0d6efd;
    --bs-primary-rgb: 13, 110, 253;
    --admin-accent-soft: rgba(13, 110, 253, 0.12);
}

[data-admin-theme="emerald"] {
    --bs-primary: #198754;
    --bs-primary-rgb: 25, 135, 84;
    --bs-link-color: #198754;
    --bs-link-hover-color: #146c43;
    --admin-accent-soft: rgba(25, 135, 84, 0.12);
}

[data-admin-theme="slate"] {
    --bs-primary: #475569;
    --bs-primary-rgb: 71, 85, 105;
    --bs-link-color: #475569;
    --bs-link-hover-color: #334155;
    --admin-accent-soft: rgba(71, 85, 105, 0.14);
}

:root {
    /* 让 Topbar/侧栏/移动端菜单高度对齐（避免硬编码 56px 导致错位） */
    --admin-topnav-height: 56px;
}

.admin-body {
    min-height: 100vh;
    font-size: 13px;
    line-height: 1.5;
}

.admin-topnav {
    z-index: 1030;
}

.admin-brand-mark {
    width: 1.95rem;
    height: 1.95rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.admin-brand-title {
    line-height: 1.1;
}

.admin-theme-switcher {
    margin-top: 0.1rem;
}

.admin-brand-wrap {
    position: relative;
}

.admin-theme-switcher-near-brand {
    position: absolute;
    left: calc(100% + 54px);
    bottom: 3px;
    display: inline-flex;
    align-items: center;
}

.admin-theme-switcher-near-brand .admin-theme-switcher {
    margin-top: 0;
}

@media (max-width: 991.98px) {
    .admin-theme-switcher-near-brand {
        position: static;
    }

    .admin-theme-switcher-near-brand .admin-theme-switcher {
        margin-top: 0.12rem;
    }
}

@media (max-width: 576px) {
    .admin-theme-switch-btn {
        padding-left: 0.12rem;
        padding-right: 0.12rem;
    }
}

.admin-theme-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    border: 1px solid transparent;
    background: transparent;
    color: #fff;
    border-radius: 999px;
    padding: 0.08rem 0.16rem;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.admin-theme-switch-btn:hover {
    transform: translateY(-1px);
}

.admin-theme-switch-btn.is-active {
    transform: scale(1.08);
}

.admin-theme-switch-swatch {
    width: 0.78rem;
    height: 0.78rem;
    border-radius: 50%;
    border: 0;
    flex-shrink: 0;
}

.admin-theme-switch-swatch.theme-slate {
    background: #475569;
}

.admin-theme-switch-swatch.theme-blue {
    background: #0d6efd;
}

.admin-theme-switch-swatch.theme-emerald {
    background: #198754;
}

.admin-shell {
    min-height: calc(100vh - var(--admin-topnav-height, 56px));
}

.admin-sidebar-wrap {
    align-self: stretch;
}

@media (min-width: 768px) {
    .admin-sidebar-wrap {
        flex: 0 0 clamp(220px, 18vw, 252px);
        max-width: clamp(220px, 18vw, 252px);
    }

    .admin-main {
        flex: 1 1 auto;
        max-width: calc(100% - clamp(220px, 18vw, 252px));
    }
}

.admin-sidebar {
    min-height: calc(100vh - var(--admin-topnav-height, 56px));
    position: sticky;
    top: var(--admin-topnav-height, 56px);
}

.admin-sidebar-inner {
    min-height: calc(100vh - var(--admin-topnav-height, 56px));
}

.admin-sidebar-search {
    flex-shrink: 0; /* 保持搜索框始终可见，菜单区域滚动 */
}

.admin-sidebar-search input.form-control {
    font-size: 0.8125rem;
}

/* Mobile offcanvas: group header 可点击折叠 */
.admin-offcanvas .admin-sidebar-group-toggle {
    cursor: pointer;
}

/* 桌面侧栏同样支持分组点击折叠 */
.admin-sidebar .admin-sidebar-group-toggle {
    cursor: pointer;
}

.admin-sidebar-group-chevron {
    display: none; /* 桌面侧栏不显示箭头，仅在 offcanvas 打开时显示 */
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.admin-offcanvas .admin-sidebar-group-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-offcanvas .admin-sidebar-group-header[aria-expanded="true"] .admin-sidebar-group-chevron {
    transform: rotate(90deg);
}

.admin-offcanvas .admin-sidebar-group-header.is-toggle-hit {
    box-shadow: inset 0 0 0 2px rgba(var(--bs-primary-rgb), 0.35);
    border-radius: 0.5rem;
}

.admin-offcanvas .admin-sidebar-group-toggle:focus-visible {
    outline: 2px solid rgba(var(--bs-primary-rgb), 0.7);
    outline-offset: 2px;
}

/* 菜单较多时允许独立滚动，避免依赖整页滚动 */
.admin-sidebar-nav {
    overflow-y: auto;
}

.admin-sidebar-nav .nav-link {
    color: var(--bs-body-color);
    font-size: 0.8125rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.admin-sidebar-nav .nav-link:hover {
    background-color: var(--bs-secondary-bg);
}

.admin-sidebar-nav .nav-link.active {
    background-color: var(--admin-accent-soft, rgba(var(--bs-primary-rgb), 0.12));
    color: var(--bs-primary);
    font-weight: 600;
}

.admin-sidebar-nav .nav-link.active i {
    color: var(--bs-primary);
}

.admin-sidebar-nav .nav-link:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(var(--bs-primary-rgb), 0.45);
}

.admin-offcanvas {
    --bs-offcanvas-width: min(20rem, 88vw);
    /* 从 Topbar 下方开始显示（保持移动端体验一致） */
    top: var(--admin-topnav-height, 56px);
    height: calc(100vh - var(--admin-topnav-height, 56px));
}

.admin-offcanvas .offcanvas-body {
    overflow-y: auto;
    max-height: 100%;
}

.admin-offcanvas .admin-sidebar-inner {
    min-height: 0;
    height: 100%;
}

.admin-main {
    min-width: 0;
}

.admin-page-card > .card-header.admin-page-card-header {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.admin-page-header-actions .btn {
    white-space: nowrap;
}

.admin-main .card-header {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.admin-main .card-body {
    padding: 0.85rem;
}

.admin-main .btn {
    --bs-btn-font-size: 0.8125rem;
}

.admin-main .btn-sm {
    --bs-btn-font-size: 0.75rem;
}

.admin-main .form-control,
.admin-main .form-select {
    font-size: 0.8125rem;
    min-height: calc(1.5em + 0.45rem + 2px);
    padding-top: 0.225rem;
    padding-bottom: 0.225rem;
}

.admin-main .form-control-sm,
.admin-main .form-select-sm {
    min-height: calc(1.5em + 0.3rem + 2px);
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

/* 插件管理列表 */
.admin-plugin-list-card .admin-plugin-table thead th {
    font-weight: 600;
    font-size: 0.75rem;
}

.admin-plugin-list-card .admin-plugin-table tbody td {
    vertical-align: middle;
    font-size: 0.8125rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* 评论插件：设置表单宽度 */
.admin-comment-settings-form {
    max-width: 640px;
}

/* 登录页（与后台同主题变量） */
.admin-login-page {
    min-height: 100vh;
    background: linear-gradient(
        155deg,
        rgba(var(--bs-primary-rgb), 0.08) 0%,
        var(--bs-body-bg) 42%,
        var(--bs-secondary-bg) 100%
    );
}

.admin-login-badge {
    width: 3.25rem;
    height: 3.25rem;
    color: #fff;
    background: linear-gradient(135deg, var(--bs-primary) 0%, rgba(var(--bs-primary-rgb), 0.85) 100%);
    box-shadow: 0 0.25rem 0.75rem rgba(var(--bs-primary-rgb), 0.35);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.media-card {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem;
    background: var(--bs-light);
}

.media-card-main {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.media-thumb-link {
    width: 96px;
    min-width: 96px;
    height: 72px;
    display: block;
    border-radius: var(--bs-border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.media-card img {
    max-width: 100%;
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    margin: 0;
}

.media-grid.media-fit-cover .media-card img {
    object-fit: cover;
    background: transparent;
}

.media-grid.media-fit-contain .media-card img {
    object-fit: contain;
    background: var(--bs-tertiary-bg);
}

.media-meta {
    font-size: 0.78rem;
    word-break: break-all;
    margin-bottom: 0;
    color: var(--bs-secondary-color);
    flex: 1;
    min-width: 0;
}

.media-meta > div + div {
    margin-top: 0.2rem;
}

.media-meta code {
    background: var(--bs-tertiary-bg);
    padding: 0.125rem 0.25rem;
    border-radius: var(--bs-border-radius-sm);
}

.media-list-table .table > :not(caption) > * > * {
    vertical-align: middle;
}

.media-list-table .table thead th {
    white-space: nowrap;
    background: var(--bs-tertiary-bg);
}

.media-list-thumb-link {
    width: 76px;
    height: 76px;
    display: inline-block;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    overflow: hidden;
    background: var(--bs-tertiary-bg);
}

button.media-list-thumb-link {
    padding: 0;
}

.media-list-thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.media-list-table.media-fit-cover .media-list-thumb {
    object-fit: cover;
}

.media-list-table.media-fit-contain .media-list-thumb {
    object-fit: contain;
    background: var(--bs-tertiary-bg);
}

.media-classic-edit-btn {
    display: block;
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
}

.media-editor-stage {
    width: 100%;
    height: 65vh;
    min-height: 420px;
    max-height: 70vh;
    padding: 10px;
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    position: relative;
}

.media-editor-cropper-root {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Cropper.js 兜底：强制裁剪界面填满根节点，避免遮罩/画布视觉越界 */
.media-editor-cropper-root .cropper-container {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden;
}

.media-editor-cropper-root .cropper-canvas,
.media-editor-cropper-root .cropper-modal,
.media-editor-cropper-root .cropper-view-box,
.media-editor-cropper-root .cropper-crop-box {
    max-width: 100%;
    max-height: 100%;
}

.media-editor-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.media-editor-stage .cropper-container {
    /* 防止 cropper 容器在弹窗滚动/重排时出现越界渲染 */
    overflow: hidden;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.media-editor-overlay-watermark {
    position: absolute;
    left: 14px;
    top: 12px;
    right: auto;
    bottom: auto;
    z-index: 3;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    display: none;
    white-space: nowrap;
}

.media-editor-overlay-size {
    position: absolute;
    left: 12px;
    bottom: 10px;
    z-index: 3;
    font-size: 0.78rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.42);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    pointer-events: none;
}

/* 媒体选择器 iframe 内 */
.admin-media-picker-page .admin-media-pick-item {
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.admin-media-picker-page .admin-media-pick-item:hover {
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.12);
}

.admin-media-picker-page .admin-media-pick-item.is-selected {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.25);
}

.admin-media-picker-page .admin-media-pick-item:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.admin-media-picker-toolbar {
    z-index: 2;
}

.admin-card-body > h2:first-child,
.admin-card-body > h3:first-child {
    margin-top: 0;
}

/* 文章管理：类 WP 列表 + 表格 */
.admin-article-manage {
    max-width: 100%;
}

.admin-article-heading .btn-group .btn.active {
    background-color: var(--bs-secondary-bg);
    font-weight: 600;
}

.admin-article-nav-tabs {
    border-bottom: 1px solid var(--bs-border-color);
}

.admin-article-nav-tabs .nav-link {
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 0.375rem 0.375rem 0 0;
    padding: 0.375rem 0.7rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    font-size: 0.8125rem;
}

.admin-article-nav-tabs .nav-link:hover {
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

.admin-article-nav-tabs .nav-link.active {
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    border-bottom-color: var(--bs-body-bg);
    margin-bottom: -1px;
    font-weight: 600;
}

.admin-article-create .card-header {
    font-size: 0.875rem;
}

.admin-article-create-page .admin-article-create textarea[name="content"] {
    min-height: 18rem;
}

.admin-tinymce-wrap .tox-tinymce {
    min-height: 20rem;
}

.admin-ckeditor-wrap .ck-editor__editable {
    min-height: 18rem;
}

/* CKEditor 5 右下角 “Powered by” 角标（.ck-powered-by-balloon）。商业授权可在页面设置 window.__qingcmsCkeditorLicenseKey 以官方方式关闭角标。 */
.admin-ckeditor-wrap .ck-powered-by-balloon {
    display: none !important;
}

.admin-article-toolbar-wrap {
    border-radius: 0.375rem 0.375rem 0 0;
    border-bottom: none;
}

.admin-article-table-wrap {
    border: 1px solid var(--bs-border-color);
    border-radius: 0 0 0.375rem 0.375rem;
    background: var(--bs-body-bg);
}

.admin-article-toolbar-wrap + .admin-article-table-wrap {
    border-top: 1px solid var(--bs-border-color);
    margin-top: -1px;
    border-radius: 0 0 0.375rem 0.375rem;
}

.admin-article-table {
    font-size: 0.8125rem;
}

.admin-article-table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
    border-bottom-width: 1px;
}

.admin-article-table .col-title {
    min-width: 200px;
}

.admin-article-table .col-check {
    width: 2.5rem;
}

.admin-article-table .col-cat {
    width: 10%;
}

.admin-article-table .col-tags {
    width: 14%;
}

.admin-article-table .col-date {
    width: 11%;
    white-space: nowrap;
}

.admin-article-table .col-views {
    width: 4.5rem;
    white-space: nowrap;
}

.admin-article-table .col-status {
    width: 5.5rem;
}

.admin-article-table .col-permission {
    width: 7rem;
    white-space: nowrap;
}

.admin-article-table .col-actions {
    width: 7rem;
}

.admin-article-table .col-time {
    width: 11rem;
}

.admin-article-table .col-cat,
.admin-article-table .col-author,
.admin-article-table .col-date,
.admin-article-table .col-views,
.admin-article-table .col-status,
.admin-article-table .col-permission,
.admin-article-table .col-actions {
    text-align: center;
}

.admin-article-table tbody td:nth-child(4),
.admin-article-table tbody td:nth-child(5),
.admin-article-table tbody td:nth-child(6),
.admin-article-table tbody td:nth-child(7),
.admin-article-table tbody td:nth-child(8),
.admin-article-table tbody td:nth-child(9),
.admin-article-table tbody td:nth-child(10) {
    text-align: center;
}

.article-title-cell .article-title-text {
    display: inline-block;
    line-height: 1.35;
    color: #111;
}

.article-title-cell .article-title-text:hover,
.article-title-cell .article-title-text:focus {
    color: #dc3545;
}

.article-row-actions {
    font-size: 0.75rem;
}

.admin-article-row:hover {
    --bs-table-hover-bg: rgba(var(--bs-primary-rgb), 0.04);
}

.admin-article-edit-form textarea {
    min-height: 6rem;
}

.admin-article-trash-hint {
    margin-bottom: 0.75rem;
}

@media (max-width: 991.98px) {
    .admin-article-table .col-tags,
    .admin-article-table .col-cat {
        min-width: 5rem;
    }
}

/* 栏目管理：行内编辑布局微调 */
.admin-category-row .form-control-sm,
.admin-category-row .form-select-sm {
    min-height: calc(1.5em + 0.45rem + 2px);
}

.admin-category-row .badge {
    font-weight: 500;
}

/* 栏目管理：鼠标经过整行高亮（包含按钮区），并兼容层级底色（inline style） */
.admin-category-row {
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.admin-category-row:hover,
.admin-category-row:focus-within {
    background-color: rgba(var(--bs-primary-rgb), 0.11) !important;
    box-shadow: inset 0 0 0 1px rgba(var(--bs-primary-rgb), 0.32);
}

@media (min-width: 992px) {
    .admin-category-row .btn {
        white-space: nowrap;
    }
}

/* Admin: user avatar picker (create/edit) */
.admin-user-avatar-trigger {
    padding: 0;
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-user-avatar-preview-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    border: 1px dashed var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    user-select: none;
}

.admin-user-avatar-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.admin-user-avatar-preview-ph {
    font-size: 1.9rem;
    line-height: 1;
    color: var(--bs-secondary-color);
    font-weight: 700;
}
