/* ============================================================
 * 产品防伪码生成器 — 响应式 + 三端适配 + 全屏布局
 * 桌面：解除 .app 限宽，保留左侧导航，内容最大 1360 居中
 * 配色：沿用站点 --accent，统一圆角/间距/阴影变量，提升可读性与一致性
 * ============================================================ */
body[data-page="antifake"] .app { max-width: 100%; }
body[data-page="antifake"] .main-content { max-width: 100%; width: 100%; border-right: 0; }

:root {
    --af-radius: 14px;
    --af-radius-lg: 18px;
    --af-gap: 16px;
    --af-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
    --af-shadow-hover: 0 2px 6px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .08);
}

.af-page {
    max-width: 1360px;
    margin: 0 auto;
    padding: 32px 40px 80px;
    box-sizing: border-box;
}

/* ---------- 标题区（品牌化） ---------- */
.af-hero {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #136ce9) 14%, #fff), #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--af-radius-lg);
    padding: 26px 30px;
    margin-bottom: 20px;
    box-shadow: var(--af-shadow);
}
.af-hero-icon {
    flex: none;
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--accent, #136ce9);
    color: #fff;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--accent, #136ce9) 38%, transparent);
}
.af-hero-body { flex: 1 1 auto; min-width: 0; }
.af-title {
    margin: 0 0 6px;
    font-size: 25px;
    font-weight: 700;
    letter-spacing: .3px;
    line-height: 1.3;
}
.af-sub {
    margin: 0;
    color: var(--text-secondary, #6b7280);
    font-size: 14px;
    line-height: 1.7;
    max-width: 760px;
}
.af-hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.af-chip {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 999px;
    padding: 4px 11px;
    white-space: nowrap;
}

/* ---------- 模式切换（桌面吸顶） ---------- */
.af-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    overflow-x: auto;
}
.af-tab {
    appearance: none;
    background: none;
    border: none;
    padding: 12px 18px;
    font-size: 15px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.af-tab:hover { color: var(--text-primary, #111827); }
.af-tab.is-active {
    color: var(--accent, #136ce9);
    border-bottom-color: var(--accent, #136ce9);
    font-weight: 600;
}
@media (min-width: 1024px) {
    .af-tabs {
        position: sticky;
        top: 0;
        z-index: 30;
        background: var(--bg-primary, #fff);
        padding: 8px 0 0;
    }
}

/* ---------- 卡片 ---------- */
.af-card {
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--af-radius);
    padding: 22px;
    margin-bottom: var(--af-gap);
    box-shadow: var(--af-shadow);
}
[data-theme="light"] .af-card { background: #fff; }

/* ---------- 设置网格 ---------- */
.af-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px 18px;
}
.af-grid-verify { margin: 14px 0; }
.af-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
}
.af-field input,
.af-field select {
    font-size: 15px;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 10px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    outline: none;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}
.af-field input:focus,
.af-field select:focus {
    border-color: var(--accent, #136ce9);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #136ce9) 18%, transparent);
}

/* ---------- 操作区 ---------- */
.af-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.af-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    user-select: none;
}

/* ---------- 按钮 ---------- */
.af-btn {
    appearance: none;
    border: 1px solid var(--border-color, #d1d5db);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    min-height: 40px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s, color .15s;
}
.af-btn:hover { border-color: var(--accent, #136ce9); color: var(--accent, #136ce9); }
.af-btn:active { transform: translateY(1px); }
.af-btn-primary {
    background: var(--accent, #136ce9);
    border-color: var(--accent, #136ce9);
    color: #fff;
    font-weight: 600;
}
.af-btn-primary:hover { color: #fff; filter: brightness(1.06); }
.af-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 结果栏 ---------- */
.af-result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.af-count { font-size: 13px; color: var(--text-secondary, #6b7280); }
.af-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 二维码中心 logo ---------- */
.af-qr-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 5px 10px;
    background: var(--bg-secondary, #f6f7f9);
}
.af-qr-logo input[type="file"] { max-width: 190px; font-size: 13px; }
.af-qr-logo-prev {
    width: 26px; height: 26px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 2px;
}

/* ---------- 二维码预览 ---------- */
.af-qr {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
    max-height: 420px;
    overflow: auto;
    padding: 2px;
}
.af-qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--af-shadow);
}
.af-qr-item canvas,
.af-qr-item img { width: 110px; height: 110px; }
.af-qr-code {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    word-break: break-all;
    text-align: center;
    line-height: 1.4;
}
.af-qr-loading { color: var(--text-secondary, #6b7280); font-size: 13px; padding: 10px 0; }

/* ---------- 列表 / 文本框 ---------- */
.af-list {
    margin: 0;
    max-height: 440px;
    overflow: auto;
    background: var(--bg-tertiary, #f7f8fa);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-primary, #111827);
}
.af-textarea {
    width: 100%;
    min-height: 140px;
    box-sizing: border-box;
    resize: vertical;
    padding: 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 10px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
    outline: none;
}
.af-textarea:focus {
    border-color: var(--accent, #136ce9);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #136ce9) 18%, transparent);
}

/* ---------- 非对称加密密钥管理 ---------- */
.af-crypto {
    background: color-mix(in srgb, var(--accent, #136ce9) 6%, var(--bg-primary, #fff));
    border-color: color-mix(in srgb, var(--accent, #136ce9) 22%, var(--border-color, #e5e7eb));
}
.af-crypto[hidden] { display: none; }
[data-theme="light"] .af-crypto { background: #f6f9ff; }
.af-grid-crypto { grid-template-columns: 1fr; gap: 12px; margin: 14px 0; }
.af-crypto-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.af-crypto-info {
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
    flex: 1 1 auto;
    min-width: 200px;
}
.af-field-col { grid-column: 1 / -1; }
.af-field-ops { display: inline-flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.af-key { min-height: 96px; font-size: 12px; }
.af-tip {
    margin: 10px 0 0;
    font-size: 12.5px;
    color: var(--text-secondary, #9aa3af);
    line-height: 1.7;
}
.af-verify-ok { color: #15a34a; }
.af-verify-bad { color: #d92121; }

/* ---------- 说明 ---------- */
.af-note {
    margin-top: 20px;
    font-size: 12.5px;
    color: var(--text-secondary, #9aa3af);
    line-height: 1.7;
    border-left: 3px solid var(--border-color, #e5e7eb);
    padding-left: 12px;
}

/* ---------- toast ---------- */
.af-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    background: rgba(17, 24, 39, .92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 2147483000;
}
.af-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 公开查询 ---------- */
.af-qmeta { font-size: 12.5px; color: var(--text-secondary, #9aa3af); }
.af-query-msg {
    margin-top: 12px;
    padding: 16px 18px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid var(--border-color, #e5e7eb);
}
.af-query-msg.af-ok { background: color-mix(in srgb, #15a34a 10%, var(--bg-secondary, #fff)); border-color: color-mix(in srgb, #15a34a 35%, transparent); color: #15803d; }
.af-query-msg.af-bad { background: color-mix(in srgb, #d92121 8%, var(--bg-secondary, #fff)); border-color: color-mix(in srgb, #d92121 30%, transparent); color: #b91c1c; }

/* ---------- 管理（管理员） ---------- */
.af-admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.af-admin-title { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.af-proj-list { display: flex; flex-direction: column; gap: 12px; }
.af-proj {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 14px 16px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    background: var(--bg-secondary, #fff);
    box-shadow: var(--af-shadow);
}
.af-proj-head { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; min-width: 0; }
.af-proj-name { font-weight: 600; font-size: 15px; }
.af-proj-slug { font-size: 12px; color: var(--text-secondary, #9aa3af); word-break: break-all; }
.af-proj-meta { font-size: 12.5px; color: var(--text-secondary, #6b7280); }
.af-proj-ops { display: flex; gap: 8px; flex-wrap: wrap; }
.af-btn-sm { padding: 7px 13px; font-size: 13px; min-height: 34px; }
.af-btn-danger { color: #d92121; border-color: color-mix(in srgb, #d92121 40%, var(--border-color, #e5e7eb)); }
.af-btn-danger:hover { color: #fff; background: #d92121; border-color: #d92121; }
.af-empty { color: var(--text-secondary, #9aa3af); font-size: 14px; margin: 4px 0; }
.af-tpl-hint { font-size: 12.5px; color: var(--text-secondary, #9aa3af); margin: 6px 0 16px; line-height: 1.7; }
.af-tpl-hint code { background: var(--bg-tertiary, #f2f3f5); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.af-field-full { grid-column: 1 / -1; }
.af-admin-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.af-admin-head .af-btn { white-space: nowrap; }
.af-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 18px; vertical-align: middle; }
.af-badge-demo { margin-left: 8px; color: #7a4b00; background: #fff4d6; border: 1px solid #f3d28a; }
.af-proj-demo { border-color: color-mix(in srgb, #f3b700 45%, var(--border-color, #e5e7eb)); background: color-mix(in srgb, #fff8e1 60%, var(--bg-primary, #fff)); }
.af-save { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary, #6b7280); }
.af-save select { padding: 9px 11px; border: 1px solid var(--border-color, #d1d5db); border-radius: 8px; background: var(--bg-primary, #fff); color: var(--text-primary, #111827); min-height: 38px; }

/* ============================================================
 * 响应式：平板 / 手机
 * ============================================================ */
@media (max-width: 1024px) {
    .af-page { padding: 28px 28px 64px; }
    .af-title { font-size: 23px; }
}
@media (max-width: 768px) {
    .af-page { padding: 20px 16px 56px; }
    .af-hero { flex-direction: column; padding: 22px 20px; gap: 16px; }
    .af-hero-icon { width: 48px; height: 48px; font-size: 24px; border-radius: 12px; }
    .af-title { font-size: 21px; }
    .af-card { padding: 18px; }
    .af-grid { grid-template-columns: 1fr 1fr; }
    /* 16px 字体避免 iOS 聚焦自动缩放 */
    .af-field input, .af-field select, .af-textarea { font-size: 16px; }
    .af-actions { width: 100%; }
    .af-btn-primary { flex: 1 1 100%; text-align: center; }
    .af-btns { width: 100%; }
    .af-btns .af-btn { flex: 1 1 auto; }
}
@media (max-width: 560px) {
    .af-admin-head { flex-direction: column; align-items: stretch; }
    .af-admin-head-actions { width: 100%; }
    .af-admin-head-actions .af-btn { flex: 1 1 auto; }
}
@media (max-width: 480px) {
    .af-grid { grid-template-columns: 1fr; }
    .af-list { max-height: 320px; }
    .af-qr { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
