/* 田字格生成器样式 - 简化版 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "PingFang SC", "Hiragino Sans GB", "STHeiti", "华文黑体", "Noto Sans CJK SC", "Source Han Sans CN", "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    /* 屏幕显示时不设置页边距，让内容占满空间 */
    padding: 0;
}

header {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1rem;
    color: #666;
}

.controls {
    background: white;
    padding: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    border: 1px solid #ddd;
    margin-bottom: 0.6rem;  /* 10px / 16px ≈ 0.6rem */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15.6rem, 1fr));  /* 250px / 16px ≈ 15.6rem */
    gap: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    align-items: end;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;  /* 8px / 16px = 0.5rem */
}

.input-group label {
    font-weight: bold;
    color: #333;
    font-size: 0.9rem;  /* 14px / 16px ≈ 0.9rem */
    white-space: nowrap;
}

.input-group input {
    padding: 0.6rem;  /* 10px / 16px ≈ 0.6rem */
    border: 1px solid #ccc;
    border-radius: 0.5rem;  /* 8px / 16px = 0.5rem */
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

/* 田字格数量输入框 - 较窄 */
.input-group:first-child input {
    width: 4rem;  /* 64px / 16px = 4rem */
}

/* 标题输入框 - 较宽 */
.input-group:nth-child(2) input {
    width: 10rem;  /* 160px / 16px = 10rem */
}

/* 字体选择下拉框 */
.input-group:nth-child(3) select {
    width: 8rem;  /* 128px / 16px = 8rem */
    height: 2.5rem;  /* 40px / 16px = 2.5rem */
    padding: 0.6rem;  /* 10px / 16px ≈ 0.6rem */
    border: 1px solid #ccc;
    border-radius: 0.5rem;  /* 8px / 16px = 0.5rem */
    font-size: 1rem;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimSun", sans-serif;
    transition: border-color 0.2s ease;
}

/* 字体预览 */
.font-preview {
    font-size: 1.5rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 0.3rem;
    background: #f9f9f9;
    min-width: 2rem;
    text-align: center;
    display: inline-block;
    font-family: "Kaiti SC", serif;
}

/* 汉字输入框 - 更宽，到达右边界，单独占一行 */
.input-group:nth-child(4) {
    grid-column: 1 / -1;  /* 跨越所有列，单独占一行 */
}

.input-group:nth-child(4) input {
    width: 100%;  /* 占满整个input-group的宽度 */
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimSun", sans-serif;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.125rem rgba(59, 130, 246, 0.2);
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;  /* 12px/16px=0.75rem, 24px/16px=1.5rem */
    font-size: 1rem;  /* 16px / 16px = 1rem */
    font-weight: bold;
    cursor: pointer;
    grid-column: 1 / -1;
    justify-self: center;
    min-width: 12.5rem;  /* 200px / 16px = 12.5rem */
    border-radius: 0.5rem;  /* 8px / 16px = 0.5rem */
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background: #2563eb;
}

.info-panel {
    background: white;
    padding: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    border: 1px solid #ddd;
    margin-bottom: 0.6rem;  /* 10px / 16px ≈ 0.6rem */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));  /* 200px / 16px = 12.5rem */
    gap: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    background: #f8f9fa;
    border: 1px solid #eee;
}

.info-item .label {
    font-weight: 600;
    color: #555;
}

.info-item .value {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1rem;
}

/* 字体测试面板 */
.font-test-panel {
    background: white;
    padding: 0.95rem;
    border: 1px solid #ddd;
    margin-bottom: 0.6rem;
}

.font-test-panel h4 {
    margin-bottom: 0.6rem;
    color: #333;
    font-size: 1rem;
}

.system-info {
    margin-bottom: 0.8rem;
    padding: 0.5rem;
    background: #f0f8ff;
    border: 1px solid #b3d9ff;
    border-radius: 0.3rem;
    font-size: 0.85rem;
    color: #0066cc;
}

.font-test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.6rem;
}

.font-test-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.6rem;
    border: 1px solid #eee;
    border-radius: 0.3rem;
    background: #fafafa;
}

.font-name {
    font-size: 0.8rem;
    color: #666;
    font-weight: bold;
}

.font-sample {
    font-size: 1.5rem;
    color: #333;
    text-align: center;
    padding: 0.3rem;
    background: white;
    border-radius: 0.2rem;
}

.preview-container {
    background: white;
    border: 1px solid #ddd;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.95rem 1.25rem;  /* 15px/16px≈0.95rem, 20px/16px=1.25rem */
    background: #f8f9fa;
}

.preview-header h3 {
    color: #333;
    font-size: 1.3rem;
}

.preview-controls {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;  /* 10px/16px≈0.6rem, 20px/16px=1.25rem */
    border-radius: 0.4rem;  /* 6px / 16px ≈ 0.4rem */
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover:not(:disabled) {
    background: #555;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.svg-container {
    padding: 0.6rem;  /* 10px / 16px ≈ 0.6rem */
    min-height: 15.6rem;  /* 250px / 16px ≈ 15.6rem */
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    /* 确保跨浏览器一致性 */
    overflow: hidden;
    position: relative;
}

.placeholder {
    color: #999;
    font-size: 1rem;  /* 16px / 16px = 1rem */
    text-align: center;
    padding: 2.5rem;  /* 40px / 16px = 2.5rem */
    border: 1px dashed #ccc;
    background: white;
}

/* SVG样式 - 确保跨浏览器一致性和A4尺寸 */
.grid-svg {
    max-width: 100%;
    width: 100%;
    height: auto;
    background: white;
    /* 确保SVG在所有浏览器中正确显示 */
    display: block;
    vertical-align: top;
    /* 确保A4尺寸正确 */
    box-sizing: border-box;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    }
    
    .controls {
        grid-template-columns: 1fr;
        gap: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    }
    
    .info-panel {
        grid-template-columns: 1fr;
        gap: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
    }
    
    .preview-header {
        flex-direction: column;
        gap: 0.95rem;  /* 15px / 16px ≈ 0.95rem */
        align-items: stretch;
    }
    
    .preview-controls {
        justify-content: center;
    }
    
    header h1 {
        font-size: 2rem;
    }
}

/* 打印样式 */
@media print {
    /* 隐藏除了svgContainer之外的所有内容 */
    header,
    .controls,
    .info-panel,
    .preview-header,
    .preview-controls,
    .placeholder {
        display: none !important;
    }
    
    /* 只显示SVG容器 */
    .svg-container {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        min-height: auto !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        position: static !important;
        overflow: visible !important;
        width: 210mm !important;
        height: 297mm !important;
        max-width: 210mm !important;
        max-height: 297mm !important;
    }
    
    /* 确保SVG严格按照A4尺寸 */
    .grid-svg {
        width: 210mm !important;
        height: 297mm !important;
        max-width: 210mm !important;
        max-height: 297mm !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        page-break-inside: avoid !important;
    }
}


