@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

/* 마루부리 (로고용 포인트 폰트) */
@font-face {
    font-family: 'MaruBuri';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-10-21@1.0/MaruBuri-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Color Palette : Modern Slate & Navy */
    --color-bg-page: #F8FAFC;
    /* 아주 연한 회색 배경 */
    --color-bg-card: #FFFFFF;
    /* 완전한 흰색 카드 */

    --color-primary: #0F172A;
    /* 거의 검정에 가까운 네이비 */
    --color-secondary: #64748B;
    /* 차분한 회색 */
    --color-accent: #2563EB;
    /* 신뢰감을 주는 로얄 블루 */
    --color-accent-hover: #1D4ED8;

    --color-border: #E2E8F0;
    /* 튀지 않는 연한 테두리 */
    --color-danger: #EF4444;
    /* 삭제/경고 */

    /* Input Colors */
    --color-input-bg: #F8FAFC;
    --color-input-border: #CBD5E1;
    --color-placeholder: #94A3B8;

    /* Spacing & Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    /* 은은한 네이비 빛이 감도는 고급스러운 그라데이션 배경 */
    background-color: var(--color-bg-page);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(15, 23, 42, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(37, 99, 235, 0.03) 0%, transparent 50%);
    background-attachment: fixed;
    /* 스크롤해도 배경은 고정 */
    color: var(--color-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --------------------------------------
   Header 
-------------------------------------- */
.header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0;
    /* 적당한 패딩 */
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    height: auto;
}

.header-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
    /* 최소 높이 지정 */
}

.header-left {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    /* 간격 제거 */
    padding: 0.4rem 0.5rem;
    /* 클릭 영역 확보 */
    margin: -0.4rem -0.5rem;
    /* 음수 마진으로 높이 상쇄 (핵심) */
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
}

.header-left:hover {
    background-color: #F8FAFC;
}

.header-left .main-info {
    font-size: 0.95rem;
    color: var(--color-primary);
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    line-height: 1.1;
    /* 줄 간격 조임 */
}

.shin-calligraphy-small {
    font-family: 'Zhi Mang Xing', 'MaruBuri', cursive !important;
    font-size: 1.3em;
    font-weight: normal;
    position: relative;
    top: 2px;
    margin-left: 2px;
}

.header-left .website-info {
    font-size: 0.7rem;
    color: var(--color-secondary);
    font-weight: 500;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.1;
    /* 줄 간격 조임 */
    margin-top: 2px;
}

.browser-tip {
    color: var(--color-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    margin: -8px 0;
    /* 높이 상쇄 */
    border-radius: var(--radius-sm);
    transition: color 0.15s ease;
}

.browser-tip:hover {
    color: var(--color-accent);
    background-color: #F1F5F9;
}

/* --------------------------------------
   Main Layout
-------------------------------------- */
.main-content {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.page-header {
    text-align: center;
    margin-bottom: 2.5rem;
    background: transparent;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

.page-description {
    font-size: 1rem;
    color: var(--color-secondary);
    max-width: 600px;
    margin: 0 auto;
    font-weight: 400;
}

/* --------------------------------------
   Tab Navigation
-------------------------------------- */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    position: relative;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-secondary);
    cursor: pointer;
    transition: color 0.2s;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--color-primary);
}

.tab-btn.active {
    color: var(--color-accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--color-accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --------------------------------------
   Calculator Section
-------------------------------------- */
.calculator-section {
    background: var(--color-bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-bg-page);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.4rem;
    display: block;
}

/* 통합 입력 스타일 */
.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    font-family: 'Pretendard', sans-serif;
    font-size: 1rem;
    color: var(--color-primary);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    -webkit-appearance: none;
    /* 모바일 스타일 제거 */
    appearance: none;
    /* 표준 속성 추가 */
}

.form-control:focus {
    outline: none;
    background-color: #FFFFFF;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control::placeholder {
    color: var(--color-placeholder);
    opacity: 1;
}

/* Period Section */
.period-section {
    background: #FFFFFF;
    border: 1px solid var(--color-input-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

.period-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed #E2E8F0;
}

.period-number {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-primary);
    background: #F1F5F9;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
}

.period-remove {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    transition: color 0.15s;
}

.period-remove:hover {
    color: var(--color-danger);
}

.period-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    /* 날짜, 날짜, 이자율 */
    gap: 1rem;
}

