<?php
/**
 * 800BUS - 资讯页面
 * 支持显示资讯列表和单个资讯详情
 */
require_once __DIR__ . '/includes/config.php';
require_once __DIR__ . '/includes/media_helpers.php';
require_once __DIR__ . '/includes/admin_helpers.php';
session_start();

$is_logged_in = isset($_SESSION['user_id']);
$user_data = null;
if ($is_logged_in) {
    $uid = $_SESSION['user_id'];
    $u_res = $conn->query("SELECT username, is_admin FROM users WHERE id = $uid");
    $user_data = $u_res->fetch_assoc();
}

// 获取参数
$id = (int)($_GET['id'] ?? 0);
$category = trim($_GET['category'] ?? '');
$page = max(1, (int)($_GET['page'] ?? 1));
$per_page = 12;

// 判断是显示详情还是列表
$news = null;
$news_list = [];
$total = 0;
$total_pages = 0;

if ($id > 0) {
    // 显示单个资讯详情
    $news = get_news_by_id($conn, $id);
    if ($news) {
        // 增加浏览次数
        increment_news_view_count($conn, $id);
    }
} else {
    // 显示资讯列表
    $valid_categories = ['公交运营', '人物志'];
    $category_filter = in_array($category, $valid_categories) ? $category : null;
    
    $result = get_news_list($conn, $category_filter, null, null, 1, $page, $per_page);
    $news_list = $result['list'];
    $total = $result['total'];
    $total_pages = $result['total_pages'];
}

