/* VINE_THEME_ADMIN_V1 */

/*
 * 始终预留纵向滚动条空间，避免不同页面高度导致页面左右位移。
 */
html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
    background: var(--bg);
}

html,
body {
    min-height: 100%;
}

:root {
    color-scheme: light;
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #171923;
    --muted: #667085;
    --brand: #6c5ce7;
    --brand-hover: #5947df;
    --line: #e7e9f1;
    --input-bg: #ffffff;
    --soft: #eef0f7;
    --soft-text: #202431;
    --nav-bg: rgba(255, 255, 255, .9);
    --hero-start: #ffffff;
    --hero-end: #efedff;
    --notice-bg: #fff4df;
    --success-bg: #eaf7ef;
    --danger-bg: #fee4e2;
    --danger: #b42318;
    --shadow: rgba(22, 26, 45, .07);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1117;
    --card: #181b24;
    --text: #f2f4f8;
    --muted: #a8b0c0;
    --brand: #8274ff;
    --brand-hover: #998eff;
    --line: #2a2f3b;
    --input-bg: #12151d;
    --soft: #242936;
    --soft-text: #eef1f7;
    --nav-bg: rgba(15, 17, 23, .9);
    --hero-start: #191c25;
    --hero-end: #211d3d;
    --notice-bg: #332916;
    --success-bg: #173124;
    --danger-bg: #3a1e22;
    --danger: #ff9b95;
    --shadow: rgba(0, 0, 0, .28);
}

body {
    background: var(--bg) !important;
    color: var(--text) !important;
    transition:
        background-color 180ms ease,
        color 180ms ease;
}

.nav {
    background: var(--nav-bg) !important;
    border-color: var(--line) !important;
}

.card,
table {
    background: var(--card) !important;
    color: var(--text);
    border-color: var(--line) !important;
    box-shadow: 0 12px 34px var(--shadow) !important;
}

.hero {
    background:
        linear-gradient(
            135deg,
            var(--hero-start),
            var(--hero-end)
        ) !important;
    box-shadow: 0 18px 50px var(--shadow) !important;
}

input,
textarea,
select {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: .85;
}

.btn {
    background: var(--brand);
}

.btn:hover {
    background: var(--brand-hover);
}

.btn.alt {
    background: var(--soft) !important;
    color: var(--soft-text) !important;
}

.btn.danger {
    background: var(--danger-bg) !important;
    color: var(--danger) !important;
}

.notice {
    background: var(--notice-bg) !important;
}

.flash {
    background: var(--success-bg) !important;
}

.flash.error {
    background: var(--danger-bg) !important;
}

th,
td {
    border-color: var(--line) !important;
}

/* 主题切换按钮 */
.vine-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 42px;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--soft);
    color: var(--soft-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.vine-theme-toggle:hover {
    transform: none;
    background: var(--card);
}

.vine-theme-icon {
    font-size: 17px;
    line-height: 1;
}

/* 首页 */
.home-welcome {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: clamp(18px, 2.2vw, 23px);
    letter-spacing: .02em;
}

.home-subtitle {
    margin: 0;
    font-size: clamp(17px, 2vw, 22px);
}

.vine-home-hero h1 {
    margin-bottom: 22px;
}

/* 后台通用标题 */
.admin-page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin: 28px 0 22px;
}

.admin-eyebrow {
    margin-bottom: 7px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .14em;
}

.admin-page-title {
    margin: 0 0 8px;
    font-size: clamp(30px, 4vw, 46px);
}

/* 商品表单 */
.product-create-card,
.product-edit-card {
    margin-bottom: 34px;
}

.product-create-card > summary {
    list-style: none;
}

.product-create-card > summary::-webkit-details-marker {
    display: none;
}

.product-section-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    cursor: pointer;
}

.product-section-summary span:first-child {
    display: grid;
    gap: 4px;
}

.product-section-summary strong {
    font-size: 20px;
}

.product-section-summary small {
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

.summary-arrow {
    font-size: 24px;
    transition: transform 180ms ease;
}

details[open] .summary-arrow {
    transform: rotate(180deg);
}

.product-create-card[open] .product-admin-form {
    margin-top: 24px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.product-admin-form label {
    display: grid;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
}

.product-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.product-check {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: fit-content;
}

.product-check input {
    width: 18px !important;
    height: 18px;
    margin: 0;
    accent-color: var(--brand);
}

.product-save-button {
    width: 100%;
    min-height: 48px;
}

.product-list-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 16px;
}

.product-list-heading h2,
.product-list-heading p {
    margin: 0;
}

.product-admin-list {
    display: grid;
    gap: 15px;
}

.product-admin-item {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 20px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--card);
    box-shadow: 0 10px 30px var(--shadow);
}

.product-admin-image {
    width: 150px;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 15px;
    background: var(--soft);
}

.product-admin-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-placeholder {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    color: var(--muted);
    font-size: 14px;
}

.product-admin-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.product-admin-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.product-admin-title-row h3 {
    margin: 0 0 8px;
    font-size: 21px;
}

.product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.product-meta span {
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.product-status {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.product-status.is-active {
    background: #dcfae6;
    color: #087a3e;
}

.product-status.is-inactive {
    background: var(--soft);
    color: var(--muted);
}

html[data-theme="dark"] .product-status.is-active {
    background: #173c29;
    color: #74e2a5;
}

.product-description {
    margin: 16px 0;
    color: var(--muted);
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.product-admin-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: auto;
}

.product-price {
    font-size: 22px;
}

.product-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
}

.product-actions form {
    display: block;
    margin: 0;
}

.product-action {
    min-width: 76px;
    min-height: 40px;
}

.current-product-image {
    display: grid;
    gap: 10px;
}

.current-product-image > span {
    font-weight: 700;
}

.current-product-image img {
    width: min(320px, 100%);
    max-height: 230px;
    object-fit: cover;
    border-radius: 15px;
    border: 1px solid var(--line);
}

.product-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.product-edit-actions .btn {
    min-width: 120px;
}

.product-empty {
    text-align: center;
    color: var(--muted);
}

/*
 * 禁止旧的局部导航位移动画。
 * 主内容切换时不再 translateY，也不强制平滑滚动。
 */
main,
#main,
#content,
.main-content,
.page-content,
.content-wrapper {
    transform: none !important;
    will-change: auto !important;
    transition:
        opacity 120ms ease,
        background-color 180ms ease,
        color 180ms ease !important;
}

.vine-content-leaving,
.vine-content-entering,
.vine-content-entered {
    transform: none !important;
}

/* 删除旧局部导航遗留的顶部加载线 */
#vine-partial-progress {
    display: none !important;
}

@media (max-width: 800px) {
    html {
        overflow-y: auto;
    }

    .vine-theme-toggle {
        min-height: 36px;
        padding: 7px 9px;
    }

    .vine-theme-text {
        display: none;
    }

    .admin-page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .product-form-grid {
        grid-template-columns: 1fr;
    }

    .product-admin-item {
        grid-template-columns: 84px minmax(0, 1fr);
        gap: 13px;
        padding: 14px;
    }

    .product-admin-image {
        width: 84px;
    }

    .product-admin-title-row {
        align-items: flex-start;
    }

    .product-admin-title-row h3 {
        font-size: 18px;
    }

    .product-description {
        grid-column: 1 / -1;
    }

    .product-admin-bottom {
        grid-column: 1 / -1;
        align-items: flex-start;
        flex-direction: column;
    }

    .product-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .product-actions form,
    .product-action {
        width: 100%;
    }

    .product-edit-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .product-edit-actions .btn {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
