/* 字帖生成器专用样式 */

/* 布局结构 */
.tool-layout {
    display: flex;
    flex-direction: row-reverse; /* Config on Right, Preview on Left */
    gap: 20px;
    margin-top: 20px;
    height: calc(100vh - 160px);
    min-height: 600px;
}

.full-width-container {
    max-width: 1400px;
}

/* 右侧配置面板 */
.config-panel {
    width: 320px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow-y: auto;
    flex-shrink: 0;
    border: 1px solid #eee;
}

.panel-section {
    margin-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 16px;
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
    font-weight: 600;
}

/* 表单元素 */
.form-group {
    margin-bottom: 12px;
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.form-row label {
    margin-bottom: 0;
    font-size: 14px;
    color: #666;
    min-width: 70px;
}

.form-row input[type="range"] {
    flex: 1;
    margin: 0 10px;
}

.form-row span.value-display {
    min-width: 40px;
    text-align: right;
    font-size: 12px;
    color: #999;
}

.form-row select,
.form-row input[type="color"] {
    width: 100px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 30px;
}

.switch-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.switch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.action-buttons-grid {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.action-buttons-grid .btn {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #666;
}

.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-bottom: 0;
}

.inline-actions {
    display: flex;
    gap: 8px;
}

.full-width {
    width: 100%;
}

.action-buttons-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 右侧预览区域 */
.preview-area {
    flex-grow: 1;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 40px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* A4 纸张模拟 */
.paper {
    background: white;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    padding: 20mm; /* 内边距 */
    box-sizing: border-box;
    margin: 0 auto;
}

.paper.a4 {
    width: 210mm;
    min-height: 297mm; /* 允许内容撑开，但通常是固定页数 */
    /* height: 297mm; 如果要做分页，这里要限制高度 */
}

/* 格子容器 */
#grid-container {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}

/* 单个汉字单元格 */
.char-cell {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 5px; /* 行间距 */
    margin-right: 5px; /* 列间距 */
}

.pinyin-box {
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-family: 'Courier New', Courier, monospace; /* 拼音字体 */
    font-size: 14px;
    color: #666;
}

.grid-box {
    position: relative;
    width: 100%;
    height: 100%;
}

/* SVG 格子 */
.grid-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.stroke-svg,
.control-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    pointer-events: none;
}

/* 汉字层 */
.char-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    font-family: "KaiTi", "STKaiti", "楷体", serif; /* 楷体 */
    line-height: 1;
    user-select: none;
}

/* 描红样式 */
.trace-light {
    color: #e0e0e0 !important; /* 浅色用于描红 */
    /* 也可以用 text-stroke 实现空心字，但兼容性一般 */
}

/* 打印样式 */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        background: white;
    }

    .page-header,
    .page-footer,
    .config-panel,
    .tool-nav,
    .nav-divider {
        display: none !important;
    }

    .main-content {
        padding: 0;
        margin: 0;
    }

    .container {
        width: 100%;
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .tool-layout {
        margin: 0;
        height: auto;
        display: block;
    }

    .preview-area {
        background: white;
        padding: 0;
        border: none;
        display: block;
    }

    .paper {
        box-shadow: none;
        margin: 0;
        padding: 10mm; /* 打印时的内边距 */
        width: 100%;
        page-break-after: always;
    }
}

/* 模态框样式 */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    text-align: center;
    position: relative;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 10px;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

#practice-char {
    font-family: "KaiTi", "STKaiti", "楷体", serif;
    font-size: 48px;
    margin: 0;
    color: #333;
}

.practice-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    color: #666;
}

.practice-stats strong {
    color: #e74c3c;
    font-size: 18px;
}

#writer-container {
    width: 300px;
    height: 300px;
    margin: 0 auto 20px;
    border: 1px solid #ddd;
    background-image: url("data:image/svg+xml,%3Csvg width='300' height='300' xmlns='http://www.w3.org/2000/svg'%3E%3Cline x1='0' y1='0' x2='300' y2='300' stroke='%23eee' stroke-width='1'/%3E%3Cline x1='300' y1='0' x2='0' y2='300' stroke='%23eee' stroke-width='1'/%3E%3Cline x1='150' y1='0' x2='150' y2='300' stroke='%23eee' stroke-width='1'/%3E%3Cline x1='0' y1='150' x2='300' y2='150' stroke='%23eee' stroke-width='1'/%3E%3Crect x='0' y='0' width='300' height='300' fill='none' stroke='%23e74c3c' stroke-width='2'/%3E%3C/svg%3E");
    background-size: cover;
}

.modal-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-tips {
    font-size: 12px;
    color: #999;
}