// 页面标题
$page_title = '资讯';
if ($id > 0 && $news) {
    $page_title = htmlspecialchars($news['title']) . ' - 资讯';
} elseif ($category) {
    $page_title = $category . ' - 资讯';
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $page_title ?> - 800BUS</title>
    <link rel="icon" href="/favicon.ico">
    <style>
        :root {
            --primary: #3b82f6;
            --primary-light: #dbeafe;
            --bg: #f8fafc;
            --card-bg: #ffffff;
            --text: #1e293b;
            --text-light: #64748b;
            --border: #e2e8f0;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: var(--bg);
            color: var(--text);
            line-height: 1.6;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        /* 导航栏 */
        .navbar {
            background: var(--card-bg);
            border-bottom: 1px solid var(--border);
            padding: 15px 0;
            margin-bottom: 30px;
        }
        
        .navbar .container {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            font-size: 24px;
            font-weight: 700;
            color: var(--primary);
            text-decoration: none;
        }
        
        .nav-links {
            display: flex;
            gap: 20px;
            align-items: center;
        }
        
        .nav-links a {
            color: var(--text-light);
            text-decoration: none;
            font-size: 14px;
            transition: color 0.2s;
        }
        
        .nav-links a:hover {
            color: var(--primary);
        }
        
        /* 页面标题 */
        .page-header {
            margin-bottom: 30px;
        }
        
        .page-title {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 10px;
        }
        
        .page-subtitle {
            color: var(--text-light);
            font-size: 16px;
        }
        
        /* 分类标签 */
        .category-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 30px;
            flex-wrap: wrap;
        }
        
        .category-tab {
            padding: 10px 20px;
            border-radius: 20px;
            background: var(--card-bg);
            border: 1px solid var(--border);
            color: var(--text-light);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s;
        }
        
        .category-tab:hover,
        .category-tab.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }
        
        /* 资讯卡片网格 */
        .news-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .news-card {
            background: #fff;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 2px 12px rgba(0,0,0,0.06);
            transition: all 0.3s ease;
            text-decoration: none;
            color: inherit;
            display: flex;
            flex-direction: column;
            border: 1px solid #f1f5f9;
        }
        
        .news-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.1);
        }
        
        .news-card-image {
            height: 180px;
            overflow: hidden;
            background: #f1f5f9;
            position: relative;
        }
        
        .news-card-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s;
        }
        
        .news-card:hover .news-card-image img {
            transform: scale(1.03);
        }
        
        .news-card-no-image {
            height: 8px;
            background: linear-gradient(90deg, #3b82f6, #60a5fa);
        }
        
        .news-card-no-image.green {
            background: linear-gradient(90deg, #22c55e, #4ade80);
        }
        
        .news-card-content {
            padding: 16px 20px 20px;
            flex: 1;
            display: flex;
            flex-direction: column;
        }
        
        .news-card-meta {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 10px;
        }
        
        .news-category-badge {
            font-size: 11px;
            padding: 4px 10px;
            border-radius: 12px;
            font-weight: 600;
        }
        
        .news-category-badge.公交运营 {
            background: #dbeafe;
            color: #1e40af;
        }
        
        .news-category-badge.人物志 {
            background: #dcfce7;
            color: #166534;
        }
        
        .news-card-title {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 10px;
            line-height: 1.4;
        }
        
        .news-card-excerpt {
            color: var(--text-light);
            font-size: 14px;
            line-height: 1.6;
            margin-bottom: 15px;
            flex: 1;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .news-card-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 12px;
            color: var(--text-light);
            padding-top: 15px;
            border-top: 1px solid var(--border);
        }
        
        /* 详情页样式 */
        .news-detail {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 30px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            margin-bottom: 30px;
        }
        
        .news-detail-header {
            margin-bottom: 25px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border);
        }
        
        .news-detail-title {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 15px;
            line-height: 1.3;
        }
        
        .news-detail-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            color: var(--text-light);
            font-size: 14px;
        }
        
        .news-detail-meta span {
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        .news-detail-content {
            font-size: 16px;
            line-height: 1.8;
            margin-bottom: 30px;
        }
        
        .news-detail-content p {
            margin-bottom: 20px;
        }
        
        .news-images {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 15px;
            margin: 25px 0;
        }
        
        .news-image-item {
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid var(--border);
            cursor: pointer;
            transition: transform 0.2s;
        }
        
        .news-image-item:hover {
            transform: scale(1.02);
        }
        
        .news-image-item img {
            width: 100%;
            height: 200px;
            object-fit: cover;
            display: block;
        }
        
        /* 分页 */
        .pagination {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 30px;
        }
        
        .pagination a,
        .pagination span {
            padding: 10px 15px;
            border-radius: 8px;
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
        }
        
        .pagination a {
            background: var(--card-bg);
            border: 1px solid var(--border);
            color: var(--text);
        }
        
        .pagination a:hover {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }
        
        .pagination .current {
            background: var(--primary);
            color: white;
            border: 1px solid var(--primary);
        }
        
        .pagination .disabled {
            background: #f1f5f9;
            color: #94a3b8;
            cursor: not-allowed;
        }
        
        /* 返回按钮 */
        .back-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 10px 20px;
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            text-decoration: none;
            font-size: 14px;
            margin-bottom: 20px;
            transition: all 0.2s;
        }
        
        .back-btn:hover {
            background: #f1f5f9;
            border-color: var(--primary);
            color: var(--primary);
        }
        
        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: var(--text-light);
        }
        
        .empty-state-icon {
            font-size: 48px;
            margin-bottom: 15px;
        }
        
        .empty-state-text {
            font-size: 16px;
        }
        
        /* 响应式 */
        @media (max-width: 768px) {
            .news-grid {
                grid-template-columns: 1fr;
            }
            
            .news-detail {
                padding: 20px;
            }
            
            .news-detail-title {
                font-size: 24px;
            }
            
            .category-tabs {
                justify-content: center;
            }
        }
    </style>
