/* 
 * 主要样式表文件
 * 为支票生成器应用提供响应式设计和美观界面
 * 包含表单样式、支票预览样式和整体布局
 * 更新：将表单和预览改为上下排列，避免溢出问题
 * 更新：优化表单字段布局，使其更接近支票上的布局
 * 更新：添加灯箱效果，使支票预览以弹窗形式显示
 * 更新：添加签名字段和自适应字体大小
 * 更新：添加背景图像和视觉增强效果
 * 更新：添加详细信息模板，包括支票下方的明细部分
 * 更新：添加明细项目表单部分
 */

/* 导入签名字体 */
@font-face {
    font-family: 'Signature';
    src: url('https://fonts.googleapis.com/css2?family=Mr+Dafoe&display=swap');
    font-display: swap;
}

:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --success-color: #2ecc71;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-signature: 'Signature', 'Mr Dafoe', cursive;
    --check-border-color: #1f3d7a;
    --table-header-bg: #f2f2f2;
    --table-border: #ddd;
}

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

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f9f9f9;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

section {
    width: 100%;
}

/* 表单样式 */
.check-form {
    background-color: var(--light-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.check-form h2 {
    margin-bottom: 20px;
    color: var(--secondary-color);
}

/* 表单网格布局 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

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

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    grid-column: span 2;
}

button {
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

#downloadCsvBtn {
    background-color: var(--success-color);
}

#downloadCsvBtn:hover {
    background-color: #27ae60;
}

/* 灯箱样式 */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 支票预览样式 */
.check-preview {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.lightbox-overlay.active .check-preview {
    transform: scale(1);
}

.check-preview h2 {
    margin-bottom: 20px;
    color: var(--secondary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-lightbox {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dark-color);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.close-lightbox:hover {
    color: var(--accent-color);
    background: none;
}

.check-container {
    border: 1px solid #ddd;
    padding: 20px;
    background-color: #fff;
    min-height: 200px;
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    overflow-x: auto;
}

/* 初始预览信息样式 */
.no-preview {
    text-align: center;
    color: #777;
    padding: 40px 0;
    font-style: italic;
}

/* 签名输入样式 */
.signature-input {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.signature-input canvas {
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-bottom: 10px;
    background-color: white;
    width: 100%;
    max-width: 300px;
    height: 100px;
}

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

.signature-input button.clear-signature {
    background-color: var(--accent-color);
}

.signature-input button.clear-signature:hover {
    background-color: #c0392b;
}

/* 美国支票样式 - 6x2.75英寸 */
.us-check {
    width: 100%;
    min-height: 275px;
    border: 1px solid var(--check-border-color);
    position: relative;
    background-color: #f8f8f8;
    margin: 0 auto;
    padding: 20px;
    font-family: 'MICR', 'Courier New', monospace;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    border-radius: 5px 5px 0 0;
    overflow: hidden;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)),
        url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIj48cmVjdCB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgZmlsbD0ibm9uZSIvPjxwYXRoIGQ9Ik0wIDBoMTAwdjEwMEgweiIgZmlsbD0ibm9uZSIvPjxwYXRoIGQ9Ik0xMCAxMGg4MHY4MEgxMHoiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RkZCIgc3Ryb2tlLXdpZHRoPSIxIi8+PC9zdmc+');
}

/* 添加安全图案背景 */
.us-check::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PGNpcmNsZSBjeD0iMTAiIGN5PSIxMCIgcj0iMiIgZmlsbD0icmdiYSgwLCAwLCAxMjgsIDAuMDUpIi8+PC9zdmc+');
    z-index: 0;
    opacity: 0.5;
}

/* 添加城市轮廓背景 */
.us-check::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 300px;
    height: 100px;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMDAgMTAwIj48cGF0aCBkPSJNMCw5MGgxMHYtMTBoNXY1aDV2LTIwaDEwdjEwaDV2LTVoMTB2MTBoNXYtMzBoMTB2MTVoNXYtMTBoMTB2NWg1di0xNWgxMHYyMGg1di0xMGg1djVoMTB2LTVoNXYtMTBoMTB2MjBoMTB2LTMwaDEwdjIwaDEwdjEwaDEwdjVoMTB2LTVoMTB2LTEwaDEwdjVoMTB2LTVoMTB2LTVoMTB2LTVoMTB2LTVoMTB2LTVoMTB2MzVoLTMwMHoiIGZpbGw9InJnYmEoMCwwLDAsMC4wMykiLz48L3N2Zz4=');
    background-repeat: no-repeat;
    background-position: bottom right;
    z-index: 0;
    opacity: 0.7;
}

/* 确保内容在背景上方 */
.check-header, .check-body, .check-footer {
    position: relative;
    z-index: 1;
}

.check-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 10px;
}

/* 添加银行标志样式 */
.bank-logo {
    max-width: 40px;
    max-height: 40px;
    margin-right: 10px;
}

.bank-info {
    max-width: 60%;
    font-size: clamp(0.7em, 2vw, 0.9em);
    word-break: break-word;
    display: flex;
    align-items: center;
}

.bank-details {
    display: flex;
    flex-direction: column;
}

.bank-name {
    font-weight: bold;
    color: var(--check-border-color);
}

.bank-address {
    font-size: 0.8em;
    color: #555;
}

.date-info {
    text-align: right;
    max-width: 40%;
    font-size: clamp(0.7em, 2vw, 0.9em);
}

.check-number {
    font-weight: bold;
    font-size: 1.2em;
    color: var(--check-border-color);
    margin-bottom: 5px;
}

.check-body {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 180px;
}

.check-body-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

/* 添加支付给样式 */
.pay-label {
    position: absolute;
    top: -12px;
    left: 0;
    font-size: 0.7em;
    color: #555;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 0 5px;
}

.payee-line {
    width: 70%;
    font-size: clamp(0.7em, 2vw, 0.9em);
    word-break: break-word;
    border-bottom: 1px solid #aaa;
    padding-bottom: 5px;
    position: relative;
}

/* 添加金额框样式 */
.amount-box {
    border: 1px solid var(--check-border-color);
    padding: 8px 10px;
    width: 120px;
    text-align: right;
    font-size: clamp(0.8em, 2vw, 1em);
    word-break: break-word;
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    font-weight: bold;
    position: relative;
}

.amount-box::before {
    content: "$";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--check-border-color);
}

