/* ============================================================
   一维条码生成器 · 页面专属样式
   迪妙网络空间安全学院 · 反钓工具箱
   注意：仅定义工具页专属区块，导航/页脚桌面端样式由 ../../style.css 决定
   ============================================================ */

/* ===== 盒模型加固：不依赖外部 reset，任何环境一致 ===== */
.tool-note, .tool-panel, .guide-card, .batch-card, .batch-svg, .preview-box,
.tool-btn, .mini-btn, .form-control, .form-color, .form-group, .panel-actions {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
}

/* ===== 提示条（与官网 warning-banner 同风格） ===== */
.tool-note {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: linear-gradient(135deg, #e8f1ff 0%, #f0f5ff 100%);
    border: 1.5px solid rgba(26, 110, 255, 0.15);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.tool-note-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tool-note-icon svg { width: 22px; height: 22px; color: white; }
.tool-note h4 { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.tool-note p { font-size: 13px; color: var(--text-secondary); line-height: 1.7; }

/* ===== 主布局 ===== */
.tool-layout {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
.tool-layout > * { min-width: 0; }
.tool-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.panel-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-title::before {
    content: '';
    width: 4px; height: 16px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}
.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: white;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 110, 255, 0.12);
}
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a5a7a' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}
textarea.form-control { resize: vertical; line-height: 1.8; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 6px; line-height: 1.6; }
.val-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 10px;
    border-radius: 100px;
}

/* 滑块 */
input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--primary-gradient);
    box-shadow: 0 2px 8px rgba(26, 110, 255, 0.4);
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(26, 110, 255, 0.4);
    cursor: pointer;
}

/* 颜色选择 */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-color {
    width: 100%;
    height: 42px;
    padding: 4px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    transition: var(--transition);
}
.form-color:focus { outline: none; border-color: var(--primary); }

/* 复选框 */
.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}
.form-check label { font-size: 13px; color: var(--text-secondary); cursor: pointer; }

/* ===== 按钮 ===== */
.panel-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    flex: 1;
    min-width: 120px;
}
.tool-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(26, 110, 255, 0.3);
}
.tool-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(26, 110, 255, 0.4); }
.tool-btn.secondary {
    background: white;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.tool-btn.secondary:hover { background: var(--primary-light); }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ===== 预览区 ===== */
.preview-panel { min-height: 420px; }
.preview-box {
    background:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%),
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%),
        #ffffff;
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    padding: 20px;
}
.preview-box.is-empty { background: var(--bg-warm); }
.preview-box > * { flex-shrink: 0; }
.preview-box svg { max-width: none; display: block; }
.preview-placeholder { font-size: 13px; color: var(--text-light); }
.status-line { font-size: 13px; margin-top: 14px; line-height: 1.7; word-break: break-all; }
.status-line.ok { color: var(--success); }
.status-line.err { color: var(--danger); }

/* ===== 批量生成 ===== */
.batch-layout {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
.batch-layout > * { min-width: 0; }
.batch-input { font-family: monospace; font-size: 13px; }
.batch-results { min-height: 200px; }
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.batch-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.batch-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: monospace;
    word-break: break-all;
}
.batch-svg {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    padding: 8px;
}
.batch-actions { display: flex; gap: 8px; }
.mini-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: var(--primary);
    background: var(--primary-light);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.mini-btn:hover { background: var(--primary); color: white; }

/* ===== 说明卡片 ===== */
.guide-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.guide-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    transition: var(--transition);
}
.guide-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-4px); border-color: rgba(26, 110, 255, 0.2); }
.guide-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.guide-icon svg { width: 24px; height: 24px; }
.guide-card h4 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.guide-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.8; }

/* ============================================================
   响应式适配
   - 导航/页脚规则照抄官网首页内联 <style>，不重写桌面样式
   - 内容区断点节奏与官网 drill 页一致
   ============================================================ */
@media (max-width: 1024px) {
    /* minmax(0,1fr)：防止轨道被内容 min-content 撑破溢出视口 */
    .tool-layout, .batch-layout { grid-template-columns: minmax(0, 1fr); }
    .tool-layout > *, .batch-layout > * { min-width: 0; }
    .guide-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    /* —— 官网同款移动导航（照抄首页内联规则） —— */
    .nav-links {
        display: none;
        position: absolute;
        top: 72px;
        left: 0; right: 0;
        background: white;
        flex-direction: column;
        padding: 16px 24px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        gap: 4px;
        border-bottom: 1px solid var(--border);
        z-index: 999;
    }
    .nav-links.active { display: flex; }
    .mobile-toggle { display: flex; }

    /* —— 内容区节奏收紧（与 drill 页 768 断点一致） —— */
    .section { padding: 48px 0; }
    .section-header { margin-bottom: 36px; }
    .page-header { padding: 110px 0 36px; }
    .breadcrumb { flex-wrap: wrap; row-gap: 4px; line-height: 1.5; }
    .tool-note { flex-direction: column; gap: 12px; padding: 16px 20px; }
    .tool-layout, .batch-layout { gap: 16px; }
    .tool-panel { padding: 20px; }

    /* —— iOS 聚焦不缩放（输入字号 ≥16px） —— */
    .form-control { font-size: 16px; }
    textarea.form-control { font-size: 15px; }
    select.form-control { padding-right: 36px; }

    /* —— 预览区：修复"居中+溢出裁切左侧"问题 ——
       改用 margin:auto 居中：内容小于容器时居中，大于容器时可完整左右滚动 */
    .preview-panel { min-height: 0; }
    .preview-box {
        min-height: 200px;
        padding: 12px;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }
    .preview-box > * { margin: auto; flex-shrink: 0; }
    .batch-svg { justify-content: flex-start; }
    .batch-svg > * { margin: auto; flex-shrink: 0; -webkit-overflow-scrolling: touch; }

    /* —— 栅格降列 —— */
    .guide-grid { grid-template-columns: 1fr; }
    .batch-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

    /* —— 按钮与页脚 —— */
    .panel-actions { flex-direction: column; }
    .tool-btn { width: 100%; }
    .footer-grid { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 480px) {
    .tool-panel { padding: 16px; }
    .panel-title { font-size: 15px; margin-bottom: 16px; padding-bottom: 12px; }
    .guide-card { padding: 20px; }
    .batch-grid { grid-template-columns: 1fr; }
    .form-row { gap: 10px; }
    .tool-note { padding: 14px 16px; }
    .page-header { padding: 100px 0 32px; }
}
