/* =========================
   폰트 설정
   ========================= */
/* Google Fonts - Jua (Korean), Roboto Mono (English) */
@import url('https://fonts.googleapis.com/css2?family=Jua&family=Roboto+Mono:wght@400;500;700&display=swap');

/* 기본 영어/숫자는 Roboto Mono */
body {
    font-family: "Roboto Mono", monospace;
    margin: 0;
    padding: 0;
}

/* 한국어는 Jua */
:lang(ko) {
    font-family: "Jua", sans-serif;
}

/* 공통 폰트 크기 */
.font-1rem {
    font-size: 1rem;
}


/* =========================
   테이블 기본 스타일
   ========================= */
.tr-border {
    border-bottom: 2px solid #333;
}

/* 테이블 공백 */
.tr-margin {
    border-collapse: separate;
    border-spacing: 0 3px;
}

/* 테이블 전체 래퍼 (좌우 2개 테이블도 대응) */
.table-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

/* PC: 2열, 태블릿/모바일: 1열로 변경 */
.wallet-table-container {
    flex: 1 1 380px;
    min-width: 380px;
    max-width: 50%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative; /* sticky 기준점 추가 */

}

/* 스크롤 가능한 테이블 영역만 별도 분리 */
.wallet-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 60vh; /* 적절한 높이 제한 */
    -webkit-overflow-scrolling: touch;
}


/* 지갑/결혼 테이블 공통 */
.table-wallet-life,
.table-wedding-life,
.table-wedding-money {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: auto;               /* 고정 → 유동 */
    border-collapse: collapse !important;
    margin-top: 0.5%;
}

/* 테이블 헤더/셀 기본 패딩 */
.table-wallet-life th,
.table-wallet-life td,
.table-wedding-life th,
.table-wedding-life td,
.table-wedding-money th,
.table-wedding-money td {
    padding: 0.6rem;
    min-width: 6rem;
    box-sizing: border-box;
}

/* 맨 상단 연월 - 수정된 sticky */
.wallet-life-ym {
    position: sticky;
    top: 0; /* top: 3% → 0으로 변경 */
    left: 0;
    right: 0;
    z-index: 100; /* 9999 → 100으로 낮춤 (충돌 방지) */
    font-size: 1.2rem;
    font-weight: 700;
    color: #3B060A;
    padding: 0.8rem 1rem;
    border-bottom: 2px solid #333;
    background: #fff;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* 시각적 구분 강화 */
    text-align: center;
}

/* 2컬럼 컨테이너: flex로 좌우 분할 */
.wallet-ym-columns {
    display: flex;
    gap: 16px;
    left:30%;
    /* height: 260px;*/
}

/* 양쪽 컬럼 공통 */
.wallet-year-column,
.wallet-month-column {
    flex: 1;
    border-radius: 12px;
    background: #f8f9fa;
    padding: 12px 0;
    overflow-y: auto;           /* 각자 세로 스크롤 */
    -webkit-overflow-scrolling: touch;
}

/* 리스트 기본 스타일 */
.wallet-year-column ul,
.wallet-month-column ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wallet-year-column li,
.wallet-month-column li {
    padding: 10px 18px;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
}

/* 연도/월 hover & 선택 상태 */
.wallet-year-column li:hover,
.wallet-month-column li:hover {
    background: #e9ecef;
}

.wallet-year-column li.active,
.wallet-month-column li.active {
    font-weight: 700;
    color: #000;
    background: #ffe8e0;
}

/* 모바일에서 높이 조금 줄이기 */
@media (max-width: 576px) {
    .wallet-ym-columns {
        height: 350px;
    }

    .wallet-year-column li,
    .wallet-month-column li {
        padding: 10px 14px;
        font-size: 0.95rem;
    }
}

/* 테이블 헤더도 sticky로 고정 */
.table-wallet-life thead {
    position: sticky;
    top: 3.5rem; /* .wallet-life-ym 높이만큼 여백 */
    z-index: 99;
    background: #fff;
}

/* 지갑 내역 테이블 전용 */
.table-wallet-life thead th {
    /* 필요시 색상 사용 */
    /* background-color: #FFC4C4; */
}

.table-wallet-life td {
    cursor: pointer;
}

