/* ==========================================================================
   1. TEMPLATE DRAWER (页面上的模版选择横廊)
   ========================================================================== */
.template-drawer {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin: 20px auto;
    max-width: 900px;
    text-align: center;
    border: 1px solid #ddd;
    position: relative;
}

.template-drawer h3 {
    margin-top: 0;
    color: #333;
}

/* 横向滑动列表容器 */
.template-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 20px;
    padding: 15px 5px 25px 5px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* 滚动条美化 */
.template-list::-webkit-scrollbar {
    height: 6px;
}
.template-list::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 10px;
}

/* 模版卡片 */
.tpl-card {
    flex: 0 0 160px; 
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.tpl-card:hover {
    transform: translateY(-8px);
}

.tpl-thumb {
    width: 100%;
    height: 220px; 
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: border-color 0.2s;
}

/* 选中状态 */
.tpl-card.active .tpl-thumb {
    border: 3px solid #27ae60;
    box-shadow: 0 0 15px rgba(39, 174, 96, 0.2);
}

.tpl-card span {
    font-weight: 500;
    color: #4a5568;
    font-size: 0.95rem;
}

/* ==========================================================================
   2. PREVIEW MODAL (弹窗基础 UI)
   ========================================================================== */
.modal {
    display: none; /* 初始隐藏 */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    overflow: auto;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #2d3748;
    margin: 2% auto;
    padding: 25px;
    width: fit-content;
    max-width: 95%;
    border-radius: 12px;
}

/* A4 纸张画布基础定义 */
#print-canvas {
    background: white;
    width: 210mm; 
    /* 不要设置 min-height: 297mm; */
    height: auto; 
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    color: #333;
    overflow: hidden; /* 防止溢出边缘触发新页 */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    margin-bottom: 15px;
}

.modal-header button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.modal-footer {
    text-align: center;
    padding-top: 20px;
}

.download-final-btn {
    background: #27ae60;
    color: white;
    padding: 14px 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: background 0.2s;
}

.download-final-btn:hover {
    background: #2ecc71;
}

/* ==========================================================================
   3. UTILITIES (功能性样式)
   ========================================================================== */
.no-print {
    display: block;
}

/* 打印或导出时的隐藏逻辑 */
.pdf-mode .no-print {
    display: none !important;
}

/* 选择廊右侧的淡出渐变遮罩 */
.template-drawer::after {
    content: '';
    position: absolute;
    right: 0;
    top: 60px;
    bottom: 20px;
    width: 40px;
    background: linear-gradient(to right, transparent, #f8f9fa);
    pointer-events: none;
}