/**
 * AiCart OS v6.11
 * Copyright (c) AiCart OS team. All rights reserved.
 *
 * 合规中心样式：法律文档页 / 注册与结算同意 / Cookie 同意横幅
 * 颜色全部使用 app.css 设计令牌，自动适配后台主题色与夜间模式
 */

/* ==================== 1. 法律文档页 ==================== */

.ux-legal-section {
    padding: 52px 0 76px;
    background: var(--bg);
}

.ux-legal-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 30px;
    align-items: start;
}

.ux-legal-aside {
    position: sticky;
    top: 92px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.ux-legal-aside h3 {
    font-size: 15px;
    margin: 0 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.ux-legal-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ux-legal-nav a {
    display: block;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: background .18s ease, color .18s ease;
}

.ux-legal-nav a:hover {
    background: var(--dark-soft);
    color: var(--ink);
}

.ux-legal-nav a.on {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}

.ux-legal-help {
    margin-top: 18px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 12.5px;
    color: var(--muted);
    text-align: center;
}

.ux-legal-help i {
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 8px;
}

.ux-legal-help p {
    margin: 0 0 8px;
    line-height: 1.6;
}

.ux-legal-help a {
    font-weight: 700;
    word-break: break-all;
}

.ux-legal-doc {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: clamp(22px, 4vw, 48px);
    box-shadow: var(--shadow-sm);
}

.ux-legal-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.ux-legal-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.ux-legal-updated {
    font-size: 12.5px;
    color: var(--muted);
}

.ux-legal-summary {
    margin: 0 0 26px;
    padding: 14px 18px;
    border-left: 3px solid var(--primary);
    background: var(--bg);
    border-radius: 0 10px 10px 0;
    font-size: 14px;
    color: var(--muted);
}

.ux-legal-content {
    font-size: 16px;
    line-height: 1.75;
    color: #475467;
    word-break: break-word;
}

/* 统一正文规格：全局 p{16px/1.6} 会与列表项字号行高不一致，这里让段落与列表都继承容器值 */
.ux-legal-content p,
.ux-legal-content li {
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    /* 列表项默认继承页面的 300 细体，与段落 400 不一致，这里统一字重 */
    font-weight: 400;
}

.ux-legal-content h2 {
    position: relative;
    margin: 34px 0 12px;
    padding-left: 14px;
    font-size: 19px;
    font-weight: 800;
}

.ux-legal-content h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: .22em;
    bottom: .22em;
    width: 4px;
    border-radius: 4px;
    background: var(--primary);
}

.ux-legal-content h3 {
    margin: 24px 0 8px;
    padding-left: 22px;
    font-size: 15.5px;
    font-weight: 700;
}

.ux-legal-content p {
    margin: 0 0 14px;
    /* 与 ul 列表正文的左缩进保持一致 */
    padding-left: 22px;
}

.ux-legal-content ul,
.ux-legal-content ol {
    margin: 0 0 18px;
    padding-left: 22px;
}

.ux-legal-content li {
    /* 与段落同一行距节奏：不再额外增加条目间距 */
    margin-bottom: 0;
}

.ux-legal-content a {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ux-legal-content .ux-legal-note {
    display: inline-block;
    margin-top: 30px;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.ux-legal-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.ux-legal-back,
.ux-legal-cookie-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    transition: border-color .18s ease, color .18s ease, background .18s ease;
}

.ux-legal-back:hover,
.ux-legal-cookie-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

/* 文档总览 */
.ux-legal-intro {
    max-width: 760px;
    margin: 0 0 26px;
    font-size: 14.5px;
    color: var(--muted);
}

.ux-legal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.ux-legal-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.ux-legal-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.ux-legal-card-i {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 6px;
}

.ux-legal-card-t {
    font-size: 15px;
    font-weight: 800;
    color: var(--ink);
}

.ux-legal-card-d {
    font-size: 12px;
    color: var(--muted);
}

.ux-legal-card-a {
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--primary);
}

/* ==================== 2. 注册 / 结算同意勾选 ==================== */

.ux-legal-consent {
    margin: 16px 0 4px;
}

.ux-consent-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    font-size: 13px;
    line-height: 1.65;
    color: var(--muted);
    cursor: pointer;
}

.ux-consent-box input[type="checkbox"] {
    flex: none;
    width: 17px;
    height: 17px;
    margin: 2px 0 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.ux-consent-box a {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ux-consent-box:has(input:invalid) {
    border-color: #e5484d;
    background: #fff5f5;
}

html[data-theme="dark"] .ux-consent-box:has(input:invalid) {
    background: rgba(229, 72, 77, .12);
}

/* ==================== 2.1 条款弹窗（注册 / 结算） ==================== */

.ux-legal-modal[hidden] {
    display: none;
}

.ux-legal-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ux-legal-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(12, 16, 24, .55);
}

.ux-legal-modal-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(860px, 100%);
    max-height: 86vh;
    padding: 22px 26px 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(12, 16, 24, .28);
}

.ux-legal-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease;
}

.ux-legal-modal-close:hover {
    color: var(--ink);
    border-color: var(--primary);
}

.ux-legal-modal-title {
    margin: 0 44px 6px 0;
    font-size: 20px;
    line-height: 1.4;
    color: var(--ink);
}

.ux-legal-modal-meta {
    margin-bottom: 14px;
    font-size: 12.5px;
    color: var(--muted);
}