/* 마우스 오버 효과 */
.table-wallet-life tbody tr:hover {
    outline: 2px solid #FF6F61;
    background-color: #EE6983;
    outline-offset: -2px;
}

/* 결혼 지출 테이블 */
.table-wedding-life th {
    border: 1px solid #ff9671;
    background-color: #ffc75f;
}

.table-wedding-life td {
    border: 1px solid #ff9671;
    background-color: #f9f871;
}

/* 축의금 테이블 */
.table-wedding-money th {
    border: 1px solid #30336b;
    background-color: #c7ecee;
}

/* 컬럼 너비 (PC 기준) */
.date {
    width: 10%;
}

.income-expense {
    width: 20% !important;
    min-width: 0 !important;
    font-size: 0.9rem;
}

.money-type {
    width: 12%;
}

/* 정렬/폰트 관련 */
.font-center {
    text-align: center;
    font-size: 0.8rem;
}

.font-size {
    font-size: 0.7rem;
}

.amount {
    text-align: right;
    font-size: 1rem !important;
}

.tbl-title {
    height: 10px;
    font-weight: 700;
    text-align: center;
}

.tbl-wallet-head-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #3B060A;
}

.tbl-wallet-title-ym {
    font-size: 0.9rem;
    margin-right: 0.5rem;
    color: #3B060A;
}

.wallet-category {
    width: 20%;
    margin-left: 0.5rem;
}

.text-right {
    text-align: right !important;
}

.text-left {
    text-align: left !important;
}

.tbl-td-detail {
    text-align: left;
    font-size: 1.1rem;
}

.tbl-td-date {
    font-size: 0.9rem;
    color: #808080;
    margin-left: 3%;
}

/* 월 요약 텍스트 */
.summary-wallet-life {
    font-size: 1.4rem;
    font-weight: 700;
    color: #3B060A;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* 등록버튼 */
.button-insert {
    background-color: #212529;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}


/* =========================
   필터 영역
   ========================= */
.filter-button-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
}

.filter-label {
    background-color: #fff;
    font-size: 1.0rem;
    font-weight: 400;
}

.filter-icon {
    width: 20px;
    height: 20px;
    margin-left: auto;
    cursor: pointer;
}

/* 필터 슬라이드업 모달 오버레이 */
.filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1040;
}

.filter-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 필터 슬라이드업 모달 */
.filter-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1050;
    max-height: 85vh;
    height: auto;
    overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
    margin: 0;
    width: 100vw;
}

.filter-modal.show {
    transform: translateY(0);
}

.filter-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e9ecef;
}

.filter-modal-header h6,
.filter-modal-header h5 {
    margin: 0;
    font-weight: 600;
    color: #212529;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-modal-body {
    padding: 24px;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-row select {
    flex: 1;
    min-width: 140px;
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
}

/* 버튼 가로 정렬 컨테이너 */
.filter-row-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
    margin-bottom: 5%;
}

/* 필터 버튼 */
.filter-option {
    flex: 1;
    padding: 12px 8px;
    font-size: 14px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background-color: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.filter-option.active {
    color: black;
    border-color: #ff6f61;
}

.filter-option:hover:not(.active) {
    border-color: #ff6f61;
    background-color: #fff5f4;
}

.filter-option:active {
    transform: translateY(1px);
}

/* 필터 적용 버튼 */
.apply-btn {
    background-color: #212529;
    width: 100%;
    border-radius: 8px !important;
    color: white;
    padding: 14px 20px;
    margin-top: 70%;
    height: 4%;
}


/* =========================
   페이징/버튼
   ========================= */
   .wallet-load-more-btn {
    display: block;
    margin: 12px auto 0;
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: #333;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    display: none;
}
.wallet-load-more-btn[disabled] {
    opacity: 0.5;
    cursor: default;
}


.button-container {
    margin-top: 2%;
}

.button {
    width: 100px;
    height: 40px;
    cursor: pointer;
    position: relative;
    display: grid;
    top: 3%;
}

.button span {
    margin: auto;
    font-weight: 600;
    display: block;
    font-size: 1em;
}

/* 밝기(빛나는) 효과 버튼 */
.button--brightness {
    color: #fff;
    background-color: transparent;
    border: 2px solid hsl(120, 43%, 35%);
    border-radius: 5px;
    overflow: hidden;
    transition: background-color .7s;
}

.button--brightness:before,
.button--brightness:after {
    content: "";
    position: absolute;
    width: 60px;
    height: 100%;
    border-radius: 5px;
    filter: blur(15px);
    opacity: 0;
    pointer-events: none;
}

.button--brightness:before {
    top: 0;
    left: 0;
    background-color: hsla(0, 0%, 100%, 0.5);
    transform: translate3d(-150%, 0, 0) skew(-15deg);
}

.button--brightness:after {
    top: 0;
    left: 30px;
    width: 30px;
    background-color: hsl(120, 43%, 35%);
    transform: translate3d(-100px, 0, 0) skew(-15deg);
}

.button--brightness:hover {
    border: 2px solid #fff;
    background-color: hsl(120, 43%, 35%);
    transition: background-color .1s, color .7s .1s, border .7s;
}

.button--brightness:hover:before,
.button--brightness:hover:after {
    transform: translate3d(180%, 0, 0);
    opacity: .6;
    transition: transform .7s;
}


/* =========================
   등록 모달 (지갑)
   ========================= */
#modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(25, 25, 25, 0.45);
    z-index: 9998;
    justify-content: center;
    align-items: center;
}

