/* 核心修改：移除了顶部的 @import 规则 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
    --primary-color: #2c5aa0;
    --primary-dark: #1e3a5f;
    --secondary-color: #6c757d;
    --background-color: #f0f2f5;
    --surface-color: #ffffff;
    --text-color: #333;
    --border-color: #ced4da;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: var(--background-color);
    padding: 20px;
    padding-top: 70px;
    color: var(--text-color);
}

/* 关键修正：将line-height从body移到更具体的元素，避免全局污染 */
p, div, span, label, h1, h2, h3 {
    line-height: 1.6;
}

/* 语言切换器 */
.cert-language-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    background: var(--surface-color);
    padding: 8px;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.cert-lang-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 16px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.cert-lang-btn:hover {
    background: rgba(44, 90, 160, 0.1);
}

.cert-lang-btn.active {
    background: var(--primary-color);
    color: white;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.control-panel {
    flex: 0 0 400px;
    background-color: var(--surface-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    height: fit-content;
    max-height: 92vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* --- (*** 已修改 ***) --- */
/* 为了实现无缝缩放，这里修改了预览区域的样式 */
/* 使用 flex 布局，并让内容居中对齐 */
.preview-area {
    flex: 1;
    display: flex;
    justify-content: center; /* 水平居中 */
    align-items: center;     /* 垂直居中 */
    min-height: 500px;       /* 保证一个最小高度 */
    overflow: hidden;        /* 隐藏任何可能超出的部分，避免出现滚动条 */
}

/* --- (*** 新增 ***) --- */
/* 对预览容器内的实际证件（直接子元素）进行样式设置 */
#preview-container > * {
    transform-origin: center center; /* 设置缩放的原点为中心，学生证等小卡片会更好看 */
    transition: transform 0.2s ease-out; /* 添加一个平滑的过渡效果 */
}

/* 学生证特殊缩放优化 */
#preview-container > .cbmu-student-card {
    transform-origin: center center;
    max-width: 100%;
}


.placeholder-text {
    font-size: 1.5rem;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 400px;
    width: 100%;
}

.app-header h1 {
    margin-bottom: 20px;
    color: var(--text-color);
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.document-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
}

.doc-type-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
    min-width: 100px;
}

.doc-type-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.doc-type-btn:hover:not(.active) {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.form-section {
    display: block;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

/* 注意：我们将隐藏原生的文件上传按钮 */
input[type="file"] {
    display: none;
}

/* 拖拽上传区域样式 */
.drag-drop-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.drag-drop-area:hover {
    border-color: var(--primary-color);
    background-color: #e9f0f7;
}

.drag-drop-area.dragover {
    border-color: var(--primary-color);
    background-color: #e9f0f7;
    border-style: solid;
}

.drag-drop-area .drag-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.drag-drop-area .drag-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.drag-drop-area .drag-hint {
    font-size: 12px;
    color: #999;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-separator {
    height: 1px;
    background-color: #e9ecef;
    margin-top: 25px;
    margin-bottom: 25px;
}

.form-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    margin-bottom: 15px;
    margin-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    position: sticky;
    bottom: -25px;
    background-color: var(--surface-color);
    padding-top: 15px;
    padding-bottom: 15px;
    margin-left: -25px;
    padding-left: 25px;
    padding-right: 25px;
    margin-right: -25px;
    border-top: 1px solid #e9ecef;
}

button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success {
    background-color: #28a745;
    color: white;
}
.btn-success:hover {
    background-color: #218838;
    transform: translateY(-1px);
}

.btn-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.hidden {
    display: none !important;
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }
    body {
        background-color: white;
        padding: 0;
    }
    .container {
        display: block;
    }
    .control-panel {
        display: none;
    }
    .preview-area {
        width: 100%;
        /* --- (*** 新增 ***) --- */
        /* 打印时重置预览区的对齐和溢出属性 */
        justify-content: flex-start;
        align-items: flex-start;
        overflow: visible;
    }
    
    /* --- (*** 修改点 ***) --- */
    /* 新增此规则，确保预览容器在打印时占据100%宽度，为内部元素（如学生证）的居中提供容器 */
    #preview-container {
        width: 100%;
    }

    /* --- (*** 修改点 ***) --- */
    /* 将通配符选择器 `*` 修改为 `.certificate`，使其只对证书生效，避免影响学生证等其他元素 */
    #preview-container > .certificate {
        width: 100% !important;
        height: 100vh !important;
        box-shadow: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
    }
}

/* --- 新增：响应式布局 (针对小屏幕设备) --- */
@media (max-width: 992px) { /* 在更宽的平板尺寸就开始响应 */
    body {
        padding: 10px; /* 减小页面内边距 */
    }

    .container {
        flex-direction: column; /* 将主容器变为垂直布局 */
        gap: 20px;
    }

    .control-panel {
        flex: 1 0 auto; /* 控制面板宽度自适应 */
        width: 100%;
        max-height: none; /* 移除最大高度限制 */
        overflow-y: visible;
    }

    .preview-area {
        width: 100%;
        min-height: 500px; /* 保证预览区有足够高度 */
        overflow-x: hidden; /* 防止缩放后依然有横向滚动条 */
    }
}


/* --- (*** 新增 ***) 优化 Safari 及其他浏览器下的下拉框样式 --- */
select {
    -webkit-appearance: none; /* 移除 Safari/Chrome 的原生样式 */
    -moz-appearance: none;    /* 移除 Firefox 的原生样式 */
    appearance: none;         /* 移除标准的原生样式 */
    /* 使用内联 SVG 自定义箭头图标，增强兼容性并减少外部依赖 */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236c757d%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-13%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2013l128%20127.9c3.6%203.6%207.8%205.4%2013%205.4s9.4-1.8%2013-5.4L287%2095.2c3.6-3.7%205.4-8%205.4-13%200-5-1.8-9.2-5.4-12.8z%22/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-right: 30px; /* 为箭头图标留出空间，防止文字遮挡 */
}

/* --- (*** 新增 ***) 优化文件选择按钮样式 --- */
.custom-file-upload {
    position: relative;
    display: flex;
    align-items: center;
}

/* 自定义的文件上传按钮样式 (通过 label 实现) */
.btn-file-upload {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 6px;
    background-color: var(--secondary-color);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s;
    white-space: nowrap; /* 防止文字换行 */
}

.btn-file-upload:hover {
    background-color: #5a6268; /* 鼠标悬浮时加深颜色 */
}

/* 用于显示所选文件名的文本样式 (*** 使用 class 选择器 ***) */
.file-chosen-text {
    margin-left: 10px;
    font-size: 14px;
    color: #6c757d;
    white-space: nowrap; /* 防止文件名换行 */
    overflow: hidden;
    text-overflow: ellipsis; /* 文件名过长时显示省略号 */
    max-width: 180px; /* 限制最大宽度，避免撑开布局 */
}