/* ============================
   contract.css - 契约模板生成器
   黑白简约线条风格
   ============================ */

.contract-container {
    max-width: 760px;
    padding: 20px;
    padding-bottom: 100px;
}

.tool-header {
    text-align: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--fg);
    padding-bottom: 1rem;
}
.tool-header h1 {
    font-size: 1.6rem;
    letter-spacing: 2px;
    margin-bottom: 4px;
}
.tool-desc {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ===== 通用区块 ===== */
.section {
    margin-bottom: 1.8rem;
}
.section-title {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 0.8rem;
    padding-left: 8px;
    border-left: 4px solid var(--fg);
    line-height: 1.2;
}

/* ===== 模板选择网格 ===== */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.template-card {
    border: 2px solid var(--fg);
    border-radius: 6px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    background: var(--bg);
    transition: all 0.2s;
    font-family: inherit;
}
.template-card:hover {
    background: var(--hover-bg);
}
.template-card.active {
    background: var(--fg);
    color: var(--bg);
}
.template-card .tpl-icon {
    font-size: 1.4rem;
    margin-bottom: 6px;
    font-weight: bold;
}
.template-card .tpl-name {
    font-size: 0.95rem;
    font-weight: bold;
    margin-bottom: 4px;
}
.template-card .tpl-desc {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.3;
}
.template-card.active .tpl-desc {
    color: #ddd;
}

/* ===== 表单 ===== */
.contract-form {
    border: 2px solid var(--fg);
    border-radius: 6px;
    padding: 16px;
}
.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}
.form-row:last-child {
    margin-bottom: 0;
}
.form-row label {
    width: 110px;
    flex-shrink: 0;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--fg);
}
.form-row input,
.form-row textarea {
    flex: 1;
    padding: 8px 10px;
    border: 1.5px solid var(--light-border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--fg);
    transition: border-color 0.2s;
}
.form-row input:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--fg);
}
.form-row textarea {
    resize: vertical;
    min-height: 60px;
}

/* 条款编辑器 */
.form-row.clauses-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
}
.form-row.clauses-row label {
    width: auto;
}
.clauses-editor {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.clause-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.clause-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--fg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    background: var(--bg);
}
.clause-input {
    flex: 1;
    padding: 6px 10px;
    border: 1.5px solid var(--light-border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    min-height: 28px;
}
.clause-input:focus {
    outline: none;
    border-color: var(--fg);
}
.clause-del {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--fg);
    background: var(--bg);
    color: var(--fg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.clause-del:hover {
    background: var(--fg);
    color: var(--bg);
}
.add-clause-btn {
    align-self: flex-start;
    padding: 6px 16px;
    border: 1.5px dashed var(--fg);
    background: transparent;
    color: var(--fg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}
.add-clause-btn:hover {
    background: var(--hover-bg);
}

/* ===== 预览 ===== */
.contract-preview {
    border: 2px solid var(--fg);
    border-radius: 6px;
    padding: 24px;
    background: var(--bg);
    margin-bottom: 1rem;
}
.preview-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: 4px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid var(--fg);
}
.preview-meta {
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.8;
}
.preview-meta-row {
    display: flex;
    gap: 4px;
}
.preview-meta-row .meta-label {
    font-weight: bold;
    flex-shrink: 0;
}
.preview-meta-row .meta-value {
    flex: 1;
    border-bottom: 1px dotted var(--muted);
    min-height: 1.2em;
}
.preview-clauses {
    margin: 16px 0;
}
.preview-clauses-title {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.95rem;
}
.preview-clause {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.9rem;
    line-height: 1.6;
}
.preview-clause-num {
    flex-shrink: 0;
    font-weight: bold;
}
.preview-remark {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--light-border);
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.6;
}
.preview-signature {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1.5px solid var(--fg);
    font-size: 0.9rem;
}
.sig-block {
    text-align: center;
    flex: 1;
}
.sig-line {
    margin-top: 24px;
    border-bottom: 1px solid var(--fg);
    height: 1px;
    margin-bottom: 4px;
}
.sig-label {
    font-size: 0.8rem;
    color: var(--muted);
}
.preview-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
}

/* ===== 操作按钮 ===== */
.preview-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.action-btn {
    padding: 10px 24px;
    border: 2px solid var(--fg);
    background: var(--bg);
    color: var(--fg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}
.action-btn.primary {
    background: var(--fg);
    color: var(--bg);
}
.action-btn:hover {
    opacity: 0.85;
}

/* ===== 移动端适配 ===== */
@media (max-width: 480px) {
    .contract-container {
        padding: 12px;
    }
    .tool-header h1 {
        font-size: 1.3rem;
    }
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .template-card {
        padding: 10px 6px;
    }
    .template-card .tpl-name {
        font-size: 0.85rem;
    }
    .contract-form {
        padding: 12px;
    }
    .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .form-row label {
        width: auto;
    }
    .form-row.clauses-row {
        align-items: stretch;
    }
    .contract-preview {
        padding: 16px;
    }
    .preview-title {
        font-size: 1.1rem;
        letter-spacing: 2px;
    }
    .preview-signature {
        flex-direction: column;
        gap: 20px;
    }
    .preview-actions {
        flex-direction: column;
    }
    .action-btn {
        width: 100%;
    }
}