/* 모달 자체 */
#wallet-modal {
    position: fixed;
    left: 50%;
    top: 0;                         /* 화면 상단 기준 */
    transform: translate(-50%, -100%);  /* 화면 위로 숨김 */
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    border-radius: 14px;
    padding: 32px 28px;
    min-width: 360px;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 9999;
    box-sizing: border-box;
    transition: transform 0.35s ease-out;  /* 부드러운 슬라이드 */
}

/* 활성 상태일 때: 화면 안으로 내려옴 */
#wallet-modal.show {
    transform: translate(-50%, 0);  /* 위에서 아래로 내려온 상태 */
}

/* 모바일에서 폭 좁게 조정 */
@media (max-width:650px) {
    #wallet-modal {
        min-width: 90vw;
        padding: 18px 8px;
    }
}

.modal-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    height: 48px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    position: relative;
    justify-content: flex-start;
}

#modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    position: absolute;
    top: 0;
    /* right: 18px; */
}

/* 모달 내부 필드 */
.modal-fields {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.modal-fields input,
.modal-fields select {
    font-size: 1rem;
    padding: 8px 12px;
    border-radius: 7px;
    border: 1px solid #ccc;
    min-width: 80px;
    box-sizing: border-box;
}


/* =========================
   결혼/축의금 모달
   ========================= */
/* 오버레이 */
#wedding-modal-overlay {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: none;
}

/* body 스크롤 차단 */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100vw !important;
    top: 0;
    left: 0;
}

/* 결혼 지출 모달 */
#wedding-modal,
#money-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    max-width: 95vw;
    width: 350px;
    max-height: 90vh;
    padding: 18px 16px 16px 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* 내용부 스크롤 */
#wedding-modal-content,
#money-modal-content {
    overflow-y: auto;
    flex: 1;
    min-height: 100px;
    max-height: 60vh;
    margin-top: 24px;
}

/* 닫기 버튼 */
#wedding-modal-close,
#money-modal-close {
    position: absolute;
    left: 8px;
    top: 8px;
    background: transparent;
    border: none;
    font-size: 1.7rem;
    color: #333;
    cursor: pointer;
    z-index: 2;
}


/* =========================
   로딩 인디케이터
   ========================= */
.ring {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    background: transparent;
    border: 3px solid #3c3c3c;
    border-radius: 50%;
    text-align: center;
    line-height: 150px;
    font-family: sans-serif;
    font-size: 20px;
    color: black;
    letter-spacing: 4px;
    text-transform: uppercase;
    text-shadow: 0 0 10px #fff000;
    box-shadow: 0 0 20px rgba(0, 0, 0, .5);
}

.ring:before {
    content: '';
    position: fixed;
    top: -3px;
    left: -3px;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #fff000;
    border-right: 3px solid #fff000;
    border-radius: 50%;
    animation: animateC 2s linear infinite;
}

.ring span {
    display: block;
    position: fixed;
    top: calc(50% - 2px);
    left: 50%;
    width: 50%;
    height: 4px;
    background: transparent;
    transform-origin: left;
    animation: animate 2s linear infinite;
}

