/* ============ 国旗头像生成器 · 工具特有样式 ============ */
/* 公共布局/卡片/按钮/空状态等样式统一来自 common.css */

/* .setting-label-row 已移至 common.css 通用样式 */

/* 控件行：左对齐排布多个小按钮 */
.btn-row {
    display: flex;
    gap: 8px;
}

/* 头像形状：用上传图片直接显示方形/圆形预览 */
.shape-seg {
    display: flex;
    gap: 14px;
}
.shape-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}
.shape-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e5e7eb;
    display: block;
    transition: border-color .15s, box-shadow .15s;
}
.shape-thumb.circle {
    border-radius: 50%;
}
.shape-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.shape-opt.active .shape-thumb {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, .25);
}
.shape-cap {
    font-size: 12px;
    color: #6b7280;
}
.shape-opt.active .shape-cap {
    color: #8b5cf6;
    font-weight: 600;
}

/* 边框颜色选择器 */
.color-input {
    width: 44px;
    height: 28px;
    padding: 2px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 4px; }

#guoqi-container {
    margin-bottom: 15px;
}

/* ---------- 上传区 ---------- */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 16px;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover,
.upload-area.active {
    border-color: #8b5cf6;
    background: #f5f3ff;
}

.upload-icon {
    font-size: 42px;
}

.upload-text {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
}

.upload-hint {
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
}

/* ---------- 已选文件信息 ---------- */
.file-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.file-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    flex-shrink: 0;
}

.file-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-name {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-sub {
    font-size: 12px;
    color: #9ca3af;
}

/* ---------- 形状分段选择 ---------- */
.shape-seg {
    display: flex;
    gap: 8px;
}

.shape-seg .mode-btn {
    flex: 1;
}

/* ---------- 滑块 ---------- */
.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #8b5cf6;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

/* ---------- 预览区 ---------- */
.preview-box {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 480px;
    padding: 20px;
    border-radius: 10px;
}

.preview-box.checker {
    background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 20px 20px;
}

.canvas-wrap {
    position: relative;
}

.canvas-wrap canvas {
    display: block;
    background: transparent;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    cursor: grab;
    user-select: none;
    touch-action: none;
    max-width: 100%;
}

.canvas-wrap canvas:active {
    cursor: grabbing;
}

.canvas-wrap.circle canvas {
    border-radius: 50%;
}

.preview-tip {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    margin: 12px 0 0;
}

/* ---------- 模板网格 ---------- */
.tpl-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.tpl-head-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.tpl-head-tip {
    font-size: 12px;
    color: #9ca3af;
}

.tpl-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.tpl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tpl-item:hover {
    background: #f5f3ff;
}

.tpl-item.active {
    border-color: #8b5cf6;
    background: #f5f3ff;
}

.tpl-canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    background: #f3f4f6;
    border-radius: 6px;
}

.tpl-canvas.circle {
    border-radius: 50%;
}

.tpl-name {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
    .tpl-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .tpl-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .preview-box {
        min-height: 360px;
    }
}
