:root {
    /* --- 라이트 모드 (기본) 색상 변수 --- */
    --text-primary: #212529; /* 일반 텍스트 색상 (부트스트랩 기본) */
    --text-secondary: #343a40; /* 폼 라벨, 특정 어두운 텍스트용 */
    --text-link: #333333; /* 링크 색상 */
    --text-active-sidebar-link: #2470dc; /* 사이드바 활성 링크 색상 */
    --text-navbar-dropdown-item: #333333; /* 네비바 드롭다운 아이템 텍스트 색상 */
    --text-navbar-dropdown-item-hover: #ffffff; /* 네비바 드롭다운 아이템 호버 시 텍스트 색상 */

    --bg-primary: #ffffff; /* 일반 배경 색상 (부트스트랩 기본) */
    --bg-light-gray: #eaeaea; /* bg-light-gray용 */
    --bg-header-id-card: #E0E0E0; /* header-id-card 배경색 */
    --bg-highlight: #f8f9fa; /* highlight 배경색 */
    --bg-header-table: #f8f9fa; /* header-bg-light-gray 배경색 */
    --bg-toast: rgba(0, 0, 0, 0.5); /* 토스트 배경 */
    --bg-loader: rgba(255, 255, 255, 0.5); /* 로더 배경색 */

    --highlight-yellow: #ffe400; /* 하이라이터 기본 색상 */
    --highlight-info: rgba(52, 152, 219, 0.3); /* 정보 하이라이터 색상 */
    --highlight-success: rgba(24, 188, 156, 0.3); /* 성공 하이라이터 색상 */

    --loader-border-color: #3498db; /* 로더 상단 테두리 색상 */
    --toast-text-color: #ffffff; /* 토스트 텍스트 색상 */
    --toast-close-btn-filter: brightness(0) invert(1); /* 토스트 닫기 버튼 필터 */
    --sidebar-btn-close-filter: invert(100%); /* 사이드바 닫기 버튼 필터 */
    --scrollbar-thumb-color: #888; /* 스크롤바 썸 색상 */
    --scrollbar-thumb-hover-color: #555; /* 스크롤바 썸 호버 색상 */

    /* 부트스트랩 오버라이드 변수 (기존 값 유지) */
    --bs-nav-link-padding-x: 1.5rem;
    --bs-link-color: var(--text-link); /* 부트스트랩 링크 색상을 우리가 정의한 변수로 연결 */
    --bs-card-spacer-y: 0rem;
    --bs-card-spacer-x: 0rem;
    --bs-navbar-padding-x: 1rem;
    --bs-navbar-padding-y: 0.3rem;
    --bs-gutter-x: 0;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* --- 다크 모드 색상 변수 재정의 --- */
        --text-primary: #e9ecef; /* 일반 텍스트 밝게 변경 */
        --text-secondary: #adb5bd; /* 폼 라벨, 특정 어두운 텍스트용 밝게 변경 */
        --text-link: #9ec5fe; /* 다크 모드에서 잘 보이는 밝은 링크 색상 */
        --text-active-sidebar-link: #6daffb; /* 사이드바 활성 링크 다크 모드에서 잘 보이게 */
        --text-navbar-dropdown-item: #e9ecef; /* 네비바 드롭다운 아이템 텍스트 색상 밝게 변경 */
        --text-navbar-dropdown-item-hover: #212529; /* 네비바 드롭다운 아이템 호버 시 텍스트 색상 어둡게 변경 (대비) */

        --bg-primary: #212529; /* 일반 배경 어둡게 변경 */
        --bg-light-gray: #343a40; /* 다크 모드용 어두운 회색 */
        --bg-header-id-card: #343a40; /* 다크 모드용 어두운 회색 */
        --bg-highlight: #343a40; /* 다크 모드용 어두운 회색 */
        --bg-header-table: #343a40 !important; /* 다크 모드용 어두운 회색 */
        --bg-toast: rgba(255, 255, 255, 0.2); /* 토스트 배경 밝게 변경 */
        --bg-loader: rgba(33, 37, 41, 0.5); /* 로더 배경 어둡게 변경 */

        --highlight-yellow: #5a5400; /* 다크 모드용 하이라이트 노란색 (조정 필요시) */
        --highlight-info: rgba(94, 192, 240, 0.3); /* 다크 모드용 정보 하이라이트 */
        --highlight-success: rgba(64, 218, 186, 0.3); /* 다크 모드용 성공 하이라이트 */

        --loader-border-color: #6daffb; /* 로더 상단 테두리 색상 밝게 변경 */
        --toast-text-color: #212529; /* 토스트 텍스트 색상 어둡게 변경 */
        --toast-close-btn-filter: none; /* 토스트 닫기 버튼 필터 제거 (배경 밝아지면 필요 없음) */
        --sidebar-btn-close-filter: none; /* 사이드바 닫기 버튼 필터 제거 (배경 어두워지면 필요 없음) */
        --scrollbar-thumb-color: #adb5bd; /* 스크롤바 썸 색상 밝게 변경 */
        --scrollbar-thumb-hover-color: #6c757d; /* 스크롤바 썸 호버 색상 밝게 변경 */
    }
}

