/* ============================================
   数独模块独有样式
   适用于：sudoku/index.php（生成器）、gallery.php、detail.php、user_sudokus.php
   （全局样式如 .global-modal / .save-modal / #toast 已在 style.css 中定义，此处不再重复）
   ============================================ */

/* ===== 数独生成器 - 格子样式 ===== */
.sudoku-board {
    display: inline-grid;
    background: #1e293b;
    border: 2.5px solid #1e293b;
    border-radius: 6px;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.sudoku-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #334155;
    background: #fff;
    border: 1px solid #cbd5e1;
    transition: background 0.15s;
    cursor: pointer;
    box-sizing: border-box;
    line-height: 1;
}
.sudoku-cell.given {
    font-weight: 700;
    color: #1e40af;
    background: rgba(255,255,255,0.85);
    cursor: default;
}
.sudoku-cell.selected {
    background: #bfdbfe !important;
    box-shadow: inset 0 0 0 2px #3b82f6;
}
.sudoku-cell.highlight {
    background: #f1f5f9;
}
.sudoku-cell.border-right-thick {
    border-right: 2.5px solid #1e293b !important;
}
.sudoku-cell.border-bottom-thick {
    border-bottom: 2.5px solid #1e293b !important;
}

/* ===== 数独广场页面 ===== */
.sudoku-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.sudoku-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}
.sudoku-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.sudoku-card-body { padding: 14px 16px; }
.sudoku-card-body h3 { font-size: 1rem; margin: 0 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sudoku-card-meta { font-size: 12px; color: var(--text-light); display: flex; gap: 12px; flex-wrap: wrap; }
.sudoku-card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.sudoku-card-tag {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(59,130,246,0.1);
    color: var(--primary);
}

/* 难度标签 */
.diff-tag { padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.diff-easy { background: #dcfce7; color: #166534; }
.diff-medium { background: #fef9c3; color: #854d0e; }
.diff-hard { background: #fee2e2; color: #991b1b; }
.diff-expert { background: #ede9fe; color: #5b21b6; }
.diff-master { background: #fce7f3; color: #9d174d; }
.diff-custom { background: #e0f2fe; color: #075985; }

/* ===== 数独详情页 ===== */
.detail-container { max-width: 900px; margin: 0 auto; }
.detail-header { margin-bottom: 20px; }
.detail-header h2 { margin: 0 0 8px 0; }
.detail-meta { font-size: 13px; color: #64748b; display: flex; gap: 16px; flex-wrap: wrap; }
.detail-content { display: flex; gap: 24px; flex-wrap: wrap; }
.detail-board { flex: 1; min-width: 300px; text-align: center; }
.detail-info { flex: 0 0 260px; }

/* 数独网格（详情页） */
.sudoku-grid {
    display: inline-grid;
    gap: 1px;
    padding: 2px;
    background: #333;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: fit-content;
    margin: 0 auto;
}
.sudoku-grid div {
    width: 30px;
    height: 30px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}
.sudoku-grid div.given { color: #1e40af; background: #f8fafc; }

/* 信息卡片 */
.info-card {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border, #e2e8f0);
    margin-bottom: 12px;
}
.info-card h3 { font-size: 14px; margin: 0 0 10px 0; }

/* 标签 */
.info-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.6rem;
    margin: 15px 0;
    justify-content: center;
    overflow: hidden;
}
.info-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(59,130,246,0.12);
    padding: 0.3rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Hero 区域内的标题+标签一行布局 */
.hero-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}
.hero-title-row h1 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.8rem); white-space: nowrap; }
.hero-title-row .info-tags { margin: 0; }

/* 详情页 Hero 标签白色风格 */
.page-hero .info-tag { background: rgba(255,255,255,0.2); color: white; }
.page-hero .hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

/* ===== 用户数独宝库页面 ===== */
.user-sudokus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.user-sudoku-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}
.user-sudoku-card:hover { transform: translateY(-2px); }
.user-sudoku-info { padding: 14px 16px; }
.user-sudoku-info h3 { font-size: 1rem; margin: 0 0 8px; }
.user-sudoku-info h3 a { color: var(--text, #1e293b); text-decoration: none; }
.user-sudoku-info h3 a:hover { color: #3b82f6; }
.user-sudoku-meta { font-size: 12px; color: #64748b; display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.user-sudoku-actions { display: flex; gap: 8px; margin-top: 10px; }

/* 用户宝库页面 - 数独列表 */
.sudoku-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.sudoku-card-header h3 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.sudoku-card-actions { display: flex; gap: 0.75rem; }
.sudoku-card-actions .btn,
.sudoku-card-actions .btn-danger {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: opacity 0.2s;
    border: none;
    font-family: inherit;
    line-height: 1.5;
}
.sudoku-card-actions .btn {
    background: linear-gradient(135deg, var(--primary), var(--accent, #4a8ae8));
    color: white;
}
.sudoku-card-actions .btn-danger { background: #e74c3c; color: white; }
.sudoku-card-actions .btn-danger:hover { opacity: 0.9; }

.sudoku-info { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

@media (max-width: 640px) {
    .sudoku-card-header { flex-direction: column; align-items: flex-start; }
    .sudoku-card-actions { width: 100%; }
    .sudoku-card-actions .btn,
    .sudoku-card-actions .btn-danger { flex: 1; text-align: center; }
}

/* 公开/私有标签 */
.public-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}
.public-badge.pub { background: #dcfce7; color: #166534; }
.public-badge.pri { background: #fef2f2; color: #991b1b; }

/* 打印预览层 */
.print-preview-layer {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #fff;
    z-index: 10000;
    display: none;
    padding: 40px;
    overflow-y: auto;
}
.print-preview-layer.show { display: block; }

/* ===== 打印样式 ===== */
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area { position: absolute; top: 0; left: 0; width: 100%; padding: 1.5cm; }
    @page { size: landscape; margin: 1.5cm; }
}

/* ===== 生成器页面专属布局 ===== */
/* 覆盖全局 section-inner 的 max-width:1400px，让控制栏可以居中 */
.page-wrap { width: 100%; }
.page-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}
.section-inner {
    max-width: none !important;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 20px 24px;
    box-sizing: border-box;
}

/* 预览区域占位图标 */
.preview-icon {
    font-size: 48px;
    color: var(--border);
    margin-bottom: 16px;
    display: block;
}

/* 数独棋盘容器 */
#sudokuBoard {
    display: none;
    justify-content: center;
    align-items: center;
    flex: 1;
    overflow: auto;
}

/* 状态消息 */
#statusMsg {
    margin-top: 8px;
    font-size: 13px;
    text-align: center;
    color: var(--text-light);
}

/* 二维码区域 */
#qrcodeArea {
    margin-top: 20px;
    display: none;
    text-align: center;
}
.qr-prompt {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}
#qrcode {
    display: inline-block;
}

/* 提示按钮 */
.btn-hint {
    background: #fff3cd !important;
    color: #856404 !important;
    border-color: #ffeaa7 !important;
}
.btn-hint:hover {
    background: #ffeaa7 !important;
    color: #856404 !important;
    border-color: #fdcb6e !important;
}
