{{--
    文件功能：每日签到日历弹窗。
    展示当月签到状态、今日签到入口、补签卡数量，并支持快速购买补签卡。
--}}

<style>
    .daily-sign-modal-overlay {
        position: fixed;
        inset: 0;
        z-index: 2600;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(15, 23, 42, 0.48);
        padding: 8px;
    }

    .daily-sign-modal {
        width: min(520px, 96vw);
        max-height: min(610px, 96vh);
        overflow: hidden;
        border-radius: 10px;
        background: #ffffff;
        box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
        border: 1px solid rgba(15, 118, 110, 0.16);
        display: flex;
        flex-direction: column;
    }

    .daily-sign-modal-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 6px 10px;
        border-bottom: 1px solid #e2e8f0;
        background: linear-gradient(90deg, #f0fdfa, #ffffff);
    }

    .daily-sign-modal-title {
        font-size: 14px;
        font-weight: 800;
        color: #0f766e;
    }

    .daily-sign-modal-close {
        border: none;
        background: #e2e8f0;
        color: #334155;
        border-radius: 7px;
        width: 24px;
        height: 24px;
        cursor: pointer;
        font-size: 15px;
        line-height: 24px;
    }

    .daily-sign-modal-body {
        padding: 6px 10px 8px;
        overflow-y: auto;
    }

    .daily-sign-summary {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px;
        margin-bottom: 6px;
    }

    .daily-sign-summary-card {
        border: 1px solid #dbeafe;
        background: #f8fafc;
        border-radius: 8px;
        padding: 5px 8px;
        min-width: 0;
    }

    .daily-sign-summary-card strong {
        display: block;
        color: #0f172a;
        font-size: 12px;
    }

    .daily-sign-summary-card span {
        color: #64748b;
        font-size: 11px;
    }

    .daily-sign-actions {
        display: flex;
        gap: 5px;
        margin-bottom: 6px;
    }

    .daily-sign-action-btn {
        flex: 1;
        border: none;
        border-radius: 8px;
        padding: 5px 8px;
        font-weight: 800;
        cursor: pointer;
        color: #ffffff;
        background: #0f766e;
        font-size: 11px;
    }

    .daily-sign-action-btn.secondary {
        background: #f59e0b;
    }

    .daily-sign-month-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 3px 0 4px;
    }

    .daily-sign-month-bar button {
        border: 1px solid #cbd5e1;
        background: #ffffff;
        border-radius: 7px;
        padding: 3px 7px;
        cursor: pointer;
        color: #334155;
        font-size: 11px;
    }

    .daily-sign-month-label {
        font-size: 12px;
        font-weight: 800;
        color: #0f172a;
    }

    .daily-sign-weekdays,
    .daily-sign-grid {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 3px;
    }

    .daily-sign-weekday {
        text-align: center;
        color: #64748b;
        font-size: 10px;
        font-weight: 700;
    }

    .daily-sign-day {
        min-height: 32px;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        background: #ffffff;
        padding: 2px;
        text-align: center;
        font-size: 9px;
        color: #334155;
        position: relative;
        overflow: hidden;
    }

    .daily-sign-day.blank {
        border-color: transparent;
        background: transparent;
    }

    .daily-sign-day.signed {
        border-color: #99f6e4;
        background: #f0fdfa;
        color: #0f766e;
    }

    .daily-sign-day.missed {
        border-color: #fed7aa;
        background: #fff7ed;
        color: #9a3412;
        cursor: pointer;
    }

    .daily-sign-day.today {
        box-shadow: inset 0 0 0 2px #14b8a6;
    }

    .daily-sign-day.future {
        background: #f8fafc;
        color: #94a3b8;
    }

    .daily-sign-day .day-num {
        display: block;
        font-weight: 800;
        font-size: 11px;
    }

    .daily-sign-day .day-state {
        display: block;
        margin-top: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .daily-sign-rewards {
        margin-top: 6px;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        background: #f8fafc;
        overflow: hidden;
    }

    .daily-sign-rewards-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        padding: 4px 8px;
        border-bottom: 1px solid #e2e8f0;
        color: #0f172a;
        font-size: 11px;
        font-weight: 800;
    }

    .daily-sign-rewards-list {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        padding: 5px 8px;
    }

    .daily-sign-reward-card {
        border: 1px solid #dbeafe;
        border-radius: 6px;
        background: #ffffff;
        padding: 4px;
        min-width: 0;
    }

    .daily-sign-reward-card.active {
        border-color: #14b8a6;
        background: #f0fdfa;
        box-shadow: inset 0 0 0 1px #14b8a6;
    }

    .daily-sign-reward-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 4px;
        color: #0f766e;
        font-size: 9px;
        font-weight: 800;
        white-space: nowrap;
    }

    .daily-sign-reward-name {
        margin-top: 1px;
        color: #334155;
        font-size: 9px;
        font-weight: 700;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .daily-sign-reward-desc {
        margin-top: 1px;
        color: #64748b;
        font-size: 8px;
        line-height: 1.15;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    @media (max-width: 520px) {
        .daily-sign-summary {
            grid-template-columns: 1fr 1fr;
        }

        .daily-sign-actions {
            flex-direction: row;
        }

        .daily-sign-day {
            min-height: 30px;
        }

        .daily-sign-rewards-list {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }
    }
</style>

<div id="daily-sign-modal" class="daily-sign-modal-overlay" data-daily-sign-modal-overlay>
    <div class="daily-sign-modal">
        <div class="daily-sign-modal-head">
            <div class="daily-sign-modal-title">✅ 每日签到</div>
            <button type="button" class="daily-sign-modal-close" data-daily-sign-close>×</button>
        </div>
        <div class="daily-sign-modal-body">
            <div class="daily-sign-summary">
                <div class="daily-sign-summary-card">
                    <strong id="daily-sign-streak">连续 0 天</strong>
                    <span id="daily-sign-preview">加载中...</span>
                </div>
                <div class="daily-sign-summary-card">
                    <strong id="daily-sign-card-count">补签卡 0 张</strong>
                    <span id="daily-sign-card-price">可在商店购买</span>
                </div>
            </div>
            <div class="daily-sign-actions">
                <button type="button" id="daily-sign-claim-btn" class="daily-sign-action-btn" data-daily-sign-claim>今日签到</button>
                <button type="button" id="daily-sign-buy-card-btn" class="daily-sign-action-btn secondary" data-daily-sign-buy-repair-card>购买补签卡</button>
            </div>
            <div class="daily-sign-month-bar">
                <button type="button" data-daily-sign-month="prev">上月</button>
                <div id="daily-sign-month-label" class="daily-sign-month-label">本月</div>
                <button type="button" data-daily-sign-month="next">下月</button>
            </div>
            <div class="daily-sign-weekdays">
                <div class="daily-sign-weekday">日</div>
                <div class="daily-sign-weekday">一</div>
                <div class="daily-sign-weekday">二</div>
                <div class="daily-sign-weekday">三</div>
                <div class="daily-sign-weekday">四</div>
                <div class="daily-sign-weekday">五</div>
                <div class="daily-sign-weekday">六</div>
            </div>
            <div id="daily-sign-calendar-grid" class="daily-sign-grid" style="margin-top:4px;"></div>
            <div class="daily-sign-rewards">
                <div class="daily-sign-rewards-head">
                    <span>连续奖励目标</span>
                    <span id="daily-sign-reward-progress" style="font-size:11px;color:#64748b;">当前 0 天</span>
                </div>
                <div id="daily-sign-rewards-list" class="daily-sign-rewards-list"></div>
            </div>
        </div>
    </div>
</div>