/* ------------------------------------------------------------- */
/* 기존 코드에서 색상 변수 적용 (또는 하드코딩된 색상 제거)             */
/* ------------------------------------------------------------- */

body {
    font-size: .875rem;
    color: var(--text-primary); /* 텍스트 색상 변수 적용 */
    background-color: var(--bg-primary); /* 배경 색상 변수 적용 */
}

.bi {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.fs-7 {
    font-size: .9em;
}

.fs-8 {
    font-size: .875em;
}

.fs-default {
    font-size: .875rem;
}

.very-small {
    font-size: 12px;
}

.card {
    --bs-card-spacer-y: 0rem;
    --bs-card-spacer-x: 0rem;
}

.q-button {
    width: 100px;
}

.form-label {
    font-size: 0.875em;
    font-weight: 700;
    color: var(--text-secondary); /* 변수 적용 */
}

.btn-small {
    min-width:100px; --bs-btn-padding-y: .325rem; --bs-btn-padding-x: .65rem; --bs-btn-font-size: .765rem;
}

.btn-tinysmall {
    --bs-btn-padding-y: .1rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .65rem;
}

.cursor-pointer {
    cursor: pointer;
}

.container-960 {
    max-width: 960px;
    margin-left: 0;
}

.highlight {
    padding: 1.5rem;
    background-color: var(--bg-highlight); /* 변수 적용 */
}

.highlighter {
    background-color: var(--highlight-yellow);
    position: relative;
    box-shadow: 4px 0 0 0 var(--highlight-yellow), -4px 0 0 0 var(--highlight-yellow);
}
.highlighter-half { background:linear-gradient(to top, var(--highlight-yellow) 50%, transparent 50%); }
.highlighter-info { background-color: var(--highlight-info); }
.highlighter-info-half { background: linear-gradient(to top, var(--highlight-info) 50%, transparent 50%); }
.highlighter-success { background-color: var(--highlight-success); }
.highlighter-success-half { background: linear-gradient(to top, var(--highlight-success) 50%, transparent 50%); }
.underline-wavy { text-decoration: var(--highlight-yellow) wavy underline; }

.custom-hyphen {
    background-color: transparent;
    border: none;
}

.cal-btn {
    align-items: initial;
}

.bg-light-gray {
    background-color: var(--bg-light-gray); /* 변수 적용 */
}

/*
 * Sidebar
 */

@media (max-width: 768px) {
    .sidebar {
        width: 0;
    }
    #sidebarMenu{
        width: 100% !important;
    }
}

.sidebar .btn-close {
    filter: var(--sidebar-btn-close-filter); /* 변수 적용 */
}

.sidebar .nav-link {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-primary); /* 사이드바 링크 텍스트 색상도 변수 적용 */
}

.sidebar .nav-link.active {
    color: var(--text-active-sidebar-link); /* 활성 링크 색상 변수 적용 */
}

.sidebar-heading {
    font-size: .875rem;
    font-weight: 700;
    color: var(--text-primary); /* 사이드바 헤딩 텍스트 색상도 변수 적용 */
}

#sidebarMenu{
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 265px;
}

.offcanvas-body {
    flex-grow: 1;
    overflow-y: auto;
}

.offcanvas-body::-webkit-scrollbar {
    width: 8px;
}

.offcanvas-body::-webkit-scrollbar-track {
    border-radius: 10px;
    background: transparent; /* 스크롤바 트랙 배경은 투명하게 유지 */
}

.offcanvas-body::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-color); /* 변수 적용 */
    border-radius: 10px;
}

.offcanvas-body::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover-color); /* 변수 적용 */
}

.offcanvas-body {
    scrollbar-width: thin;
}

.header-id-card {
    background-color: var(--bg-header-id-card); /* 변수 적용 */
    display: none;
}

@media (min-width: 768px) {
    .sidebar {
        min-height: 100vh;
    }
    .sidebar .offcanvas-lg {
        position: sticky;
        top: 48px;
    }
    .header-id-card {
        display: block;
    }
}

.nav {
    --bs-nav-link-padding-x: 1.5rem;
}

.bi-chevron-down {
    margin-left: auto;
}

.accordion-button::after {
    margin-left: 0;
}

.accordion-button.collapsed .bi-chevron-down {
    transform: rotate(0); /* 접혔을 때 아이콘의 방향 */
    transition: transform 0.3s ease;
}

.accordion-button .bi-chevron-down {
    transform: rotate(180deg); /* 펼쳐졌을 때 아이콘의 방향 */
    transition: transform 0.3s ease;
}

/* 위아래 이동 버튼 */
.button-container {
    display: flex;
    flex-direction: row;
    position: fixed;
    left: auto;
    right: 16px;
    bottom: 16px;
    z-index: 100;
}
.button-container .btn {
    margin-right: 5px;
}
.button-container .btn:last-child {
    margin-right: 0;
}