.amount-text-line {
    margin: 10px 0;
    width: 100%;
    font-size: clamp(0.7em, 2vw, 0.9em);
    line-height: 1.2;
    word-break: break-word;
    border-bottom: 1px solid #aaa;
    padding-bottom: 5px;
}

.check-body-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    padding-top: 20px;
}

.memo-line {
    width: 45%;
    font-size: clamp(0.7em, 2vw, 0.85em);
    word-break: break-word;
    border-bottom: 1px solid #aaa;
    padding-bottom: 3px;
}

.signature-line {
    width: 200px;
    border-bottom: 1px solid #000;
    text-align: center;
    font-family: var(--font-signature);
    font-size: 1.2em;
    padding-bottom: 5px;
    min-height: 40px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

.signature-line::before {
    content: "Authorized Signature";
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.6em;
    font-family: var(--font-main);
    color: #555;
}

.signature-line img {
    max-width: 100%;
    max-height: 100%;
    margin-bottom: 2px;
}

.check-footer {
    margin-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 10px;
}

.micr-line {
    font-family: 'MICR', Courier, monospace;
    letter-spacing: 1px;
    width: 100%;
    font-size: clamp(0.7em, 2vw, 0.9em);
    word-break: break-word;
    text-align: center;
}

/* 打印按钮 */
.print-check {
    margin-top: 20px;
    text-align: center;
}

footer {
    margin-top: 40px;
    text-align: center;
    color: #777;
    font-size: 14px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group.full-width {
        grid-column: span 1;
    }
    
    .us-check {
        width: 100%;
        height: auto;
        aspect-ratio: 6/2.75;
    }
}

/* 响应式调整 */
@media (max-width: 650px) {
    .us-check {
        width: 100%;
        height: auto;
        min-height: 275px;
        padding: 15px;
    }
    
    .check-body {
        height: 190px;
    }
    
    .payee-line {
        width: 55%;
        font-size: 0.9em;
    }
    
    .amount-box {
        width: 80px;
        font-size: 0.85em;
    }
    
    .amount-text-line {
        font-size: 0.85em;
        max-height: 50px;
    }
    
    .signature-line {
        width: 150px;
        right: 30px;
    }
}

/* 打印样式 */
@media print {
    body {
        background: none;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        padding: 0;
    }
    
    .check-form, 
    header p,
    footer,
    button {
        display: none;
    }
    
    .check-preview {
        box-shadow: none;
        padding: 0;
        max-width: 100%;
        max-height: 100%;
        position: static;
        transform: none;
    }
    
    .lightbox-overlay {
        position: static;
        background: none;
        display: block;
    }
    
    .close-lightbox,
    .print-check {
        display: none;
    }
    
    .detailed-check-template {
        box-shadow: none;
        max-width: 100%;
    }
    
    .us-check {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .check-items th {
        background-color: #eee !important;
        color: #000 !important;
    }
}

/* 详细支票模板容器 */
.detailed-check-template {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    font-family: var(--font-main);
    background-color: white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    overflow: hidden;
}

/* 支票详细信息部分 */
.check-details {
    padding: 20px;
    background-color: white;
    border-top: 1px solid #ddd;
    font-family: var(--font-main);
}

/* 支票摘要信息 */
.check-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.summary-left, .summary-right {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-right {
    text-align: right;
}

.summary-label {
    font-weight: bold;
    color: #555;
    font-size: 0.9em;
}

.summary-value {
    font-size: 0.9em;
}

/* 支票明细表格 */
.check-items {
    width: 100%;
    margin-top: 20px;
}

.check-items table {
    width: 100%;
    border-collapse: collapse;
}

.check-items th {
    background-color: var(--table-header-bg);
    border: 1px solid var(--table-border);
    padding: 8px;
    text-align: left;
    font-weight: bold;
    color: #333;
}

.check-items td {
    border: 1px solid var(--table-border);
    padding: 8px;
    font-size: 0.9em;
}

.check-items tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

.check-items .amount-column {
    text-align: right;
}

/* 明细项目表单样式 */
.itemized-entries {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.itemized-entry {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    border: 1px solid #eee;
}

.item-description {
    flex: 3;
}

.item-date, .item-amount {
    flex: 1;
}

.remove-item {
    background-color: var(--accent-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.remove-item:hover {
    background-color: #c0392b;
}

.add-item-btn {
    background-color: var(--success-color);
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
}

.add-item-btn:hover {
    background-color: #27ae60;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .itemized-entry {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    
    .item-description {
        grid-column: span 2;
    }
    
    .remove-item {
        grid-row: 1;
        grid-column: 2;
        justify-self: end;
    }
} 