/* 导入本地字体 */
@import url('./fonts/fonts.css');

/* Tailwind CSS 自定义样式 */
.content-auto {
    content-visibility: auto;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.transition-height {
    transition: max-height 0.3s ease-in-out;
}

.pinyin-handwriting {
    font-family: '推荐字体', 'Comic Neue', 'Schoolbell', 'Kalam', 'Microsoft YaHei', 'SimSun', sans-serif;
    font-weight: 400;
    letter-spacing: 1px;
    font-variant: normal;
}

/* 单选框样式 */
.radio-check[data-checked="true"] .w-2 {
    display: block;
}

.radio-check[data-checked="false"] .w-2 {
    display: none;
}

/* 田字格样式 */
.grid-container {
    position: relative;
    display: inline-block;
    margin: 5px;
}

.character-grid {
    border: 1px solid #333;
    position: relative;
    background: white;
}

.grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.character-group {
    display: inline-block;
    margin: 0;
    padding: 0;
}

.words-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    align-items: flex-start;
    justify-content: flex-start;
}

.grid-line {
    position: absolute;
    background-color: #ccc;
}

.grid-line.horizontal {
    width: 100%;
    height: 1px;
    top: 50%;
}

.grid-line.vertical {
    height: 100%;
    width: 1px;
    left: 50%;
}

.grid-line.diagonal1 {
    width: 141.42%;
    height: 1px;
    top: 50%;
    left: -20.71%;
    transform: rotate(45deg);
}

.grid-line.diagonal2 {
    width: 141.42%;
    height: 1px;
    top: 50%;
    left: -20.71%;
    transform: rotate(-45deg);
}

/* 拼音样式 */
.pinyin-text {
    text-align: center;
    margin-bottom: 5px;
    color: #666;
}

/* 拼音可点击/可编辑样式 */
.tone-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 10px;
    padding: 0 2px;
}

.tone-clickable:hover {
    background-color: rgba(22, 93, 255, 0.1);
    border-radius: 3px;
}

.tone-clickable[contenteditable="true"] {
    cursor: text;
    outline: 2px solid #165DFF;
    outline-offset: 2px;
    border-radius: 4px;
    background-color: rgba(22, 93, 255, 0.05);
}

/* 字符样式 */
.character-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    pointer-events: none;
    line-height: 1;
}

/* 打印样式优化 */
@media print {
    /* 隐藏浏览器默认的页眉页脚 */
    @page {
        margin: 0;
        size: auto;
    }

    /* 强制打印背景颜色和图片 */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* 隐藏页面上的非打印元素 */
    body > header,
    body > footer,
    #helpModal,
    /* 隐藏左侧控制面板 */
    main > div > div:first-child,
    /* 隐藏预览区域顶部的标题和按钮栏 (注意：不要隐藏整个卡片容器) */
    main > div > div:nth-child(2) > div:first-child > div:first-child,
    /* 隐藏导出按钮等 */
    #exportPdfBtn,
    #themeToggle, #helpBtn,
    /* 隐藏滚动条样式 */
    ::-webkit-scrollbar {
        display: none;
    } {
        display: none !important;
    }

    /* 确保 body 和 main 占满全屏 */
    body, main, html {
        width: 100%;
        margin: 0;
        padding: 0;
        background: white;
        overflow: visible !important;
    }
    
    main {
        max-width: none !important;
    }
    
    /* 调整右侧内容区域 */
    main > div > div:nth-child(2) {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* 调整卡片容器 (bg-white) */
    main > div > div:nth-child(2) > div:first-child {
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    /* 重置预览容器外层 div 的样式 (去除背景、边框、滚动条) */
    main > div > div:nth-child(2) > div:first-child > div:nth-child(2) {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: 0 !important;
        overflow: visible !important;
        display: block !important; /* 取消 flex */
        box-shadow: none !important;
    }
    
    #previewContainer {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 页面分页控制 */
    .preview-page {
        margin: 0 auto !important;
        box-shadow: none !important;
        /* 使用标准属性 break-after */
        break-after: page;
        page-break-after: always;
        /* 打印时保持A4尺寸 */
        width: 210mm !important;
        /* 移除固定高度，改为自动，防止因微小计算误差导致的溢出分页 */
        height: auto !important;
        /* 限制最大高度，防止内容撑出产生额外页面 */
        max-height: 297mm !important;
        padding: 15px 25px !important;
        border: none !important;
        /* 隐藏溢出内容 */
        overflow: hidden !important;
    }
    
    .preview-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
    
    /* 隐藏原有的打印区域 */
    #printArea {
        display: none !important;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .grid-container {
        margin: 3px;
    }
    
    .character-text {
        font-size: 20px;
    }
    
    .pinyin-text {
        font-size: 12px;
    }
}

/* 模态框样式 */
.modal-overlay {
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* 按钮样式 */
.btn-primary {
    background-color: #165DFF;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: #0E4FD1;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 输入框样式 */
.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #165DFF;
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    padding: 20px;
    transition: all 0.2s;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* 预览页面分页样式 */
.preview-page {
    width: 210mm;
    height: 297mm;
    padding: 15px 25px;
    margin: 20px auto;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

@media print {
    .preview-page {
        margin: 0;
        box-shadow: none;
        page-break-after: always;
    }
}