</head>
<body>
    <div id="ntoast" style="position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(0.85);background:rgba(0,0,0,0.78);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);color:#fff;padding:14px 28px;border-radius:14px;font-size:15px;font-weight:500;z-index:9999;opacity:0;pointer-events:none;transition:all 0.25s cubic-bezier(0.25,0.46,0.45,0.94);text-align:center;max-width:80vw;box-shadow:0 8px 32px rgba(0,0,0,0.3);"></div>
    <nav class="navbar">
        <div class="container">
            <a href="/" class="logo">🚌 800BUS</a>
            <div class="nav-links">
                <a href="/">首页</a>
                <a href="/gallery">图库</a>
                <a href="/browse">浏览</a>
                <a href="/news" style="color: var(--primary); font-weight: 600;">资讯</a>
                <?php if ($is_logged_in): ?>
                    <a href="/user/"><?= htmlspecialchars($user_data['username'] ?? '用户') ?></a>
                <?php else: ?>
                    <a href="/login">登录</a>
                <?php endif; ?>
            </div>
        </div>
    </nav>

    <div class="container">
        <?php if ($id > 0 && $news): ?>
            <!-- 详情页 -->
            <a href="javascript:history.back()" class="back-btn">← 返回</a>
            
            <div class="news-detail">
                <div class="news-detail-header">
                    <div class="news-card-meta" style="margin-bottom: 15px;">
                        <span class="news-category-badge <?= $news['category'] ?>"><?= $news['category'] ?></span>
                        <?php if ($news['is_anonymous']): ?>
                        <span style="font-size: 11px; color: var(--text-light);">匿名投稿</span>
                        <?php endif; ?>
                    </div>
                    
                    <h1 class="news-detail-title"><?= htmlspecialchars($news['title']) ?></h1>
                    
                    <div class="news-detail-meta">
                        <span>👤 <?= $news['is_anonymous'] ? '匿名用户' : htmlspecialchars($news['username'] ?? '未知') ?></span>
                        <span>📍 <?= htmlspecialchars(($news['province_name'] ?? '') . ' ' . ($news['city_name'] ?? '')) ?></span>
                        <span>📅 <?= date('Y年m月d日 H:i', strtotime($news['created_at'])) ?></span>
                        <span>👁️ <?= number_format($news['view_count']) ?> 次浏览</span>
                    </div>
                </div>
                
                <div class="news-detail-content">
                    <?= parse_markdown($news['content']) ?>
                </div>
                
                <?php if (!empty($news['images']) && is_array($news['images'])): ?>
                <div class="news-images">
                    <?php foreach ($news['images'] as $img): ?>
                    <div class="news-image-item" onclick="window.open('<?= htmlspecialchars($img['original'] ?? $img['thumbnail'] ?? '') ?>', '_blank')">
                        <img src="<?= htmlspecialchars($img['thumbnail'] ?? $img['original'] ?? '') ?>" 
                             alt="资讯图片" loading="lazy">
                    </div>
                    <?php endforeach; ?>
                </div>
                <?php endif; ?>
            </div>

            <?php if ($is_logged_in && !empty($news['author_user_id'])): ?>
            <div style="display:flex; gap:10px; margin-top:20px; flex-wrap:wrap;">
                <button onclick="openNewsRate()" style="padding:10px 20px; border-radius:12px; border:1px solid rgba(0,0,0,0.08); background:rgba(255,255,255,0.9); backdrop-filter:blur(12px); cursor:pointer; font-size:13px; font-weight:600; transition:all 0.2s;">
                    ⭐ 评分
                </button>
                <button onclick="openNewsTip()" style="padding:10px 20px; border-radius:12px; border:1px solid rgba(146,164,14,0.2); background:rgba(254,243,199,0.9); backdrop-filter:blur(12px); cursor:pointer; font-size:13px; font-weight:600; color:#92400e; transition:all 0.2s;">
                    🪙 投币
                </button>
            </div>
            <?php endif; ?>

            <div style="margin-top:32px;">
                <h3 style="font-size:18px; font-weight:700; margin-bottom:16px;">💬 评论区</h3>
                <?php if ($is_logged_in): ?>
                <div style="display:flex; gap:10px; margin-bottom:20px; align-items:flex-start;">
                    <textarea id="newsCommentInput" placeholder="说点什么..." maxlength="500" rows="2" style="flex:1; padding:12px 16px; border-radius:12px; border:1px solid rgba(0,0,0,0.08); background:rgba(255,255,255,0.9); backdrop-filter:blur(12px); resize:none; font-size:14px; font-family:inherit; outline:none;"></textarea>
                    <button onclick="submitNewsComment()" id="newsCommentBtn" style="padding:12px 20px; border-radius:12px; border:none; background:#000; color:#fff; font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap;">发布</button>
                </div>
                <?php else: ?>
                <p style="color:#94a3b8; font-size:13px; margin-bottom:16px;"><a href="login" style="color:var(--primary);">登录</a>后参与评论</p>
                <?php endif; ?>
                <div id="newsComments"></div>
            </div>

        <?php else: ?>
            <!-- 列表页 -->
            <div class="page-header">
                <h1 class="page-title">📰 资讯</h1>
                <p class="page-subtitle">了解最新公交运营动态和人物故事</p>
            </div>
            
            <div class="category-tabs">
                <a href="/news" class="category-tab <?= empty($category) ? 'active' : '' ?>">全部</a>
                <a href="/news?category=公交运营" class="category-tab <?= $category === '公交运营' ? 'active' : '' ?>">🚌 公交运营</a>
                <a href="/news?category=人物志" class="category-tab <?= $category === '人物志' ? 'active' : '' ?>">👤 人物志</a>
            </div>
            
            <?php if (!empty($news_list)): ?>
            <div class="news-grid">
                <?php foreach ($news_list as $item): ?>
                <a href="/news/<?= $item['id'] ?>" class="news-card">
                    <?php if (!empty($item['images']) && is_array($item['images'])): ?>
                    <div class="news-card-image">
                        <img src="<?= htmlspecialchars($item['images'][0]['thumbnail'] ?? $item['images'][0]['original'] ?? '') ?>" 
                             alt="<?= htmlspecialchars($item['title']) ?>" loading="lazy">
                    </div>
                    <?php endif; ?>
                    
                    <div class="news-card-content">
                        <div class="news-card-meta">
                            <span class="news-category-badge <?= $item['category'] ?>"><?= $item['category'] ?></span>
                            <?php if ($item['is_anonymous']): ?>
                            <span style="font-size: 10px; color: var(--text-light);">匿名</span>
                            <?php endif; ?>
                        </div>
                        
                        <h2 class="news-card-title"><?= htmlspecialchars($item['title']) ?></h2>
                        
                        <p class="news-card-excerpt"><?= htmlspecialchars(mb_substr(strip_tags($item['content']), 0, 150)) ?></p>
                        
                        <div class="news-card-footer">
                            <span>📍 <?= htmlspecialchars(($item['province_name'] ?? '') . ' ' . ($item['city_name'] ?? '')) ?></span>
                            <span><?= date('m-d', strtotime($item['created_at'])) ?></span>
                        </div>
                    </div>
                </a>
                <?php endforeach; ?>
            </div>
            
            <!-- 分页 -->
            <?php if ($total_pages > 1): ?>
            <div class="pagination">
                <?php if ($page > 1): ?>
                <a href="/news?<?= $category ? 'category=' . urlencode($category) . '&' : '' ?>page=<?= $page - 1 ?>">上一页</a>
                <?php else: ?>
                <span class="disabled">上一页</span>
                <?php endif; ?>
                
                <?php for ($i = max(1, $page - 2); $i <= min($total_pages, $page + 2); $i++): ?>
                    <?php if ($i == $page): ?>
                    <span class="current"><?= $i ?></span>
                    <?php else: ?>
                    <a href="/news?<?= $category ? 'category=' . urlencode($category) . '&' : '' ?>page=<?= $i ?>"><?= $i ?></a>
                    <?php endif; ?>
                <?php endfor; ?>
                
                <?php if ($page < $total_pages): ?>
                <a href="/news?<?= $category ? 'category=' . urlencode($category) . '&' : '' ?>page=<?= $page + 1 ?>">下一页</a>
                <?php else: ?>
                <span class="disabled">下一页</span>
                <?php endif; ?>
            </div>
            <?php endif; ?>
            
            <?php else: ?>
            <div class="empty-state">
                <div class="empty-state-icon">📭</div>
                <div class="empty-state-text">暂无资讯内容</div>
            </div>
            <?php endif; ?>
        <?php endif; ?>
    </div>
    
    <script>
        var newsId = <?= $id ?>;
        var isLoggedIn = <?= $is_logged_in ? 'true' : 'false' ?>;
        var newsUserName = <?= json_encode($user_data['username'] ?? '') ?>;
        var _nt = null;
        function ntoast(m, d) {
            d = d || 2000;
            var e = document.getElementById('ntoast');
            e.textContent = m;
            e.style.opacity = '1';
            e.style.transform = 'translate(-50%,-50%) scale(1)';
            clearTimeout(_nt);
            _nt = setTimeout(function() { e.style.opacity = '0'; e.style.transform = 'translate(-50%,-50%) scale(0.85)'; }, d);
        }

        document.querySelectorAll('.news-image-item').forEach(item => {
            item.addEventListener('click', function() {
                const img = this.querySelector('img');
                if (img) window.open(img.src, '_blank');
            });
        });

        function openNewsRate() {
            if (!isLoggedIn) { window.location.href = 'login.php'; return; }
            var val = prompt("请输入您的评分 (1-5):", "5");
            if (val && val >= 1 && val <= 5) {
                var fd = new FormData();
                fd.append('id', newsId);
                fd.append('rating', val);
                fd.append('source_type', 'news');
                fetch('/api/rate.php', { method: 'POST', body: fd })
                    .then(function(r) { return r.json(); })
                    .then(function(d) { ntoast(d.msg || '评分完成'); })
                    .catch(function() { ntoast('网络错误'); });
            }
        }

        function openNewsTip() {
            if (!isLoggedIn) { window.location.href = 'login.php'; return; }
            document.getElementById('newsTipModal').style.display = 'flex';
        }
        function closeNewsTip() {
            document.getElementById('newsTipModal').style.display = 'none';
        }
        function confirmNewsTip(amt) {
            var fd = new FormData();
            fd.append('news_id', newsId);
            fd.append('amount', amt);
            fetch('/api/handler.php?action=tip_coin_news', { method: 'POST', body: fd })
                .then(function(r) { return r.json(); })
                .then(function(d) {
                    ntoast(d.msg || '投币完成');
                    if (d.status === 'success') closeNewsTip();
                })
                .catch(function(e) { ntoast('投币请求失败: ' + e.message); });
        }

        function loadNewsComments() {
            fetch('/api/comments.php?submission_id=' + newsId + '&source_type=news')
                .then(function(r) { return r.json(); })
                .then(function(d) {
                    if (d.status !== 'success') return;
                    var html = '';
                    if (!d.data || d.data.length === 0) {
                        html = '<p style="color:#94a3b8; font-size:13px; text-align:center; padding:20px;">暂无评论</p>';
                    } else {
                        d.data.forEach(function(c) {
                            html += '<div style="padding:14px 0; border-bottom:1px solid rgba(0,0,0,0.05);">';
                            html += '<div style="display:flex; align-items:center; gap:8px; margin-bottom:6px;">';
                            html += '<span style="font-weight:600; font-size:13px;">' + escapeHtml(c.username || '匿名') + '</span>';
                            html += '<span style="font-size:11px; color:#94a3b8;">' + timeAgo(c.created_at) + '</span></div>';
                            html += '<p style="margin:0; font-size:14px; line-height:1.6; color:#334155;">' + escapeHtml(c.content) + '</p>';
                            if (c.replies && c.replies.length > 0) {
                                c.replies.forEach(function(r) {
                                    html += '<div style="margin-top:10px; margin-left:20px; padding:10px 14px; background:rgba(0,0,0,0.02); border-radius:10px;">';
                                    html += '<div style="display:flex; align-items:center; gap:6px; margin-bottom:4px;">';
                                    html += '<span style="font-weight:600; font-size:12px;">' + escapeHtml(r.username || '匿名') + '</span>';
                                    if (r.reply_to) html += '<span style="font-size:11px; color:#94a3b8;">回复 ' + escapeHtml(r.reply_to) + '</span>';
                                    html += '<span style="font-size:11px; color:#94a3b8;">' + timeAgo(r.created_at) + '</span></div>';
                                    html += '<p style="margin:0; font-size:13px; line-height:1.5; color:#334155;">' + escapeHtml(r.content) + '</p></div>';
                                });
                            }
                            html += '</div>';
                        });
                    }
                    document.getElementById('newsComments').innerHTML = html;
                });
        }

        function submitNewsComment() {
            if (!isLoggedIn) { window.location.href = 'login.php'; return; }
            var input = document.getElementById('newsCommentInput');
            var content = input.value.trim();
            if (!content) return;
            var fd = new FormData();
            fd.append('submission_id', newsId);
            fd.append('content', content);
            fd.append('source_type', 'news');
            document.getElementById('newsCommentBtn').disabled = true;
            fetch('/api/comments.php', { method: 'POST', body: fd })
                .then(function(r) { return r.json(); })
                .then(function(d) {
                    document.getElementById('newsCommentBtn').disabled = false;
                    if (d.status === 'success') {
                        input.value = '';
                        loadNewsComments();
                        ntoast(d.msg || '评论已提交');
                    } else {
                        ntoast(d.msg || '评论失败');
                    }
                })
                .catch(function() {
                    document.getElementById('newsCommentBtn').disabled = false;
                    ntoast('网络错误');
                });
        }

        function escapeHtml(s) {
            var d = document.createElement('div');
            d.appendChild(document.createTextNode(s || ''));
            return d.innerHTML;
        }
        function timeAgo(dt) {
            var diff = (Date.now() - new Date(dt).getTime()) / 1000;
            if (diff < 60) return '刚刚';
            if (diff < 3600) return Math.floor(diff / 60) + '分钟前';
            if (diff < 86400) return Math.floor(diff / 3600) + '小时前';
            return Math.floor(diff / 86400) + '天前';
        }

        <?php if ($id > 0 && $news): ?>
        loadNewsComments();
        <?php endif; ?>
    </script>

    <?php if ($id > 0 && $news && $is_logged_in && !empty($news['author_user_id'])): ?>
    <div id="newsTipModal" style="display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:9998; align-items:center; justify-content:center;">
        <div style="background:#fff; border-radius:20px; padding:28px 24px; width:320px; max-width:90vw; box-shadow:0 20px 60px rgba(0,0,0,0.3); text-align:center;">
            <div style="font-size:40px; margin-bottom:8px;">🪙</div>
            <div style="font-size:17px; font-weight:700; margin-bottom:16px;">投币支持</div>
            <div style="display:flex; gap:10px; margin-bottom:16px;">
                <button onclick="confirmNewsTip(1)" style="flex:1; padding:12px; border:2px solid #92400e; border-radius:12px; background:#fef3c7; color:#92400e; font-size:18px; font-weight:800; cursor:pointer;">1 🪙</button>
                <button onclick="confirmNewsTip(2)" style="flex:1; padding:12px; border:2px solid #e2e8f0; border-radius:12px; background:#f8fafc; color:#64748b; font-size:18px; font-weight:800; cursor:pointer;">2 🪙</button>
            </div>
            <button onclick="closeNewsTip()" style="width:100%; padding:10px; border:none; background:#f1f5f9; border-radius:10px; font-size:13px; font-weight:600; cursor:pointer;">取消</button>
        </div>
    </div>
    <?php endif; ?>
</body>
</html>