.ux-legal-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 6px;
    padding-bottom: 20px;
    overflow-y: auto;
    font-size: 14.5px;
    line-height: 1.85;
    color: var(--ink);
    -webkit-overflow-scrolling: touch;
}

.ux-legal-modal-body img {
    max-width: 100%;
    height: auto;
}

.ux-legal-modal-body a {
    color: var(--primary);
}

.ux-legal-modal-summary {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--ink);
}

.ux-legal-modal-loading {
    padding: 32px 0;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 640px) {
    .ux-legal-modal {
        padding: 10px;
    }

    .ux-legal-modal-panel {
        max-height: 90vh;
        padding: 18px 16px 4px;
    }

    .ux-legal-modal-title {
        font-size: 17px;
    }
}

/* ==================== 3. Cookie 同意横幅 ==================== */

.ux-cc[hidden],
.ux-cc-fab[hidden] {
    display: none !important;
}

.ux-cc {
    position: fixed;
    z-index: 9998;
    pointer-events: none;
    animation: uxCcFade .3s ease both;
}

.ux-cc.is-open {
    display: flex;
}

.ux-cc:not(.is-open) {
    display: none;
}

/* 底部条 */
.ux-cc {
    left: 16px;
    right: 16px;
    bottom: 16px;
    justify-content: center;
}

/* 居中弹层（后台可选 position=center） */
.ux-cc[data-position="center"] {
    inset: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(3px);
}

.ux-cc-card {
    position: relative;
    pointer-events: auto;
    width: 100%;
    max-width: 1080px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 20px 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    animation: uxCcUp .35s cubic-bezier(.2, .8, .3, 1) both;
}

.ux-cc[data-position="center"] .ux-cc-card {
    max-width: 620px;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    padding: 30px;
}

.ux-cc[data-position="center"] .ux-cc-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
}

.ux-cc-icon {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 20px;
    flex: none;
}

.ux-cc-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
}

.ux-cc-desc {
    margin: 0;
    font-size: 12.8px;
    line-height: 1.65;
    color: var(--muted);
}

.ux-cc-desc a {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.ux-cc-dot {
    margin: 0 4px;
    opacity: .5;
}

.ux-cc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.ux-cc-btn {
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    font-size: 12.8px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
    white-space: nowrap;
}

.ux-cc-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ux-cc-accept {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.ux-cc-accept:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.ux-cc-close {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
}

.ux-cc-close:hover {
    background: var(--dark-soft);
    color: var(--ink);
}

/* 类别设置 */
.ux-cc-prefs {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.ux-cc-prefs[hidden] {
    display: none;
}

.ux-cc-prefs-title {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.ux-cc-cat {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 0;
    cursor: pointer;
}

.ux-cc-cat + .ux-cc-cat {
    border-top: 1px dashed var(--line);
}

.ux-cc-cat-txt b {
    display: block;
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 2px;
}

.ux-cc-cat-txt small {
    display: block;
    font-size: 11.8px;
    line-height: 1.55;
    color: var(--muted);
}

.ux-cc-switch {
    flex: none;
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ux-cc-switch i {
    display: none;
}

.ux-cc-switch input {
    appearance: none;
    -webkit-appearance: none;
    width: 42px;
    height: 24px;
    margin: 0;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    cursor: pointer;
    transition: background .18s ease;
}

.ux-cc-switch input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
    transition: left .18s ease;
}

.ux-cc-switch input:checked {
    background: var(--primary);
}

.ux-cc-switch input:checked::after {
    left: 21px;
}

.ux-cc-switch input:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* 再次打开按钮 */
.ux-cc-fab {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 9997;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--primary);
    font-size: 18px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}

.ux-cc-fab:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 页脚合规链接条 */
.ux-footer-compliance {
    padding: 18px 0;
}

/* 覆盖 .ux-footer .ux-container 的 56px 顶距，避免合规链接上方出现多余空隙 */
.ux-footer .ux-footer-compliance .ux-container {
    padding-top: 0;
    padding-bottom: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 18px;
}

.ux-footer-compliance a,
.ux-footer-compliance button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 12.4px;
    color: inherit;
    opacity: .72;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .18s ease;
}

.ux-footer-compliance a:hover,
.ux-footer-compliance button:hover {
    opacity: 1;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ux-footer-compliance .ux-fc-sep {
    opacity: .3;
}

/* ==================== 4. 响应式与夜间模式 ==================== */

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

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

@media (max-width: 900px) {
    .ux-legal-layout {
        grid-template-columns: 1fr;
    }

    .ux-legal-aside {
        position: static;
    }

    .ux-legal-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .ux-legal-nav a {
        border: 1px solid var(--line);
        padding: 7px 12px;
    }

    .ux-legal-help {
        display: none;
    }

    .ux-cc-card {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .ux-cc-icon {
        display: none;
    }

    .ux-cc-actions {
        justify-content: flex-start;
    }

    .ux-cc-btn {
        flex: 1 1 auto;
        text-align: center;
    }
}

@media (max-width: 560px) {
    .ux-legal-section {
        padding: 34px 0 56px;
    }

    .ux-legal-doc {
        padding: 20px 16px;
    }

    .ux-cc {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .ux-cc-card {
        padding: 18px 16px;
        border-radius: 16px;
    }

    .ux-cc-title {
        font-size: 15px;
    }

    .ux-cc-fab {
        left: 12px;
        bottom: 12px;
    }
}

html[data-theme="dark"] .ux-legal-content {
    color: #c9d3e4;
}

html[data-theme="dark"] .ux-legal-content .ux-legal-note {
    background: var(--bg);
}
