/* 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* 헤더 */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 1rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 섹션 공통 스타일 */
section {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

section h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* 입력 섹션 */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.input-group input,
.input-group select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group .unit {
    position: absolute;
    right: 1rem;
    bottom: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group input[type="number"] {
    padding-right: 2.5rem;
}

.calculate-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.calculate-btn:active {
    transform: translateY(0);
}

/* 요약 카드 */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.summary-card {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 1rem;
    padding: 1.5rem;
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s;
}

.summary-card:hover {
    transform: translateY(-4px);
}

.summary-card.age-55 {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
}

.summary-card.age-60 {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
}

.summary-card.age-65 {
    border-left-color: #8b5cf6;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
}

.summary-card h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.summary-card .amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.summary-card .details {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-top: 1px dashed var(--border-color);
}

.summary-card .details .label {
    color: var(--text-secondary);
}

.summary-card .details .value {
    font-weight: 600;
}

.summary-card .details.growth .value {
    color: var(--success-color);
}

/* 차트 섹션 */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* 세금 정보 카드 */
.tax-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.tax-card {
    background: var(--bg-primary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    border-top: 4px solid var(--primary-color);
}

.tax-card.pension {
    border-top-color: #10b981;
}

.tax-card.irp {
    border-top-color: #3b82f6;
}

.tax-card.isa {
    border-top-color: #8b5cf6;
}

.tax-card.general {
    border-top-color: #f59e0b;
}

.tax-card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.tax-card ul {
    list-style: none;
}

.tax-card li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.tax-card li:last-child {
    border-bottom: none;
}

/* 수령 계산 섹션 */
.withdrawal-block {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-primary);
    border-radius: 0.75rem;
}

.withdrawal-block h3 {
    color: var(--primary-color);
}

/* 테이블 스타일 */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

th:first-child,
td:first-child {
    text-align: left;
}

tr:hover {
    background: #f0f9ff;
}

.withdrawal-table tbody tr:nth-child(odd) {
    background: rgba(37, 99, 235, 0.03);
}

.detail-table tbody tr:nth-child(odd) {
    background: rgba(37, 99, 235, 0.03);
}

/* 긍정적/부정적 값 스타일 */
.positive {
    color: var(--success-color);
}

.negative {
    color: var(--danger-color);
}

/* 출처 섹션 */
.sources-section {
    background: #fefce8;
    border-left: 4px solid #eab308;
}

.sources-section ul {
    list-style: none;
}

.sources-section li {
    padding: 0.5rem 0;
}

.sources-section a {
    color: var(--primary-color);
    text-decoration: none;
}

.sources-section a:hover {
    text-decoration: underline;
}

/* 푸터 */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer p {
    margin: 0.5rem 0;
}

footer .copyright {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: #9ca3af;
}

/* 반응형 - 태블릿 */
@media (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }

    .summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    .tax-info-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* 반응형 - 모바일 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        padding: 1.5rem 1rem;
        margin-bottom: 2rem;
        border-radius: 0.75rem;
    }

    header h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    section {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
        border-radius: 0.75rem;
    }

    section h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .input-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .input-group input,
    .input-group select {
        padding: 0.875rem 1rem;
        font-size: 16px; /* iOS 줌 방지 */
    }

    .calculate-btn {
        max-width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }

    .summary-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .summary-card {
        padding: 1.25rem;
    }

    .summary-card .amount {
        font-size: 1.5rem;
    }

    .summary-card .details {
        font-size: 0.9rem;
    }

    .chart-container {
        height: 280px;
    }

    .tax-info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tax-card {
        padding: 1.25rem;
    }

    .tax-card li {
        font-size: 0.9rem;
    }

    .withdrawal-block {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    /* 테이블 모바일 최적화 */
    .table-container {
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    table {
        font-size: 0.8rem;
        min-width: 600px;
    }

    th, td {
        padding: 0.625rem 0.5rem;
    }

    th {
        font-size: 0.75rem;
    }

    /* 출처 섹션 */
    .sources-section li {
        font-size: 0.9rem;
    }

    footer {
        padding: 1.5rem 1rem;
        font-size: 0.85rem;
    }

    footer .copyright {
        font-size: 0.8rem;
    }
}

/* 반응형 - 소형 모바일 */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    header {
        padding: 1.25rem 1rem;
    }

    header h1 {
        font-size: 1.3rem;
    }

    header .subtitle {
        font-size: 0.85rem;
    }

    section {
        padding: 1rem;
    }

    section h2 {
        font-size: 1.1rem;
    }

    .summary-card .amount {
        font-size: 1.35rem;
    }

    .chart-container {
        height: 250px;
    }

    .input-group label {
        font-size: 0.9rem;
    }

    /* 테이블 스크롤 힌트 */
    .table-container {
        position: relative;
    }

    .table-container::after {
        content: '← 스크롤 →';
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: var(--text-secondary);
        padding: 0.5rem;
        background: linear-gradient(90deg, transparent, var(--bg-primary), transparent);
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .calculate-btn {
        min-height: 48px;
    }

    .input-group input,
    .input-group select {
        min-height: 48px;
    }

    .summary-card:hover,
    .tax-card:hover {
        transform: none;
    }

    /* 터치 피드백 */
    .calculate-btn:active {
        background: var(--primary-dark);
        transform: scale(0.98);
    }
}

/* 가로 모드 모바일 */
@media (max-height: 500px) and (orientation: landscape) {
    .chart-container {
        height: 200px;
    }

    header {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    header h1 {
        font-size: 1.3rem;
    }
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* 하이라이트 스타일 */
.highlight {
    background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
}

/* 툴팁 */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 통화 포맷팅 강조 */
.currency {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* 숫자 강조 */
.big-number {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary-color);
}

/* 카드 호버 효과 */
.tax-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

/* 입력 필드 숫자 포맷 */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 선택된 계좌 유형 강조 */
.account-selected {
    border: 2px solid var(--primary-color) !important;
    background: rgba(37, 99, 235, 0.05) !important;
}

/* 로딩 상태 */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
