/* 기본 스타일 초기화 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background-color: #f5f5f5;
    line-height: 1.6;
    color: #333;
}

/* 결제 컨테이너 */
.payment-container {
    max-width: 600px;
    margin: 20px auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 헤더 */
.payment-header {
    background: #4f46e5;
    color: white;
    padding: 20px;
    text-align: center;
}

.payment-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

/* 결제 폼 */
.payment-form {
    padding: 30px;
}

/* 폼 그룹 */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-col-50 {
    flex: 1;
}

/* 유효기간 전용 스타일 */
.expiry-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.expiry-month,
.expiry-year {
    flex: 1;
}

.expiry-separator {
    font-weight: 600;
    color: #6b7280;
    font-size: 18px;
    line-height: 1;
    margin: 0 5px;
}

/* 폼 라벨 */
.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #374151;
    font-size: 14px;
}

.form-label.required::after {
    content: ' *';
    color: #ef4444;
}

/* 폼 입력 */
.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    background-color: #fff;
}

.form-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input:disabled,
.form-input[readonly] {
    background-color: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
}

/* 금액 입력 */
.amount-container {
    position: relative;
    display: flex;
    align-items: center;
}

.amount-input {
    flex: 1;
    padding-right: 50px;
    font-size: 18px;
    font-weight: 600;
    text-align: right;
    background-color: #fff;
    cursor: text;
}

.amount-input::placeholder {
    color: #9ca3af;
    font-weight: normal;
}

.amount-unit {
    position: absolute;
    right: 16px;
    color: #6b7280;
    font-weight: 500;
    font-size: 16px;
    pointer-events: none;
}

/* 카드 입력 */
.card-input {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    font-size: 18px;
}

/* 섹션 제목 */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

/* 인증 섹션 */
.auth-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

/* 구매자 정보 섹션 */
.payer-section {
    margin-top: 30px;
}

/* 약관 섹션 */
.terms-section {
    margin-top: 30px;
}

.terms-group {
    margin-bottom: 12px;
}

.terms-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.terms-label input[type="checkbox"] {
    margin-right: 12px;
    transform: scale(1.2);
    cursor: pointer;
}

.terms-text {
    flex: 1;
    font-size: 14px;
    color: #374151;
}

.terms-view-btn {
    background: #6b7280;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.terms-view-btn:hover {
    background: #4b5563;
}

/* 제출 섹션 */
.submit-section {
    margin-top: 40px;
}

.submit-btn {
    width: 100%;
    background: #4f46e5;
    color: white;
    border: none;
    padding: 16px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.submit-btn:hover:not(:disabled) {
    background: #4338ca;
}

.submit-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 에러 메시지 */
.error-message {
    background: #fee2e2;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    margin: 20px 30px;
    border-left: 4px solid #dc2626;
    font-size: 14px;
}

.error-text {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* 유효성 검증 툴팁 스타일 */
.validation-tooltip {
    position: absolute;
    background: #dc2626;
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    animation: tooltipFadeIn 0.2s ease-out;
    max-width: 280px;
    white-space: normal;
    line-height: 1.4;
}

.validation-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #dc2626;
}

.validation-tooltip.bottom {
    top: calc(100% + 8px);
}

.validation-tooltip.bottom::before {
    top: -6px;
    border-bottom-color: #dc2626;
    border-top-color: transparent;
}

.validation-tooltip.top {
    bottom: calc(100% + 8px);
    top: auto;
}

.validation-tooltip.top::before {
    top: auto;
    bottom: -6px;
    border-bottom-color: transparent;
    border-top-color: #dc2626;
}

/* 필드 에러 스타일 */
.form-input.error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-input.error:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* 성공 메시지 */
.success-text {
    color: #059669;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* 모달 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 12px;
    overflow: hidden;
}

.modal-header {
    background: #f9fafb;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #374151;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    line-height: 1.6;
}

.modal-body h4 {
    margin: 16px 0 8px 0;
    color: #1f2937;
    font-weight: 600;
}

.modal-body p {
    margin-bottom: 12px;
    color: #4b5563;
}

.modal-body ul {
    margin: 8px 0 12px 20px;
}

.modal-body li {
    margin-bottom: 4px;
    color: #4b5563;
}

.modal-footer {
    background: #f9fafb;
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    text-align: right;
}

.btn-modal-close {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.btn-modal-close:hover {
    background: #4338ca;
}

/* 셀렉트 박스 스타일 */
select.form-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

/* 체크박스 스타일 개선 */
input[type="checkbox"] {
    accent-color: #4f46e5;
}

/* 모바일에서 자동 링크 생성 방지 */
.no-link a[href^="tel"] {
    pointer-events: none;
    cursor: default;
    color: inherit;
    text-decoration: none;
}

.no-link {
    -webkit-touch-callout: none;
}

.identity-help-text {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-size: .825rem;
}

.identity-help-text .no-link {
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 접근성 향상 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .payment-container {
        margin: 10px;
        border-radius: 8px;
    }
    
    .payment-form {
        padding: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-col-50 {
        flex: none;
        width: 100%;
    }
    
    .expiry-group {
        display: flex;
        gap: 10px;
        align-items: center;
        width: 100%;
    }
    
    .expiry-month,
    .expiry-year {
        flex: 1;
        min-width: 0;
    }
    
    .expiry-separator {
        display: block;
        flex-shrink: 0;
        font-size: 16px;
    }
    
    .payment-header h1 {
        font-size: 20px;
    }
    
    .amount-input {
        font-size: 16px;
    }
    
    .card-input {
        font-size: 16px;
    }
    
    .modal {
        padding: 15px;
    }
    
    .modal-content {
        width: 100%;
        max-height: calc(100vh - 30px);
        border-radius: 8px;
    }

    .validation-tooltip {
        max-width: 250px;
        font-size: 11px;
    }
    
    .identity-help-text {
        font-size: .625rem;
    }
}

@media (max-width: 480px) {
    .payment-container {
        margin: 5px;
    }
    
    .payment-form {
        padding: 15px;
    }
    
    .terms-label {
        font-size: 13px;
    }
    
    .submit-btn {
        font-size: 16px;
        padding: 14px;
    }

    .expiry-group {
        display: flex;
        gap: 8px;
        align-items: center;
        width: 100%;
    }
    
    .expiry-month,
    .expiry-year {
        flex: 1;
        min-width: 0;
    }

    .expiry-separator {
        display: block;
        flex-shrink: 0;
        font-size: 14px;
        margin: 0 3px;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
        border-radius: 6px;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-header h3 {
        font-size: 16px;
    }
    
    .modal-close {
        width: 28px;
        height: 28px;
        font-size: 20px;
    }
    
    .modal-body {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .modal-body h4 {
        font-size: 15px;
        margin: 12px 0 6px 0;
    }
    
    .modal-footer {
        padding: 10px 15px;
    }

    .validation-tooltip {
        max-width: 200px;
        font-size: 10px;
        padding: 8px 10px;
    }
}