/**
 * 登录 / 注册 / 找回密码 — 用户协议与隐私政策弹窗（前台）
 * 依赖：Quill snow.css（.ql-editor 等类名）
 */

/* ========== 遮罩 ========== */
#agreementModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    box-sizing: border-box;
    background: radial-gradient(ellipse 120% 100% at 50% 0%, rgba(67, 56, 202, 0.35) 0%, rgba(15, 23, 42, 0.72) 55%, rgba(2, 6, 23, 0.88) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ========== 弹窗容器 ========== */
.agreement-modal-box {
    width: 100%;
    max-width: 560px;
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 32px 64px -12px rgba(15, 23, 42, 0.45),
        0 12px 32px rgba(79, 70, 229, 0.15);
    animation: agreementModalIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes agreementModalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== 顶栏 ========== */
.agreement-modal-head {
    flex-shrink: 0;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(125deg, #4f46e5 0%, #6366f1 38%, #7c3aed 100%);
    color: #fff;
    position: relative;
}

.agreement-modal-head::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
}

.agreement-modal-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.agreement-modal-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    transition: background 0.2s, transform 0.15s;
}

.agreement-modal-close:hover {
    background: rgba(255, 255, 255, 0.26);
    transform: scale(1.05);
}

/* ========== Tab（分段控件） ========== */
.agreement-modal-tabs {
    flex-shrink: 0;
    padding: 12px 14px 14px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.agreement-tab-list {
    display: flex;
    gap: 8px;
}

.agreement-tab {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    border-radius: 12px;
    border: 2px solid transparent;
    background: transparent;
    transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}

.agreement-tab:hover {
    color: #475569;
    background: rgba(255, 255, 255, 0.7);
}

.agreement-tab.active {
    color: #3730a3;
    background: #fff;
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.18);
}

/* ========== 正文滚动区 ========== */
.agreement-modal-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 22px 24px 26px;
    font-size: 14px;
    color: #334155;
    line-height: 1.75;
    white-space: normal;
    background: linear-gradient(180deg, #fafbfc 0%, #ffffff 18%);
    scrollbar-width: thin;
    scrollbar-color: #a5b4fc #eef2ff;
}

.agreement-modal-body::-webkit-scrollbar {
    width: 8px;
}

.agreement-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}

.agreement-modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #a5b4fc, #818cf8);
    border-radius: 8px;
    border: 2px solid #f1f5f9;
}

.agreement-modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #818cf8, #6366f1);
}

/* 与后台 Quill Snow 一致：外层 .ql-snow 使 snow.css 中 .ql-snow .ql-editor 的标题/引用/链接等生效 */
.agreement-modal-body.ql-snow .ql-editor {
    height: auto;
    min-height: 0;
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
}

/* ========== Quill 渲染正文（协议 HTML，与后台保存的 innerHTML 同步） ========== */
#agreementContent.ql-editor {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.8;
    color: #334155;
    padding: 0;
    border: none;
    outline: none;
    white-space: normal;
}

/* Snow 主题下由后台生成的块级元素（与 quill.snow.css 对齐并略调间距以适配弹窗） */
#agreementModal .ql-snow .ql-editor h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #475569;
    margin: 0.9rem 0 0.35rem;
}

#agreementModal .ql-snow .ql-editor h5,
#agreementModal .ql-snow .ql-editor h6 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #64748b;
    margin: 0.75rem 0 0.3rem;
}

#agreementModal .ql-snow .ql-editor a {
    color: #4338ca;
    text-decoration: underline;
    word-break: break-word;
}

#agreementModal .ql-snow .ql-editor blockquote {
    border-left: 4px solid #c7d2fe;
    margin: 0.65em 0;
    padding: 0.35em 0 0.35em 1rem;
    color: #64748b;
    background: rgba(248, 250, 252, 0.9);
    border-radius: 0 10px 10px 0;
}

#agreementModal .ql-snow .ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    vertical-align: middle;
}

#agreementModal .ql-snow .ql-editor pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0.75em 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    line-height: 1.55;
}

#agreementModal .ql-snow .ql-editor code {
    font-size: 0.9em;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

#agreementModal .ql-snow .ql-editor pre.ql-syntax {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

#agreementContent.ql-editor > p:first-child:not(:last-child) {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    letter-spacing: 0.02em;
}

/* 后台一键优化后的文档主标题（h2）与首段大标题一致层级 */
#agreementContent.ql-editor > h2:first-child {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    letter-spacing: 0.02em;
    line-height: 1.45;
}

#agreementContent.ql-editor p {
    margin: 0 0 0.85em;
}

#agreementContent.ql-editor p:last-child {
    margin-bottom: 0;
}

#agreementContent.ql-editor h1 {
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    margin: 1.25rem 0 0.5rem;
    letter-spacing: -0.02em;
}

#agreementContent.ql-editor h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1e293b;
    margin: 1.15rem 0 0.45rem;
}

#agreementContent.ql-editor h3 {
    font-size: 1.12rem;
    font-weight: 700;
    color: #334155;
    margin: 1rem 0 0.4rem;
}

#agreementContent.ql-editor strong {
    font-weight: 800;
    color: #1e293b;
}

#agreementContent.ql-editor ol,
#agreementContent.ql-editor ul {
    padding-left: 1.35em;
    margin: 0.35em 0 0.85em;
}

#agreementContent.ql-editor li {
    margin-bottom: 0.35em;
}

#agreementContent.ql-editor .ql-align-center {
    text-align: center;
}

#agreementContent.ql-editor .ql-align-right {
    text-align: right;
}

#agreementContent.ql-editor .ql-align-justify {
    text-align: justify;
}

#agreementContent .ql-size-small {
    font-size: 0.8em;
}

#agreementContent .ql-size-large {
    font-size: 1.35em;
}

#agreementContent .ql-size-huge {
    font-size: 1.75em;
}

#agreementContent .ql-indent-1 {
    padding-left: 2.5em;
}

#agreementContent .ql-indent-2 {
    padding-left: 5em;
}

#agreementContent .ql-indent-3 {
    padding-left: 7.5em;
}

#agreementContent em {
    font-style: italic;
}

#agreementContent u {
    text-decoration: underline;
}

#agreementContent s {
    text-decoration: line-through;
}

/* ========== 底部按钮 ========== */
.agreement-modal-foot {
    flex-shrink: 0;
    padding: 16px 22px 20px;
    display: flex;
    justify-content: center;
    background: linear-gradient(180deg, #fafbff 0%, #f8fafc 100%);
    border-top: 1px solid #eef2f7;
}

.agreement-confirm-btn {
    min-width: 200px;
    padding: 13px 28px;
    border: none;
    border-radius: 14px;
    cursor: not-allowed;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #fff;
    opacity: 0.42;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
    transition: opacity 0.25s, box-shadow 0.25s, transform 0.2s;
}

.agreement-confirm-btn.enabled {
    opacity: 1;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.45);
}

.agreement-confirm-btn.enabled:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.5);
}

.agreement-confirm-btn.enabled:active {
    transform: translateY(0);
}

.agreement-confirm-btn.agreement-confirm-btn--finalize {
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
    white-space: normal;
    padding: 12px 14px;
    min-width: 0;
}

@media (max-width: 480px) {
    .agreement-modal-head {
        padding: 16px 18px;
    }

    .agreement-modal-body {
        padding: 18px 16px 22px;
    }

    .agreement-tab {
        font-size: 12px;
        padding: 9px 8px;
    }

    .agreement-confirm-btn {
        width: 100%;
        min-width: 0;
    }
}