/*
 * Navbar
 */

.navbar .form-control {
    padding: .75rem 1rem;
}

.navbar .dropdown-menu .dropdown-item {
    color: var(--text-navbar-dropdown-item); /* 변수 적용 */
}

.navbar .dropdown-menu .dropdown-item:hover {
    color: var(--text-navbar-dropdown-item-hover); /* 변수 적용 */
}

/*
 * Table
 */
.table-sm {
    font-size: .875em;
}
.table-sm input[type="checkbox"] {
    margin: 3px 3px 3px 4px;
}
.header-bg-light-gray {
    background-color: var(--bg-header-table) !important; /* 변수 적용 */
}

/*
 * Datepicker
 */
.datepicker-controls button {
    border: none;
    padding: .75rem;
}

/*
 * Page Navigation
 */
.page-navigation-container {
    display: flex; justify-content: center; align-items: center;position:relative;
    min-height: 35px;
}
.div-total-record {
    position: absolute; right: 0; top: 0;
}
.div-show-rows {
    position: absolute; left: 0; top: 0;
}

/* login */
.logo-badge-wrapper {
    display: inline-block; position: relative; bottom: 1em;
}
.logo-badge-wrapper .superscript {
    position: relative; left:10px; top:-10px;
}

/* Print */
.print-only {
    display: none !important;
}
@media print {
    .sidebar {
        display: none;
        width: 0;
    }
    main {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    body {
        font-size: 12pt;
    }
    .noprint {
        display: none;
    }
    .print-only {
        display: block !important;
    }
    .ms-sm-auto {
        margin-left: 0 !important;
    }
    .table-responsive-scroll table {
        min-width: auto !important;
        width: 100% !important;
    }
}

/* Loader */
.loader {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-loader); /* 변수 적용 */
    z-index: 1000;
}

.loader::after {
    content: "";
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    margin-top: -20px;
    border: 5px solid #f3f3f3; /* 이 부분은 다크모드에서도 잘 보이는 회색으로 유지 */
    border-top: 5px solid var(--loader-border-color); /* 변수 적용 */
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

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

/* 큰 화면에서 로더 아이콘 위치 조정 */
@media (min-width: 768px) {
    .loader::after {
        left: calc(50% + (16.66666667% / 2));
        top: 50%;
        margin-left: -20px;
        margin-top: -20px;
    }
}

/* 작은 화면에서 전체 화면에 로더 표시 */
@media (max-width: 767.98px) {
    .loader {
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
    }
    .loader::after {
        left: 50%;
        top: 50%;
        margin-left: -20px;
        margin-top: -20px;
    }
}

/* 모달창 스타일 */
.draggable-modal .modal-dialog {
    position: fixed;
    left: 50%;
    top: 10%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    width: 720px;
}

/* Toast popup */
/* Toast container to center it properly */
#toast-container {
    transform: translateX(-50%);
}

/* Customizing the toast */
.toast {
    background-color: var(--bg-toast); /* 변수 적용 */
    border: none;
    box-shadow: none;
    backdrop-filter: blur(10px);
    color: var(--toast-text-color); /* 변수 적용 */
}

/* Adjusting the toast-body for better spacing and alignment */
.toast-body {
    padding: 0.75rem 1.25rem;
    text-align: center;
    right: 0.5rem;
    top: 0.5rem;
}

/* Customizing the close button */
.toast .btn-close {
    filter: var(--toast-close-btn-filter); /* 변수 적용 */
    opacity: 0.8;
}

/* Optional: Adjusting the button hover state */
.toast .btn-close:hover {
    opacity: 1;
}

/* 테이블 최소 너비 유지 스크롤 */
.table-responsive-scroll {
    width:100%;
    overflow-x:auto;
}

.table-responsive-scroll table {
    min-width:1024px;
}

@media (max-width: 600px) {
    .table-responsive-scroll {
        width: calc(100vw - 10px);
    }
}

.pre-line{ white-space: pre-line; }

/*bootstrap custom*/
.navbar { --bs-navbar-padding-x: 1rem; --bs-navbar-padding-y: 0.3rem; }
.container-fluid { --bs-gutter-x: 0; }

#scrollToTopBtn, #scrollToBottomBtn {
    border-radius: 45%;
}

/* Tooltip */
.tooltip-bg-tr {--tt-bg: rgb(44 62 80 / 59%);}
.tooltip-bg-tr .tooltip-inner {background-color: var(--tt-bg);}
.tooltip-bg-tr.bs-tooltip-top .tooltip-arrow::before {border-top-color: var(--tt-bg);}
.tooltip-bg-tr.bs-tooltip-bottom .tooltip-arrow::before {border-bottom-color: var(--tt-bg);}
.tooltip-bg-tr.bs-tooltip-start .tooltip-arrow::before {border-left-color: var(--tt-bg);}
.tooltip-bg-tr.bs-tooltip-end .tooltip-arrow::before {border-right-color: var(--tt-bg);}
