/* ============================================================
   打赏独立小组件（自写，无 Vue/Element UI 依赖）
   引入方式：blade 组件 reward-btn.blade.php 自动引入
   依赖：global.css 的 UI token、Reward 模块后端 API（/api/reward/load, /api/reward/submit）
   ============================================================ */

/* --- 弹窗容器 --- */
.rw-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}
.rw-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 遮罩 */
.rw-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

/* 弹窗卡片 */
.rw-modal-dialog {
    position: relative;
    width: min(440px, calc(100vw - 32px));
    max-height: min(82vh, 720px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(14px) scale(0.97);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.rw-modal.is-open .rw-modal-dialog {
    transform: translateY(0) scale(1);
}

/* 弹窗头 */
.rw-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    flex-shrink: 0;
}
.rw-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}
.rw-modal-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.04);
    color: #475569;
    font-size: 20px; line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.rw-modal-close:hover { background: rgba(15, 23, 42, 0.08); color: #0f172a; transform: scale(1.06); }
.rw-modal-close:active { transform: scale(0.94); }

/* 弹窗体 */
.rw-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    -webkit-overflow-scrolling: touch;
}

/* --- 金额档位选择 --- */
.rw-amount-section { margin-bottom: 18px; }
.rw-amount-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 10px;
    font-weight: 500;
}
.rw-amount-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.rw-amount-btn {
    position: relative;
    padding: 12px 0;
    border: 1.5px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}
.rw-amount-btn:hover { border-color: #d97706; background: rgba(217, 119, 6, 0.04); }
.rw-amount-btn:active { transform: scale(0.96); }
.rw-amount-btn.is-selected {
    border-color: #d97706;
    background: rgba(217, 119, 6, 0.08);
    color: #d97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}
.rw-amount-num {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}
.rw-amount-btn.is-selected .rw-amount-num { color: #d97706; }
.rw-amount-unit {
    font-size: 11px;
    color: #94a3b8;
    margin-left: 1px;
}

/* 自定义金额输入 */
.rw-custom-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}
.rw-custom-row input[type="number"] {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    font-size: 14px;
    background: #f8fafc;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.rw-custom-row input[type="number"]:focus {
    border-color: #d97706;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}
.rw-custom-row input[type="number"]::placeholder { color: #94a3b8; }
.rw-custom-row span {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

/* --- 备注输入 --- */
.rw-msg-section { margin-bottom: 18px; }
.rw-msg-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 10px;
    font-weight: 500;
}
.rw-msg-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    font-size: 14px;
    background: #f8fafc;
    resize: none;
    min-height: 72px;
    font-family: inherit;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.rw-msg-input:focus {
    border-color: #d97706;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}
.rw-msg-input::placeholder { color: #94a3b8; }

/* --- 提交按钮 --- */
.rw-submit-btn {
    width: 100%;
    padding: 13px 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
    transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.rw-submit-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(217, 119, 6, 0.45); }
.rw-submit-btn:active { transform: translateY(0) scale(0.98); }
.rw-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: 0 4px 14px rgba(217, 119, 6, 0.2); }
.rw-submit-btn.rw-success { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35); }

/* --- 已打赏记录 --- */
.rw-rewards-section {
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    padding-top: 14px;
    margin-top: 14px;
}
.rw-rewards-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 10px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.rw-rewards-total { color: #d97706; font-weight: 700; }
.rw-rewards-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 140px;
    overflow-y: auto;
}
.rw-reward-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 10px;
    font-size: 13px;
}
.rw-reward-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rw-reward-info { flex: 1; min-width: 0; }
.rw-reward-name { color: #0f172a; font-weight: 500; }
.rw-reward-msg { color: #64748b; font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rw-reward-money { color: #d97706; font-weight: 700; flex-shrink: 0; }
.rw-rewards-empty {
    text-align: center;
    padding: 16px;
    color: #94a3b8;
    font-size: 13px;
}
.rw-rewards-empty-icon { font-size: 28px; margin-bottom: 6px; }

/* --- 加载/错误状态 --- */
.rw-loading, .rw-error {
    padding: 20px;
    text-align: center;
    font-size: 14px;
}
.rw-loading { color: #64748b; }
.rw-error { color: #dc2626; }
.rw-spinner {
    width: 28px; height: 28px;
    border: 2.5px solid rgba(15, 23, 42, 0.08);
    border-top-color: #d97706;
    border-radius: 50%;
    animation: rw-spin 0.7s linear infinite;
    margin: 0 auto 10px;
}
@keyframes rw-spin { to { transform: rotate(360deg); } }

/* --- 打赏悬浮按钮（竖排，与收藏分开） --- */
.rw-float-btn {
    position: fixed;
    right: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 52px; height: 52px;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    font-family: inherit;
    transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    appearance: none;
    -webkit-appearance: none;
}
.rw-float-btn:hover { background: rgba(217, 119, 6, 0.06); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(217, 119, 6, 0.15); }
.rw-float-btn:active { transform: scale(0.95); }
.rw-float-btn .rw-float-icon { font-size: 20px; line-height: 1; }
.rw-float-btn .rw-float-label { font-size: 10px; color: #64748b; font-weight: 500; line-height: 1; }
.rw-float-btn:hover .rw-float-label { color: #d97706; }

/* 收藏按钮已收藏高亮（复用 .rw-float-btn 的收藏按钮） */
.rw-float-btn.favorite-float-btn.is-favorited {
    background: rgba(255, 107, 53, 0.08);
    border-color: rgba(255, 107, 53, 0.2);
}
.rw-float-btn.favorite-float-btn.is-favorited .rw-float-icon {
    color: #ff6b35;
    animation: rw-fav-pop 0.4s ease;
}
.rw-float-btn.favorite-float-btn.is-favorited .rw-float-label {
    color: #ff6b35;
    font-weight: 600;
}
@keyframes rw-fav-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* --- 工具类 --- */
.rw-hidden { display: none !important; }

/* --- 响应式：移动端弹窗更宽 --- */
@media (max-width: 520px) {
    .rw-amount-grid { grid-template-columns: repeat(3, 1fr); }
    .rw-modal-dialog { width: calc(100vw - 24px); max-height: 88vh; border-radius: 16px; }
    .rw-float-btn { right: 16px; width: 48px; height: 48px; border-radius: 14px; }
}

/* 工作台/预览台打开时隐藏 */
body.workbench-open .rw-float-btn,
body.preview-open .rw-float-btn { display: none !important; }
