/* 기본 설정 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Malgun Gothic", "맑은 고딕", sans-serif;
    background: #f0f2f5;
    color: #333;
}

/* -----------------------
   1. 입력 폼 & 인증 화면 스타일
   ----------------------- */
.input-container, .auth-container {
    max-width: 500px;
    margin: 20px auto;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    font-family: "Malgun Gothic", "맑은 고딕", sans-serif;
}

.auth-container { text-align: center; display: none; }
.auth-icon { font-size: 40px; margin-bottom: 10px; }
.auth-title { font-size: 20px; font-weight: bold; margin-bottom: 5px; color: #2c3e50; }
.auth-desc { font-size: 14px; color: #7f8c8d; margin-bottom: 20px; }
.auth-input { width: 100%; padding: 12px; margin-bottom: 10px; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 16px; }
.btn-auth { width: 100%; padding: 12px; background: #27ae60; color: white; border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; }

.header-brand { text-align: center; margin-bottom: 25px; color: #2c3e50; }
.header-brand h1 { font-size: 20px; margin-bottom: 5px; }
.header-brand p { font-size: 13px; color: #7f8c8d; }

.form-section { margin-bottom: 20px; }
.form-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #34495e; }
.required-mark { color: #e74c3c; margin-left: 3px; }

input[type="text"], input[type="tel"], input[type="date"], select {
    width: 100%; padding: 12px; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 16px; transition: 0.3s;
}
input:focus, select:focus { border-color: #3498db; outline: none; box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2); }

/* 유효성 검사 에러 */
input.input-error { border-color: #e74c3c !important; background-color: #fff8f8; }
.error-message { color: #e74c3c; font-size: 12px; margin-top: 5px; display: none; }
.error-message.show { display: block; animation: shake 0.3s ease-in-out; }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-5px); } 100% { transform: translateX(0); } }

.radio-group { display: flex; gap: 10px; background: #f8f9fa; padding: 5px; border-radius: 6px; }
.radio-label { flex: 1; text-align: center; padding: 10px; cursor: pointer; border-radius: 4px; font-size: 14px; transition: 0.2s; }
input[type="radio"] { display: none; }
input[type="radio"]:checked + .radio-label { background: #3498db; color: white; font-weight: bold; }

.btn-submit { width: 100%; padding: 16px; background: #2980b9; color: white; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 10px; }
.btn-submit:hover { background: #2573a7; }

/* AI Section */
.ai-section { background: #f0f7ff; border: 1px solid #cce5ff; border-radius: 8px; padding: 15px; margin-bottom: 20px; }
.ai-title { font-size: 14px; font-weight: bold; color: #0056b3; margin-bottom: 10px; display: flex; align-items: center; gap: 5px; }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.btn-ai { background: linear-gradient(135deg, #6e8efb, #a777e3); color: white; border: none; padding: 10px; border-radius: 12px; font-size: 13px; font-weight: bold; cursor: pointer; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.1s; }
.btn-ai:active { transform: scale(0.98); }
.btn-ai.safe { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn-ai.easy { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.btn-ai.trans { background: linear-gradient(135deg, #3498db, #2980b9); }
.btn-ai span { font-size: 11px; font-weight: normal; opacity: 0.9; }
.ai-result { margin-top: 10px; font-size: 13px; background: white; padding: 12px; border-radius: 8px; border: 1px solid #e1e4e8; white-space: pre-line; display: none; line-height: 1.6; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.lang-select { width: 100%; padding: 8px; border: 1px solid #dfe6e9; border-radius: 6px; margin-bottom: 5px; font-size: 13px; }

/* -----------------------
   2. 계약서 양식 스타일
   ----------------------- */
.contract-paper {
    display: none; /* 초기엔 숨김 */
    width: 210mm;
    margin: 20px auto;
    background: white;
    padding: 20mm 15mm;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden; 
}

@media print {
    body { 
        background: white; 
        margin: 0 !important;
        padding: 0 !important;
    }
    .input-container, .auth-container, .action-bar, .success-message, .modal-overlay { display: none !important; }
    .contract-paper { 
        display: block !important; 
        width: 100% !important; 
        max-width: 100% !important;
        min-height: 0 !important; /* 최소 높이 제거 */
        height: auto !important; /* 자동 높이 */
        margin: 0 !important; 
        box-shadow: none !important; 
        padding: 12mm 15mm !important;
        page-break-after: avoid !important; /* 페이지 나누기 방지 */
    }
    @page { 
        margin: 0; /* 머리글/바닥글 공간 제거 */
        size: A4 portrait;
    }
    
    /* 인쇄 시 폰트 크기 - 너무 작지 않게 */
    .c-title { 
        font-size: 18pt !important; /* 살짝만 축소 */
        margin-bottom: 15px !important; 
        margin-top: 8px !important; 
    }
    .c-body { 
        font-size: 9pt !important; /* 읽기 편한 크기 */
        line-height: 1.35 !important; 
    }
    .c-table { 
        font-size: 8pt !important; 
        margin: 3px 0 !important; 
    }
    .c-table th, .c-table td { 
        padding: 2px 4px !important; 
    }
    .c-row { 
        margin-bottom: 7px !important; /* 섹션 간격 줄임 */
    }
    .c-indent { 
        margin-left: 12px !important; 
        margin-top: 2px !important; 
    }
    .c-sign-box { 
        margin-top: 12px !important; /* 서명란 상단 여백 줄임 */
        padding: 0 15px !important; 
    }
    
    /* 인쇄 시 로고 크기 */
    .contract-paper img {
        height: 50px !important; /* 적절한 크기 */
    }
    
    /* 본문 단락의 여백 약간 줄임 */
    .c-body p {
        margin-bottom: 3px !important;
    }
    
    /* 페이지 나누기 방지 */
    .c-row, .c-table, .c-sign-box { 
        page-break-inside: avoid !important; 
    }
    
    /* 추가: 모든 요소가 1페이지에 들어가도록 */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }
}

.c-title { text-align: center; font-size: 20pt; font-weight: bold; text-decoration: underline; margin-bottom: 25px; margin-top: 20px; font-family: "Malgun Gothic", "맑은 고딕", sans-serif; position: relative; z-index: 1; }
.c-body { font-family: "Malgun Gothic", "맑은 고딕", sans-serif; font-size: 10pt; line-height: 1.4; position: relative; z-index: 1; }
.c-table { width: 100%; border-collapse: collapse; margin: 5px 0; font-size: 9pt; }
.c-table th, .c-table td { border: 1px solid black; padding: 3px 5px; text-align: center; vertical-align: middle; }
.c-table th { background-color: white; font-weight: normal; }
.c-row { margin-bottom: 12px; }
.c-indent { margin-left: 15px; margin-top: 3px; }
.c-bold { font-weight: bold; }
.c-sign-box { margin-top: 30px; display: flex; justify-content: space-between; padding: 0 20px; }
.dynamic-blue { color: #000080; font-weight: bold; }

/* 계약서 작성 완료 팝업 (모달) */
.success-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.success-content {
    max-width: 500px;
    width: 90%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: slideUp 0.5s ease-out;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.success-icon {
    font-size: 50px;
    margin-bottom: 15px;
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.success-message h3 {
    font-size: 28px;
    margin-bottom: 20px;
    font-weight: bold;
}

.success-message p {
    font-size: 16px;
    margin-bottom: 20px;
    opacity: 0.95;
    line-height: 1.5;
}

.success-list {
    text-align: left;
    list-style: none;
    margin: 20px auto;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.success-list li {
    padding: 10px 0;
    font-size: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.success-list li:last-child {
    border-bottom: none;
}

.success-list strong {
    display: block;
    font-size: 17px;
    margin-bottom: 5px;
}

.success-note {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 20px;
    font-style: italic;
}

.btn-success-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 12px 40px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 25px;
    transition: all 0.3s ease;
}

.btn-success-close:hover {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

/* 하단 액션 버튼 */
.action-bar { 
    position: fixed; 
    bottom: 20px; 
    left: 50%; 
    transform: translateX(-50%); 
    display: none; 
    gap: 8px; 
    z-index: 999;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 95%;
}

.btn-action { 
    padding: 10px 16px; 
    border-radius: 20px; 
    border: none; 
    font-weight: bold; 
    cursor: pointer; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-size: 13px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .action-bar {
        bottom: 15px;
        gap: 6px;
        padding: 0 10px;
    }
    
    .btn-action {
        padding: 10px 14px;
        font-size: 12px;
        border-radius: 18px;
    }
}

/* 아주 작은 화면 대응 */
@media (max-width: 480px) {
    .action-bar {
        bottom: 10px;
        gap: 5px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-action {
        padding: 12px 16px;
        font-size: 13px;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
}

.btn-print { background: #27ae60; color: white; }
.btn-print-only { background: #3498db; color: white; }
.btn-back { background: #95a5a6; color: white; }
.btn-link { background: #8e44ad; color: white; }

/* 모달 스타일 */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 2000; }
.modal-content { background: white; padding: 25px; border-radius: 15px; width: 90%; max-width: 400px; text-align: center; }
.modal-title { font-size: 18px; font-weight: bold; margin-bottom: 15px; }
.link-box { background: #f1f2f6; padding: 10px; border-radius: 8px; word-break: break-all; font-size: 12px; margin-bottom: 15px; border: 1px solid #ddd; max-height: 80px; overflow-y: auto; }
.qr-box { margin: 15px 0; background: white; padding: 10px; display: inline-block; border-radius: 10px; border: 1px solid #eee; }
.btn-copy { background: #34495e; color: white; padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer; width: 100%; }
.btn-close { background: transparent; color: #999; border: none; margin-top: 10px; cursor: pointer; }
