/**
 * 通用组件
 * 合并工具页和游戏页的通用样式
 */

/* ===== 工具索引页样式 ===== */
.tool-category {
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
}

.tool-category h2 {
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.tool-item {
   margin-bottom: 1.5rem;
    padding: 1rem 3rem 1rem 1rem;
    background: var(--bg-light);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    position: relative;
}

.tool-name {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.tool-url {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0.5rem 0;
    font-family: monospace;
}

.tool-desc {
    color: var(--text-dark);
    margin: 0.5rem 0;
}

.tool-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.feature-tag {
    display: inline-block;
    background: rgba(192, 40, 30, 0.08);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* ===== 卡片组件 ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 12px var(--shadow-sm);
}

.card--hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-md);
    transition: all 0.3s ease;
}

/* ===== 按钮组件 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 10px 20px var(--shadow-md);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--accent-tint);
    border-color: var(--accent-tint-strong);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 表单组件 ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--accent-tint);
    outline: none;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ===== 上传区域组件 ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--accent-tint);
}

.upload-area.dragover {
    border-color: var(--primary-dark);
    background: var(--accent-tint-strong);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-text {
    color: var(--text-dark);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== 信息提示框 ===== */
.info-box {
    background: var(--accent-tint);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-sm);
}

.info-box--success {
    background: rgba(91, 122, 58, 0.1);
    border-left-color: var(--success);
}

.info-box--error {
    background: var(--accent-tint);
    border-left-color: var(--error);
}

