/* ============================================================
   短剧加剧系统 · 前台样式（v3.0）
   重点：手机端不竖排，表格变卡片，搜索框占满
   ============================================================ */

/* ---------- 重置（关键：中文不断字） ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    background: #f5f7fa;
    color: #2d3748;
    line-height: 1.6;
    font-size: 14px;
    /* 关键修复：中文 keep-all 不被强制按字断行（解决"竖排"问题） */
    word-break: keep-all;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
a { color: #5a67d8; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* =====================================================
   顶部（头部）
   ===================================================== */
.site-header { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.04); }
.topbar { background: #fff; border-bottom: 1px solid #edf2f7; }
.topbar-inner {
    display: flex;
    align-items: center;
    min-height: 56px;
    gap: 12px;
}
.brand {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 4px;
}
.brand:hover { text-decoration: none; color: #5a67d8; }

/* 水平横向导航 */
.main-nav {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
    color: #4a5568;
    padding: 8px 14px;
    border-radius: 6px;
    transition: .2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.main-nav a:hover { background: #edf2f7; text-decoration: none; }
.main-nav a.active { background: #5a67d8; color: #fff; }

/* 用户区 */
.user-area {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}
.user-area .hello { color: #4a5568; font-size: 13px; white-space: nowrap; }
.user-area .credits-chip {
    display: inline-block;
    background: #fff5f5;
    color: #c53030;
    padding: 3px 10px;
    border-radius: 12px;
    margin-left: 4px;
    font-size: 12px;
    white-space: nowrap;
}
.user-area .credits-chip b { color: #e53e3e; font-size: 14px; }
.user-area .link { color: #5a67d8; font-size: 13px; white-space: nowrap; }
.user-area .reg-link {
    background: #ed8936;
    color: #fff;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 12px;
}
.user-area .reg-link:hover { background: #dd6b20; text-decoration: none; color: #fff; }

/* =====================================================
   搜索区（卡片化、占满）
   ===================================================== */
.searchbar-wrap {
    background: #fafbff;
    padding: 16px 0;
}
.search-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 14px rgba(0,0,0,.05);
    padding: 20px;
}
.search-label {
    display: block;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #2d3748;
    white-space: normal;
}
.search-row {
    display: flex;
    border: 2px solid #5a67d8;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    min-width: 0;
}
.search-row input[type=text] {
    flex: 1 1 0%;
    min-width: 0;          /* 关键：允许 input 在 flex 里缩小 */
    width: 100%;
    border: 0;
    padding: 14px 16px;
    font-size: 15px;
    outline: none;
    background: transparent;
}
.search-row button {
    flex-shrink: 0;
    border: 0;
    background: #5a67d8;
    color: #fff;
    padding: 0 36px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
    white-space: nowrap;
}
.search-row button:hover { background: #4c51bf; }

/* ---------- 公告 ---------- */
.announcement {
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 16px 0;
    color: #2a4365;
    word-break: keep-all;
    overflow-wrap: break-word;
}
.ann-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 10px;
}
.ann-title .ann-bar {
    display: inline-block;
    width: 5px;
    height: 22px;
    background: #e53e3e;
    border-radius: 3px;
}
.ann-body {
    font-size: 16px;
    line-height: 1.8;
    color: #2d3748;
    font-weight: 500;
    white-space: pre-line;
}
.ann-time {
    margin-top: 10px;
    text-align: right;
    font-size: 13px;
    color: #2c5282;
}
.announcement .muted { color: #718096; font-size: 12px; }

/* ---------- 首页弹窗公告（关闭后24小时不再弹，JS控制显示） ---------- */
.popup-mask {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.popup-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    padding: 28px 26px 24px;
    max-width: 420px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}
.popup-box .ann-title { justify-content: flex-start; }
.popup-box .ann-body { margin-bottom: 22px; }
.popup-close-btn {
    display: block;
    width: 100%;
    padding: 12px 0;
    font-size: 16px;
    border-radius: 8px;
}

/* ---------- 卡片 ---------- */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.04);
    padding: 24px;
    margin: 16px 0;
}
.card h1, .card h2, .card h3 { margin-top: 0; }
.card-title {
    font-size: 18px;
    font-weight: 600;
    border-left: 4px solid #5a67d8;
    padding-left: 10px;
    margin: 24px 0 16px;
}

/* ---------- 按钮 ---------- */
.btn, button.btn, a.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    border: 0;
    font-size: 14px;
    cursor: pointer;
    background: #5a67d8;
    color: #fff;
    transition: .2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: #4c51bf; text-decoration: none; color: #fff; }
.btn[disabled] { background: #cbd5e0; cursor: not-allowed; }
.btn-default { background: #edf2f7; color: #2d3748; }
.btn-default:hover { background: #e2e8f0; color: #2d3748; }
.btn-danger { background: #e53e3e; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-warn { background: #ed8936; }
.btn-warn:hover { background: #dd6b20; }
.btn-success { background: #38a169; }
.btn-success:hover { background: #2f855a; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-row label .required { color: #e53e3e; }
.form-row input:not([type="checkbox"]):not([type="radio"]), .form-row textarea, .form-row select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: .2s;
    background: #fff;
    word-break: keep-all;
}
.form-row input[type="checkbox"], .form-row input[type="radio"] {
    width: 16px; height: 16px; min-width: 16px;
    margin: 0 6px 0 0;
    padding: 0; border: 0; border-radius: 4px;
    vertical-align: -2px;
    accent-color: #5a67d8;
    cursor: pointer;
    flex: none;
}
.form-row label.check-line {
    display: flex; align-items: center;
    font-weight: 500; margin-bottom: 4px;
    cursor: pointer; user-select: none;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90,103,216,.12);
}
.form-row textarea { min-height: 96px; resize: vertical; }
.form-row .hint { color: #718096; font-size: 12px; margin-top: 4px; }
.form-inline { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.form-inline .form-row { margin: 0; }

/* ---------- 提示 ---------- */
.msg { padding: 10px 16px; border-radius: 6px; margin: 8px 0; word-break: keep-all; overflow-wrap: break-word; }
.msg-info { background: #ebf8ff; color: #2a4365; border: 1px solid #90cdf4; }
.msg-ok { background: #f0fff4; color: #22543d; border: 1px solid #9ae6b4; }
.msg-err { background: #fff5f5; color: #742a2a; border: 1px solid #fc8181; }
.msg-warn { background: #fffaf0; color: #7b341e; border: 1px solid #f6ad55; }

/* ---------- 表格（关键：内部不断字） ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,.04);
    table-layout: auto;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
    /* 关键修复：表格内中文 keep-all */
    word-break: keep-all;
    overflow-wrap: break-word;
    white-space: normal;
    vertical-align: top;
}
.table th { background: #f7fafc; font-weight: 600; color: #2d3748; white-space: nowrap; }
.table tr:hover td { background: #fafbff; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- 状态徽标（不再竖排） ---------- */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.6;
    white-space: nowrap;
}
.tag-pending { background: #fff5f5; color: #c53030; }
.tag-done    { background: #f0fff4; color: #22543d; }
.tag-custom  { background: #ebf8ff; color: #2a4365; }
.tag-empty   { background: #fffaf0; color: #7b341e; }

/* ---------- 提交说明 ---------- */
.notice-list { padding-left: 22px; }
.notice-list li { margin: 6px 0; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 6px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.pager a {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
}
.pager a.active { background: #5a67d8; color: #fff; border-color: #5a67d8; }
.pager .page-nav { font-weight: bold; color: #4a5568; }
.pager .page-nav.disabled { color: #cbd5e0; background: #f7fafc; border-color: #edf2f7; cursor: not-allowed; }
.pager .pager-gap { padding: 6px 4px; color: #a0aec0; align-self: center; }
.pager .pager-info { padding: 6px 2px; color: #718096; font-size: 12px; align-self: center; margin-left: 6px; white-space: nowrap; }

/* ---------- 页脚 ---------- */
.site-footer { text-align: center; padding: 24px 0; color: #718096; font-size: 13px; margin-top: 32px; }

/* ---------- 文本辅助 ---------- */
.muted { color: #718096; }
.text-red { color: #e53e3e; }
.text-green { color: #38a169; }
hr { border: 0; border-top: 1px solid #edf2f7; margin: 24px 0; }

/* ---------- 收款码（并排显示） ---------- */
.qr-row {
    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: start;
    flex-wrap: nowrap;
}
.qr-row figure {
    margin: 0;
    text-align: center;
    flex: 1 1 0;
    min-width: 0;
    max-width: 220px;
}
.qr-row img {
    width: 100%;
    max-width: 220px;
    border: 1px solid #edf2f7;
    border-radius: 8px;
}
.qr-row figcaption {
    margin-top: 8px;
    font-size: 14px;
    color: #4a5568;
    font-weight: 600;
}
.qr-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #edf2f7;
    color: #a0aec0;
    border-radius: 8px;
    font-size: 14px;
}

/* ---------- 赞助档 ---------- */
.package-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.package-item {
    background: #fff;
    border: 2px solid #edf2f7;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: .2s;
    cursor: pointer;
}
.package-item:hover { border-color: #5a67d8; }
.package-item h3 { margin: 0 0 8px; font-size: 18px; color: #5a67d8; }
.package-item .price { font-size: 24px; font-weight: 700; color: #e53e3e; margin: 8px 0; }
.package-item .credits { color: #4a5568; }

/* =====================================================
   手机端底部导航栏（默认隐藏，<=768px 显示，fixed 沉底）
   ===================================================== */
.mobile-tabbar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
    z-index: 1000;
    min-height: 56px;
    align-items: center;
    justify-content: space-around;
    border-top: 1px solid #edf2f7;
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tabbar a {
    flex: 1;
    text-align: center;
    color: #a0aec0;
    font-size: 11px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    transition: .2s;
    white-space: nowrap;
}
.mobile-tabbar a:hover { text-decoration: none; }
.mobile-tabbar a.active { color: #5a67d8; }
.mobile-tabbar .tab-icon { font-size: 20px; line-height: 1; }

/* ---------- 每日签到悬浮按钮（页面右侧中间，签到完成后消失） ---------- */
.sign-fab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 16px 11px;
    border: none;
    cursor: pointer;
    background: linear-gradient(150deg, #ff7849, #e53e3e);
    color: #fff;
    border-radius: 16px 0 0 16px;
    box-shadow: -4px 4px 16px rgba(229, 62, 62, .38);
    font-size: 15px;
    font-weight: bold;
    line-height: 1.3;
    letter-spacing: 1px;
    transition: transform .25s ease, opacity .4s ease;
    -webkit-tap-highlight-color: transparent;
}
.sign-fab:hover { transform: translateY(-50%) translateX(-4px); }
.sign-fab:active { transform: translateY(-50%) translateX(-2px) scale(.97); }
.sign-fab .sf-icon { font-size: 20px; line-height: 1; }
.sign-fab .sf-text { font-size: 15px; }
.sign-fab .sf-credits {
    font-size: 11px;
    font-weight: normal;
    letter-spacing: 0;
    background: rgba(255, 255, 255, .22);
    padding: 1px 6px;
    border-radius: 8px;
}
.sign-fab.loading { opacity: .65; cursor: wait; }
.sign-fab.hide {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(120%);
}

/* 签到结果轻提示 */
.sign-toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(26, 32, 44, .92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 1300;
    font-size: 14px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .28);
    opacity: 0;
    transition: opacity .35s ease, transform .35s ease;
    pointer-events: none;
    max-width: 86vw;
    text-align: center;
}
.sign-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =====================================================
   响应式：<= 768px（手机）
   ===================================================== */
@media (max-width: 768px) {
    .wrap { padding: 0 12px; }

    /* 顶部条精简 */
    .topbar-inner { min-height: 48px; gap: 8px; }
    .brand { font-size: 15px; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; }

    /* 桌面导航隐藏，用底部 Tab 代替 */
    .main-nav { display: none; }

    /* 用户区：与 PC 端一致显示 用户名+积分+退出（隐藏"你好，"前缀，紧凑排布） */
    .user-area { gap: 6px; margin-left: auto; }
    .user-area .hello {
        display: flex; align-items: center; gap: 5px;
        font-size: 12px; white-space: nowrap;
        max-width: 44vw; overflow: hidden;
    }
    .user-area .hello .hello-prefix { display: none; }
    .user-area .hello > a {
        max-width: 22vw; overflow: hidden; text-overflow: ellipsis;
    }
    .user-area .credits-chip {
        padding: 3px 8px;
        font-size: 11px;
    }
    .user-area .credits-chip b { font-size: 13px; }
    .user-area .link { font-size: 12px; }
    .user-area .reg-link { padding: 4px 10px; font-size: 11px; }

    /* 显示底部导航 Tab，body 留出高度防止内容被遮挡 */
    .mobile-tabbar { display: flex; }
    body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

    /* 签到悬浮按钮（手机端稍小，避免遮挡内容） */
    .sign-fab { padding: 13px 9px; }
    .sign-fab .sf-icon { font-size: 17px; }
    .sign-fab .sf-text { font-size: 13px; }

    /* 搜索卡片占满 + 输入框不被挤压 */
    .searchbar-wrap { padding: 10px 0; }
    .search-card { padding: 14px 12px; }
    .search-label { font-size: 15px; margin-bottom: 8px; }
    .search-row { border-width: 2px; }
    .search-row input[type=text] {
        padding: 12px 12px;
        font-size: 14px;
        flex: 1 1 0%;
        min-width: 0;
    }
    .search-row button { padding: 0 18px; font-size: 14px; }

    /* 公告/卡片 */
    .announcement { padding: 12px 14px; }
    .ann-title { font-size: 17px; margin-bottom: 8px; }
    .ann-title .ann-bar { height: 19px; width: 4px; }
    .ann-body { font-size: 14px; line-height: 1.7; }
    /* 首页弹窗 */
    .popup-mask { padding: 16px; }
    .popup-box { padding: 20px 18px 18px; }
    .ann-time { font-size: 12px; margin-top: 8px; }
    .card { padding: 16px; margin: 12px 0; }

    /* 表格水平滚动兜底 */
    .table-wrap { overflow-x: auto; }

    /* 响应式表格：手机端变卡片（关键：解决表格竖排） */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr {
        background: #fff;
        border: 1px solid #edf2f7;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 10px 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,.03);
    }
    .table-stack td {
        border: 0;
        padding: 4px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
        white-space: normal;
        word-break: keep-all;
    }
    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #4a5568;
        text-align: left;
        flex-shrink: 0;
    }
    .table-stack td[data-label]:empty::before { content: ''; }

    /* 按钮 */
    .btn { padding: 9px 16px; font-size: 13px; }

    /* 收款码手机端缩小但保持并排 */
    .qr-row { gap: 12px; }
    .qr-row figure { max-width: 150px; }
    .qr-row img { max-width: 150px; }
    .qr-placeholder { max-width: 150px; font-size: 12px; }
}

@media (max-width: 380px) {
    .search-row button { padding: 0 14px; }
    .brand { font-size: 14px; }
}