.ring span:before {
    content: '';
    position: fixed;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff000;
    top: -6px;
    right: -8px;
    box-shadow: 0 0 20px #fff000;
}

@keyframes animateC {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes animate {
    0% { transform: rotate(45deg); }
    100% { transform: rotate(405deg); }
}


/* =========================
   부트스트랩 alert 위치
   ========================= */
.alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    min-width: 260px;
    max-width: 96vw;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.16);
}


/* =========================
   Datepicker 커스터마이징
   ========================= */
.datepicker {
    font-size: 18px !important;
    width: 30% !important;
}

.datepicker table {
    width: 100% !important;
}

.datepicker td,
.datepicker th {
    font-size: 18px !important;
    padding: 8px !important;
}


/* =========================
   반응형 (브레이크포인트)
   ========================= */

/* 태블릿 이하: 테이블 1열, 가로 스크롤 허용 */
@media (max-width: 992px) {
    .table-wrapper {
        flex-direction: column;
        gap: 1.5rem;
        padding-left: 8px;
        padding-right: 8px;
    }

    .wallet-table-container {
        max-width: 100% !important;
        min-width: 0 !important;
        width: 100% !important;
        overflow: visible; /* overflow 제거 */

    }

    .wallet-scroll-container {
        overflow-x: auto;
        overflow-y: auto;
        max-height: 50vh;
    }

    .table-wallet-life,
    .table-wedding-life,
    .table-wedding-money {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

/* 650px 이하: 등록 모달/필드 정렬 */
@media (max-width:650px) {
    #wallet-modal {
        min-width: 90vw;
        padding: 18px 8px;
    }

    .modal-fields {
        flex-direction: column;
        gap: 10px;
    }

    .modal-fields input,
    .modal-fields select {
        min-width: 0;
        width: 100%;
    }
}

/* 600px 이하: datepicker, 결혼/축의금 모달 최적화 */
@media only screen and (max-width: 600px) {
    .datepicker {
        font-size: 16px !important;
        width: 90vw !important;
        min-width: 0 !important;
        max-width: 100vw !important;
    }

    .datepicker td,
    .datepicker th {
        padding: 8px !important;
        font-size: 1.1rem !important;
    }

    input.form-control {
        font-size: 16px !important;
        height: 42px !important;
    }

    #wedding-modal,
    #money-modal {
        width: 98vw;
        max-width: 98vw;
        max-height: 80vh;
        padding: 10px 4px 10px 4px;
    }

    #wedding-modal-content,
    #money-modal-content {
        max-height: 60vh;
        min-height: 100px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* 필터 모달 - 모바일 최적화 */
@media (max-width: 576px) {
    .filter-modal {
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        max-height: 90vh;
    }

    .filter-modal-header {
        padding: 16px 20px 12px;
        gap: 12px;
    }

    .filter-modal-header h6,
    .filter-modal-header h5 {
        font-size: 16px;
    }

    .filter-modal-body {
        padding: 20px 16px 24px;
    }

    .filter-row {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
    }

    .filter-row select {
        min-width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        height: 48px;
    }

    .filter-row-buttons {
        gap: 6px;
        flex-wrap: wrap;
    }

    .filter-option {
        flex: 1 1 calc(33.333% - 6px);  /* 3열 */
        padding: 12px 6px;
        font-size: 13px;
        min-height: 44px;
    }

    .filter-label {
        font-size: 1.1rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 16px;
        height: 48px;
    }

    .apply-btn {
        margin-top: 20px;
        height: auto;
        padding: 16px;
    }
}

/* 매우 작은 화면 (iPhone SE 등) */
@media (max-width: 375px) {
    .filter-row-buttons {
        flex-direction: column;
    }

    .filter-option {
        flex: 1 1 auto;
    }

    .filter-modal-header {
        padding: 14px 16px 10px;
    }

    .filter-modal-body {
        padding: 16px 12px 20px;
    }

    #wallet-modal,
    #wedding-modal,
    #money-modal {
        width: 95vw;
        min-width: 0;
        padding: 16px 10px;
    }
}

/* 뷰포트 단위로 안전장치 */
@supports (height: 100dvh) {
    .filter-modal {
        max-height: 85dvh;
    }
}

@media (max-width: 576px) and (supports (height: 100dvh)) {
    .filter-modal {
        max-height: 90dvh;
    }
}