/* ===== 标签组件 ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--accent-tint);
    color: var(--primary);
}

/* ===== 标签页组件 ===== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== 进度条组件 ===== */
.progress-container {
    margin-top: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* ===== 文件列表组件 ===== */
.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.file-info {
    flex: 1;
    margin-right: 1rem;
}

.file-name {
    font-weight: 600;
    color: var(--text-dark);
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===== 页面标题组件 ===== */
.page-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    font-size: 1.05rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* ===== 分隔线 ===== */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: 2rem 0;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ===== 工具特定组件 ===== */
.tool-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.textarea-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.textarea-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.textarea-code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    min-height: 400px;
}

.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.message {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: none;
}

.message.active {
    display: block;
}

.message.success {
    background: rgba(91, 122, 58, 0.1);
    color: var(--success);
    border-left: 4px solid var(--success);
}

.message.error {
    background: var(--accent-tint);
    color: var(--error);
    border-left: 4px solid var(--error);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.preview-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.preview-box {
    background: #fff;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-box canvas,
.preview-box img {
    max-width: 100%;
    height: auto;
}

.preview-empty {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* 密码生成器专用样式 */
.password-display {
    background: var(--bg-light);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 80px;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

.password-display:hover {
    border-color: var(--primary);
}

.password-text {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    word-break: break-all;
    user-select: all;
    cursor: text;
    color: var(--text-dark);
    min-height: 1.6em;
    display: flex;
    align-items: center;
}

.password-text.empty {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0;
    user-select: none;
    cursor: default;
}

.btn-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
    color: var(--text-light);
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--accent-tint);
}

.btn-icon.copied {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.strength-bar-wrap {
    margin-bottom: 1.5rem;
}

.strength-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.strength-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.strength-value {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--bg-light);
}

.strength-bar {
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.strength-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s, background 0.4s;
    width: 0%;
}

.length-section {
    margin-bottom: 1.5rem;
}

.length-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.length-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.length-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 3ch;
    text-align: center;
}

.options-label {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    display: block;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.option-item:hover {
    border-color: var(--primary);
    background: var(--accent-tint);
}

.option-item.active {
    border-color: var(--primary);
    background: var(--accent-tint-strong);
}

.option-item input[type="checkbox"] {
    display: none;
}

.option-check {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    transition: all 0.2s;
}

.option-item.active .option-check {
    background: var(--primary);
    border-color: var(--primary);
}

.exclude-section {
    margin-bottom: 1.5rem;
}

.exclude-input {
    width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.count-section {
    margin-bottom: 1.5rem;
}

.count-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.count-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.count-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.count-display {
    font-size: 1.2rem;
    font-weight: 700;
    min-width: 2ch;
    text-align: center;
}

.count-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.actions-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.batch-results {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
}

.batch-item {
    padding: 0.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-item:last-child {
    border-bottom: none;
}

/* ===== 系列卡（首页专栏 / 文章列表共用） =====
   推荐标记：SERIES 里标了 featured 的专栏、最新一篇所属专栏、以及还没发文的专栏。
   只用背景色区分，不改字号、字重和文字颜色。
   注意：pages/home.css 与 pages/articles.css 在 components.css 之后加载，
   它们的 .series-card 也是单类选择器，这里必须用双类提高特异性才压得住。 */

.series-card.series-card--featured {
    background: var(--accent-tint-strong);
}

/* ===== 响应式组件 ===== */
@media (max-width: 768px) {
    .btn {
        width: 100%;
    }
    
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .file-info {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .file-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .tool-container {
        grid-template-columns: 1fr;
    }
}

/* ===== 通用：文件拖放区（2026-11-02 新增，证件类工具共用） ===== */
.drop-zone {
    display: block;
    padding: 2.25rem 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.is-dragover {
    border-color: var(--primary);
    background: var(--accent-tint);
}

.drop-zone-title {
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* 画布预览容器：白底 + 细边，打印类工具通用 */
.canvas-frame {
    display: block;
    max-width: 100%;
    height: auto;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ===== 通用：页尾相关内容（2026-11-02 新增，由 scripts/inject-related.js 注入） ===== */
.related-block {
    max-width: var(--container-max-width);
    margin: 3rem auto 0;
    padding: 1.75rem var(--container-padding) 0;
    border-top: 1px solid var(--border-light);
}

.related-title {
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 0.9rem;
}

.related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.5rem;
}

.related-item {
    font-size: 0.92rem;
    color: var(--primary-dark);
    text-decoration: none;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.15rem;
}

.related-item:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.related-item--guide {
    color: var(--text-light);
}

/* ===== og-lead：微信转发缩略图用隐藏首图（保持自然尺寸供抓取） ===== */
.og-lead {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 300px;
    height: auto;
    opacity: 0.01;
    pointer-events: none;
}

/* ===== 工具卡分享按钮 ===== */
.tool-share-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: var(--bg-light);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.tool-share-btn:hover {
    color: var(--primary);
    background: var(--accent-tint);
    transform: scale(1.08);
}

/* ===== 分享 toast ===== */
.share-toast {
    position: fixed;
    left: 50%;
    bottom: 8%;
    transform: translateX(-50%) translateY(8px);
    z-index: 10000;
    max-width: min(86vw, 26rem);
    padding: 0.7rem 1.25rem;
    border-radius: 999px;
    background: rgba(44, 44, 42, 0.92);
    color: #fff;
    font-size: 0.875rem;
    line-height: 1.5;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== 分享面板（底部弹层） ===== */
.share-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(44, 44, 42, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* 关键：作者 display:flex 会压过 UA 的 [hidden]{display:none}，必须显式补回，否则面板关不掉 */
.share-overlay[hidden] {
    display: none;
}

.share-sheet {
    width: 100%;
    max-width: 24rem;
    max-height: 86vh;
    overflow-y: auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 32px var(--shadow-lg);
    padding: 0.9rem 0.9rem calc(0.9rem + env(safe-area-inset-bottom));
    animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes sheet-up {
    from { transform: translateY(30%); opacity: 0.4; }
    to   { transform: none; opacity: 1; }
}

.share-card-area {
    margin-bottom: 0.7rem;
}

.share-card-img {
    display: block;
    width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.share-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.share-btn {
    padding: 0.7rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-dark);
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.share-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.share-btn:active {
    transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
    .share-sheet { animation: none; }
    .share-toast, .share-btn { transition: none; }
}