.period-payment {
    grid-template-columns: 1fr 0.8fr 1fr;
    /* 날짜, 이자율, 금액 */
}

/* Rate Chips (이자율 빠른 입력 버튼) - Updated Layout */
.rate-chips {
    display: flex;
    gap: 0.35rem;
    /* 간격 살짝 좁힘 */
    margin-top: 0.6rem;
    flex-wrap: nowrap;
    /* 한 줄 유지 (줄바꿈 X) */
    align-items: center;
}

.chip-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    background: #F1F5F9;
    color: var(--color-secondary);
    border: 1px solid #E2E8F0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s;
    font-weight: 500;
    white-space: nowrap;
    /* 글자 줄바꿈 방지 */
    flex: 1;
    /* 가득 채우기 */
    text-align: center;
    min-width: 0;
    /* flex box ellipsis 방지용 */
}

.chip-btn:hover {
    background: #E2E8F0;
    color: var(--color-primary);
    border-color: #CBD5E1;
}

.chip-btn:active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    transform: translateY(1px);
}

/* Buttons */
.btn-add-period {
    width: 100%;
    background: white;
    border: 1px dashed #94A3B8;
    color: var(--color-secondary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-add-period:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: #FAFAFA;
}

.btn-calculate {
    width: 100%;
    margin-top: 1.5rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-calculate:hover {
    background-color: var(--color-accent);
}

/* Results Section */
.results-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px dashed var(--color-border);
    animation: fadeIn 0.3s ease-out;
}

.result-period {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
}

.result-period-header {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.result-detail {
    font-size: 0.9rem;
    color: var(--color-secondary);
    line-height: 1.6;
}

.result-formula {
    font-family: 'D2Coding', 'Courier New', monospace;
    background: #F1F5F9;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-primary);
    margin: 0.5rem 0;
    overflow-x: auto;
}

.result-total {
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-top: 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.result-total-label {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.result-total-amount {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.result-total .result-detail {
    color: #94A3B8;
    font-size: 0.95rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-action {
    flex: 1;
    padding: 0.875rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.btn-action:hover {
    background: #F8FAFC;
    border-color: #94A3B8;
}

/* Warning Box */
.warning-box {
    background: #FFFBEB;
    border: 1px solid #FCD34D;
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin: 1.5rem 0;
    display: flex;
    gap: 10px;
}

.warning-box i {
    color: #D97706;
    margin-top: 2px;
}

.warning-text {
    color: #92400E;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Footer */
.footer {
    border-top: 1px solid var(--color-border);
    background: white;
    padding: 2rem 0;
    margin-top: auto;
}

.footer-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.footer-links a {
    color: var(--color-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.footer-copyright {
    font-size: 0.75rem;
    color: #94A3B8;
    line-height: 1.6;
}

/* Modal (Home Guide) */
.home-guide-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.home-guide-modal.show {
    display: flex;
}

.home-guide-content {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    position: relative;
    padding-top: 3.5rem;
}

.service-link-copy {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    background: var(--color-primary);
    color: white;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
}

.guide-header {
    text-align: center;
    margin: 1rem 0;
}

.guide-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #94A3B8;
}

.browser-section {
    background: #F8FAFC;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.guide-steps {
    padding-left: 1.2rem;
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-secondary);
}

/* Lawyer Banner (Fixed) */
.lawyer-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #fff;
    padding: 10px 16px 10px 11px;
    border-radius: 13px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--color-primary);
    transition: all 0.2s ease;
    z-index: 999;
    border: 2.5px solid #94A3B8;
}

.lawyer-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
    border-color: var(--color-primary);
}

.lawyer-icon-box {
    width: 36px;
    height: 36px;
    background: #F1F5F9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.lawyer-text-box {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.lawyer-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.01em;
}

.lawyer-subtitle {
    font-size: 0.65rem;
    color: var(--color-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
}

.lawyer-subtitle::after {
    content: '→';
    font-size: 0.8em;
    transition: transform 0.2s;
}

.lawyer-banner:hover .lawyer-subtitle::after {
    transform: translateX(3px);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .calculator-section {
        padding: 1.25rem;
    }

    .period-inputs,
    .period-payment {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lawyer-banner {
        bottom: 16px;
        right: 16px;
        padding: 8px 13px 8px 10px;
    }

    .chip-btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

@media print {

    .no-print,
    .header,
    .footer,
    .lawyer-banner {
        display: none !important;
    }
}