/* 전역 스타일 */
:root {
    --primary-color: #4F46E5;
    --secondary-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px 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);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* 헤더 */
.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

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

/* 목표 설정 섹션 */
.goal-setup {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    max-width: 100%;
    overflow: hidden;
}

.goal-setup h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.inline {
    flex: 1;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-group input {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
    font-family: 'Noto Sans KR', sans-serif;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 버튼 스타일 */
.btn-primary, .btn-success, .btn-nav, .btn-delete {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Noto Sans KR', sans-serif;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #4338CA;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-nav {
    background: var(--surface);
    color: var(--primary-color);
    padding: 8px 16px;
    border: 2px solid var(--border-color);
}

.btn-nav:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-delete {
    background: var(--danger-color);
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-delete:hover {
    background: #DC2626;
}

.btn-edit {
    background: var(--warning-color);
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Noto Sans KR', sans-serif;
}

.btn-edit:hover {
    background: #D97706;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Noto Sans KR', sans-serif;
}

.btn-secondary:hover {
    background: #4B5563;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: all 0.3s;
}

.btn-close:hover {
    color: var(--danger-color);
    transform: rotate(90deg);
}

.btn-help {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    transition: all 0.3s;
}

.btn-help:hover {
    color: var(--secondary-color);
    transform: scale(1.2);
}

/* 대시보드 */
.dashboard {
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 빠른 잔고 입력 */
.quick-balance {
    background: var(--surface);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    max-width: 100%;
    overflow: hidden;
}

.quick-balance h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.balance-form {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

/* 핵심 지표 카드 */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.metric-card:hover {
    transform: translateY(-5px);
}

.metric-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.metric-content h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 5px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* 목표 정보 */
.target-info {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    max-width: 100%;
    overflow: hidden;
}

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

.info-card {
    background: linear-gradient(135deg, #f6f8fb 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid var(--border-color);
}

.info-card h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row span {
    color: var(--text-secondary);
}

.info-row strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* 목표 금액 차이 표시 */
.target-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.diff-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.diff-badge.positive {
    background-color: #D1FAE5;
    color: #065F46;
}

.diff-badge.negative {
    background-color: #FEE2E2;
    color: #991B1B;
}

.diff-badge i {
    font-size: 0.7rem;
    margin-right: 2px;
}

/* 달력 섹션 */
.calendar-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    max-width: 100%;
    overflow: hidden;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.calendar-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.achieved-simple {
    background: #FCD34D;
}

.achieved-compound {
    background: #60A5FA;
}

.achieved-both {
    background: #34D399;
}

.not-achieved {
    background: #FCA5A5;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    min-width: 0;
    min-height: 0;
    padding: 4px;
    overflow: hidden;
}

.calendar-day.header {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: default;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.day {
    background: var(--background);
    border: 2px solid var(--border-color);
}

.calendar-day.day:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow);
}

.calendar-day.today {
    border-color: var(--primary-color);
    border-width: 3px;
}

.calendar-day.achieved-simple {
    background: #FCD34D;
    border-color: #F59E0B;
}

.calendar-day.achieved-compound {
    background: #60A5FA;
    border-color: #3B82F6;
}

.calendar-day.achieved-both {
    background: #34D399;
    border-color: #10B981;
}

.calendar-day.not-achieved {
    background: #FCA5A5;
    border-color: #EF4444;
}

.calendar-day .day-number {
    font-size: 1rem;
}

.calendar-day .day-balance {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* 히스토리 섹션 */
.history-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    max-width: 100%;
    overflow: hidden;
}

.history-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: var(--background);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.history-item:hover {
    box-shadow: var(--shadow);
    transform: translateX(5px);
}

.history-date {
    font-weight: 600;
    color: var(--primary-color);
}

.history-balance {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-actions {
    display: flex;
    gap: 8px;
}

/* 반응형 디자인 */

/* 태블릿 (iPad) - 768px ~ 1024px */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        padding: 15px;
    }

    .calendar-section {
        padding: 20px;
    }

    .calendar {
        gap: 6px;
    }

    .calendar-day {
        font-size: 0.85rem;
        padding: 2px;
    }

    .calendar-day .day-number {
        font-size: 0.9rem;
    }

    .calendar-day .day-balance {
        font-size: 0.65rem;
    }

    .calendar-legend {
        gap: 15px;
    }

    .legend-item {
        font-size: 0.85rem;
    }

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

/* 모바일 - 768px 이하 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .balance-form {
        flex-direction: column;
        align-items: stretch;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

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

    .calendar-section {
        padding: 15px;
    }

    .calendar {
        gap: 4px;
    }

    .calendar-day {
        font-size: 0.75rem;
        padding: 2px;
    }

    .calendar-day .day-number {
        font-size: 0.85rem;
    }

    .calendar-day .day-balance {
        font-size: 0.6rem;
    }

    .calendar-legend {
        font-size: 0.8rem;
        gap: 10px;
    }
}

/* 스크롤바 스타일 */
.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #4338CA;
}

/* 목표 정보 카드 헤더 */
.card-header-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header-with-button h4 {
    margin: 0;
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin: 0;
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body .form-group {
    margin-bottom: 20px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--warning-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 25px;
    border-top: 2px solid var(--border-color);
}

/* 대형 모달 */
.modal-large {
    max-width: 700px;
}

/* 도움말 모달 스타일 */
.help-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.help-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.help-section h4 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.help-section p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.help-section.highlight {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--warning-color);
}

.help-section.highlight h4 {
    color: var(--warning-color);
}

.help-section.highlight ul {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.help-section.highlight li {
    padding: 8px 0;
    color: var(--text-primary);
    line-height: 1.6;
}

.help-section.highlight li:before {
    content: "✓ ";
    color: var(--secondary-color);
    font-weight: bold;
    margin-right: 8px;
}

.help-formula {
    background: var(--background);
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
}

.help-formula div {
    padding: 5px 0;
    color: var(--text-primary);
}

.help-example {
    background: var(--background);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.help-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.help-row:last-child {
    border-bottom: none;
}

.help-row span {
    color: var(--text-secondary);
}

.help-row strong {
    color: var(--text-primary);
    font-weight: 600;
}

.help-badge-example {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.badge-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
}

.badge-row .diff-badge {
    flex-shrink: 0;
}

.badge-row span:last-child {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
