/* ============================================
   Brand Color System
   ============================================ */
:root {
    --brand-action: #F68026;
    --primary-dark: #0E2F2E;
    --primary-soft: #1F5F5B;
    --background: #F3FBFA;
    --surface-card: #FFFFFF;
    --text-primary: #0B1F1E;
    --text-secondary: #4C6B68;
    --divider: #D6E5E3;

    /* Status Colors */
    --status-progress: #1F5F5B;
    --status-complete: #059669;
    --status-permission: #7C3AED;
    --status-repeat: #2563EB;

    /* Priority Colors */
    --priority-normal: #1F5F5B;
    --priority-important: #F68026;
    --priority-urgent: #DC2626;
}

/* ============================================
   Base Styles
   ============================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    white-space: nowrap;
    margin: 0;
    background-color: var(--background);
    color: var(--text-primary);
}

/* 모달이 열릴 때 페이지 스크롤바가 사라지면서 상단 고정 네비게이션(#base_nav)과
   본문이 좌우로 흔들리는(화면이 가로로 늘어나는) 현상 방지.
   - 세로 스크롤바를 항상 표시해 모달 오픈/클로즈 시 뷰포트 폭 변화를 없앤다.
   - scrollbar-gutter 로 스크롤바 영역을 예약(미지원 브라우저 대비 이중화).
   - 부트스트랩이 모달 오픈 시 body 에 추가하는 overflow/padding-right 보정을 무력화한다. */
html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body.modal-open {
    overflow: visible !important;
    padding-right: 0 !important;
}

/* ============================================
   Navigation - Top Header
   ============================================ */
#base_nav {
    position: fixed;
    width: 100%;
    z-index: 999;
}

#aside_nav {
    display: flex;
    align-items: center;
    position: relative;
    background: linear-gradient(180deg,
        #FFFFFF 0%,
        #FDFEFE 50%,
        #FAFBFC 100%);
    border-bottom: 1px solid rgba(220,225,230,0.3);
    box-shadow: 0 1px 0 0 rgba(255,255,255,1) inset,
                0 1px 4px -1px rgba(0,0,0,0.03);
    padding: 20px 16px;
    /* 내용이 폭을 넘치면 헤더 안에서만 가로 스크롤 (페이지 전체 스크롤/잘림 방지). 서브메뉴는 #nav_sub 에 따로 있어 잘리지 않음 */
    overflow-x: auto;
    overflow-y: hidden;
}

#aside_nav > a > img {
    height: 60px;
    margin-top: -8px;
}

/* 우측 문의게시판 / 사용자 버튼 (미디어 쿼리에서 크기 조절) */
.nav_action_btn {
    min-width: 100px;
    padding: 10px 18px;
    font-size: 14px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 아이콘은 축소 브레이크포인트에서만 표시 */
.nav_action_btn .nav_action_icon {
    display: none;
    font-size: 20px;
}

.aside_btn {
    position: relative;
    isolation: isolate;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    margin-left: 12px;
    margin-right: 12px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.aside_btn:hover {
    color: var(--brand-action);
}

.aside_btn.aside_btn_selected::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 4px;
    left: 6px;
    right: 6px;
    background-color: rgba(246, 128, 38, 0.15);
    border-radius: 8px;
    z-index: -1;
    pointer-events: none;
}

/* ============================================
   Sub Navigation
   ============================================ */
#nav_sub {
    position: relative;
    height: 0;
    overflow-y: hidden;
    transition: height 0.25s ease;
    border-bottom: 1px solid var(--divider);
    background-color: rgba(255, 255, 255, 0.96);
}

.nav_sub_div {
    display: flex;
    padding-top: 80px;
    padding-left: 50px;
    padding-bottom: 30px;
    gap: 2rem;
}

ul {
    list-style: none;
    padding: 0;
}

.aside_btn_choice {
    display: none;
}

.nav_sub_div_sub_title {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-soft));
    padding: 6px 12px;
    font-size: 0.95em;
    font-weight: 600;
    text-align: center;
    min-width: 160px;
    color: white;
    border-radius: 8px;
    margin-bottom: 8px;
}

/* ============================================
   Main Content
   ============================================ */
#main {
    padding-top: 85px;
    background-color: var(--background);
    min-height: 100vh;
}

#content_load {
    padding: 20px 10px 10px;
}

/* ============================================
   Loading
   ============================================ */
#modal_loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

#modal_loading > #spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.my-indicator {
    display: none;
}

.htmx-request .my-indicator {
    display: inline;
}

.htmx-request.my-indicator {
    display: inline;
}

/* ============================================
   Section Titles
   ============================================ */
.sub_title {
    border-left: 5px solid black;
    font-weight: bold;
    height: 36px;
    display: flex;
    align-items: center;
    padding-left: 10px;
}

.li_title {
    margin-top: 20px;
    border-left: 5px solid slategray;
    display: flex;
    align-items: center;
    padding-left: 10px;
}

/* ============================================
   Cards & Containers
   ============================================ */
.search_box {
    border-radius: 10px;
    margin: 4px auto auto;
    padding-bottom: 8px;
}

.content_li {
    border-radius: 10px;
    border: 2px solid ghostwhite;
    padding: 5px;
    margin-top: 6px;
    overflow-x: hidden !important;
}

/* ============================================
   Data Tables
   ============================================ */
.my_table_data {
    font-size: 13px;
    box-sizing: border-box;
    text-align: center;
    width: 100%;
    margin-top: 1rem;
    border-spacing: 0;
    border-collapse: separate;
}

.my_table_data th,
.my_table_data td {
    border: 1px solid #d1dae7;
    padding: 4px;
    text-overflow: ellipsis;
    max-width: 160px;
    overflow: hidden;
    height: 32px;
}

.my_table_data tbody {
    vertical-align: inherit;
}

.my_table_data th {
    background-color: #e2e5e9;
    color: rgb(128, 128, 128);
}

/* 서버 정렬 헤더 (sort_th.html): 클릭 가능 표시 + 정렬 방향 화살표 */
.my_table_data th.sort_th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.my_table_data th.sort_th:hover {
    color: var(--text-primary);
}

.my_table_data th.sort_th .sort_arrow {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.35;
}

.my_table_data th.sort_th.sort_active {
    color: var(--text-primary);
}

.my_table_data th.sort_th.sort_active .sort_arrow {
    opacity: 1;
    color: var(--brand-action);
}

/* overflow-auto 컨테이너 안의 테이블 thead 고정 (스크롤 시 헤더 가림 방지) */
.overflow-auto .my_table_data thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.my_table_data td {
    background-color: #ffffff;
}

.my_table_data.tr_hover tbody tr:hover {
    background-color: #f9f9f9;
    cursor: pointer;
}

/* 행 hover 시 td 배경 투명하게 (행 배경색 보이게) */
.my_table_data.tr_hover tbody tr:hover td {
    background-color: transparent;
}

/* 선택된 행 (tr_active 클릭 시) td 배경 투명하게 */
.my_table_data tbody tr[style*="background-color"] td {
    background-color: transparent !important;
}

/* ============================================
   Input Tables
   ============================================ */
.my_table_input {
    font-size: 13px;
    box-sizing: border-box;
    width: 100%;
    margin-top: 1rem;
    border-spacing: 0;
    border-collapse: separate;
}

.my_table_input th,
.my_table_input td {
    border: 1px solid #d1dae7;
    height: 35px;
}

.my_table_input th {
    background-color: #e2e5e9;
    color: rgb(128, 128, 128);
    text-align: center;
}

.my_table_input td {
    background-color: #ffffff;
    padding: 0;
}

.my_table_data td {
    padding: 4px 8px;
}

/* 모든 테이블 셀 안의 input/select가 셀 전체를 채우도록 */
table td input,
table td select,
table td textarea,
table td .form-control,
table td .form-select {
    width: 100%;
    height: 100%;
    min-height: 30px;
    border: none;
    background-color: transparent;
    padding: 4px 8px;
    box-sizing: border-box;
    border-radius: 0;
}

table td input:focus,
table td select:focus,
table td textarea:focus,
table td .form-control:focus,
table td .form-select:focus {
    outline: none;
    box-shadow: none;
    background-color: #fffef0;
}

/* 달력 내 비활성화 입력 필드 - 둥근 모서리 */
table td input:disabled,
table td input[disabled] {
    border-radius: 4px;
    background-color: #e9ecef;
}

.col_min {
    min-width: 130px !important;
}

.cell_hover {
    cursor: pointer;
    transition: all 0.2s ease;
}

.cell_hover:hover {
    background-color: #f9f9f9;
}

.cell_hover_none {
    cursor: default !important;
}

.page_active {
    color: var(--surface-card) !important;
    background-color: var(--primary-soft) !important;
}

.page_active:hover {
    color: var(--surface-card) !important;
    background-color: var(--primary-soft) !important;
}

#tab_load {
    margin-top: 12px;
}

/* 탭 컨텐츠 내 버튼 박스 간격 */
.tab-content .button_box,
.tab-pane .button_box {
    margin-top: 12px;
    margin-bottom: 8px;
}

/* 연속된 버튼 박스 사이 간격 */
.button_box + .button_box {
    margin-top: 8px;
}

/* ============================================
   Form Elements
   ============================================ */
.readonly_text {
    border: 1px solid var(--divider) !important;
    height: 36px !important;
    padding: 0.25rem 0.75rem !important;
    border-radius: 0 !important;
    font-weight: 400 !important;
    background-color: #ffffff;
}

.select2-selection--single {
    height: 100% !important;
    border: 1px solid var(--divider) !important;
    border-radius: 0 !important;
}

.select2-selection__arrow {
    display: none !important;
}

/* 조회 필터 영역 폼 요소 직사각형 */
.search_box .form-control,
.search_box .form-select,
.search_box input,
.search_box select {
    border-radius: 0 !important;
}

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

/* ============================================
   Datatable / Tabulator
   ============================================ */
#datatable_load {
    margin-top: 20px;
}

.tabulator {
    border: 1px solid var(--divider) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.tabulator-col-content {
    background-color: #e2e5e9;
}

.tabulator-row.tabulator-selectable:hover {
    background-color: #f9f9f9;
}

.tabulator-col-title {
    text-align: center;
    color: rgb(128, 128, 128);
    font-weight: 600;
}

.tabulator-edit-list-item.focused {
    color: #fff;
    background: var(--primary-soft);
}

/* ============================================
   Bootstrap Overrides
   ============================================ */
.btn-group .input-group {
    flex-wrap: nowrap;
}

/* 모든 btn-sm 버튼 크기 통일 */
.btn.btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
    border-radius: 6px !important;
}

/* Primary Button */
.btn-primary {
    background-color: var(--primary-soft);
    border-color: var(--primary-soft);
    font-weight: 500;
    transition: all 0.2s ease;
}

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

/* Warning/Action Button */
.btn-warning {
    background-color: var(--brand-action);
    border-color: var(--brand-action);
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-warning:hover {
    background-color: #E5721F;
    border-color: #E5721F;
    color: white;
}

/* Danger Button */
.btn-danger {
    background-color: #DC2626;
    border-color: #DC2626;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background-color: #B91C1C;
    border-color: #B91C1C;
    color: white;
}

/* Outline Primary Button - 조회 버튼 (슬레이트 블루) */
.btn-outline-primary {
    background-color: #475569;
    border-color: #475569;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-outline-primary:hover {
    background-color: #334155;
    border-color: #334155;
    color: white;
}

/* Print Button - 출력 버튼 (다크 틸) */
.btn-print {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-print:hover {
    background-color: #0A2423;
    border-color: #0A2423;
    color: white;
}

/* Excel Button - 엑셀 버튼 (녹색) */
.btn-excel {
    background-color: #217346;
    border-color: #217346;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-excel:hover {
    background-color: #1a5c38;
    border-color: #1a5c38;
    color: white;
}

/* Outline Dark Button - 기타 버튼 (파란색) */
.btn-outline-dark {
    background-color: #3B82F6;
    border-color: #3B82F6;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-outline-dark:hover {
    background-color: #2563EB;
    border-color: #2563EB;
    color: white;
}

/* Secondary Button - 일반 탭 (흰색 배경) */
.btn-secondary,
.btn-outline-secondary {
    background-color: white;
    border: 1px solid #dee2e6;
    color: #495057;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover,
.btn-outline-secondary:hover {
    background-color: white !important;
    border-color: #dee2e6 !important;
    color: #495057 !important;
}

/* 탭 버튼 호버 시 배경색 유지 */
.btn-check + .btn-outline-secondary:hover {
    background-color: white !important;
    border-color: #dee2e6 !important;
    color: #495057 !important;
}

/* 선택된 탭 스타일 (진한 회색) */
/* data-bs-toggle="tab" 방식(.active)도 btn-check 방식과 동일하게 보이도록 함께 지정 */
.btn-check:checked + .btn-outline-secondary,
.btn-check:checked + .btn-outline-secondary:hover,
.btn-group > .btn-outline-secondary.active,
.btn-group > .btn-outline-secondary.active:hover {
    background-color: #495057 !important;
    border-color: #495057 !important;
    color: white !important;
}

/* Cards */
.card {
    border: 1px solid var(--divider);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Modals */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--divider);
    background-color: var(--background);
    border-radius: 16px 16px 0 0;
}

/* Readonly 요소 스타일 */
select[readonly],
input[readonly],
textarea[readonly],
.form-control[readonly],
.form-select[readonly] {
    background-color: #ffffff !important;
    pointer-events: none;
}

.flatpickr-input[readonly] {
    pointer-events: auto;
    cursor: pointer;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--divider);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   Menu Search
   ============================================ */
.menu-search-container {
    position: relative;
    margin-right: 8px;
}

.menu-search-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--background);
    border: 1px solid var(--divider);
    border-radius: 12px;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.menu-search-input-wrapper:focus-within {
    border-color: var(--primary-soft);
    box-shadow: 0 0 0 3px rgba(31, 95, 91, 0.1);
}

.menu-search-icon {
    color: var(--text-secondary);
    font-size: 20px;
    margin-right: 8px;
}

.menu-search-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    width: 180px;
}

.menu-search-input::placeholder {
    color: var(--text-secondary);
}

/* ============================================
   Header responsive
   헤더 자연 폭: 로고 203 + 메뉴 2줄 1138 + 우측 검색/버튼 460 = 약 1,820px.
   #base_nav 가 fixed 라 헤더 높이는 유지하고(줄바꿈 없음) 폭만 줄인다.
   ============================================ */
/* 컴팩트: FHD 미만 ~ 1,600 모니터 */
@media (max-width: 1850px) {
    #aside_nav .aside_btn {
        font-size: 16px;
        margin-left: 8px;
        margin-right: 8px;
        padding: 8px 8px;
    }
    .menu-search-input {
        width: 120px;
    }
    .nav_action_btn {
        min-width: 80px;
        padding: 10px 14px;
    }
}

/* 축소: 1,366 노트북. 검색창은 아이콘만 두고 포커스 시 펼침 */
@media (max-width: 1500px) {
    #aside_nav {
        padding: 20px 12px;
    }
    #aside_nav > a > img {
        height: 50px;
    }
    #aside_nav .aside_btn {
        font-size: 15px;
        margin-left: 3px;
        margin-right: 3px;
        padding: 8px 6px;
    }
    /* 컨테이너는 아이콘 크기로 고정, 펼친 입력창은 absolute 로 왼쪽 메뉴 위에 겹쳐서 헤더 폭을 밀지 않게 */
    .menu-search-container {
        margin-right: 4px;
        width: 42px;
        height: 42px;
    }
    .menu-search-input-wrapper {
        padding: 8px 10px;
        position: absolute;
        top: 0;
        right: 0;
        background-color: var(--surface-card, #fff);
    }
    .menu-search-input-wrapper:focus-within {
        z-index: 10;
    }
    .menu-search-icon {
        margin-right: 0;
        cursor: pointer;
    }
    .menu-search-input {
        width: 0;
        padding: 0;
        transition: width 0.2s ease;
    }
    .menu-search-input-wrapper:focus-within .menu-search-input {
        width: 140px;
        margin-left: 8px;
    }
    /* 문의게시판/사용자 버튼은 아이콘만 (title 로 툴팁) */
    .nav_action_btn {
        min-width: 0;
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 50%;
    }
    .nav_action_btn .nav_action_label {
        display: none;
    }
    .nav_action_btn .nav_action_icon {
        display: inline-block;
    }
}

.menu-search-shortcut {
    background-color: var(--divider);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    margin-left: 8px;
    border: none;
}

.menu-search-results {
    position: fixed;
    top: 80px;
    right: 280px;
    background-color: var(--surface-card);
    border: 1px solid var(--divider);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 9999;
    min-width: 320px;
    width: 320px;
}

.menu-search-results.show {
    display: block;
}

.menu-search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--divider);
}

.menu-search-item:last-child {
    border-bottom: none;
}

.menu-search-item:hover,
.menu-search-item.selected {
    background-color: var(--background);
}

.menu-search-item.selected {
    background-color: rgba(31, 95, 91, 0.1);
}

.menu-search-item-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.menu-search-item-text mark {
    background-color: rgba(246, 128, 38, 0.3);
    color: var(--text-primary);
    padding: 0 2px;
    border-radius: 2px;
}

.menu-search-item-category {
    font-size: 12px;
    color: var(--text-secondary);
    background-color: var(--background);
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.menu-search-no-result {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================
   교통민원접수대장 - 좌우 테이블 높이 맞춤
   ============================================ */
#change_complaints_load {
    display: flex;
    flex-direction: column;
}

#change_complaints_load > form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

#change_complaints_load > form > .overflow-auto,
#change_complaints_load > .overflow-auto {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#change_complaints_load .my_table_input {
    flex-grow: 1;
}

#change_complaints_load .my_table_input tbody {
    height: 100%;
}

#change_complaints_load .my_table_input tbody tr:last-child td {
    height: 100%;
    vertical-align: top;
}

#change_complaints_load .my_table_input tbody tr:last-child td textarea {
    min-height: 100px;
}

/* ============================================
   File Input (ClearableFileInput) 스타일
   ============================================ */
/* 테이블 셀 내 파일 입력 필드 레이아웃 */
table td input[type="file"] {
    width: auto !important;
    height: auto !important;
    min-height: auto !important;
    padding: 4px 8px;
    display: inline-block;
    vertical-align: middle;
}

/* ClearableFileInput 위젯 - 요소들 인라인 배치 */
table td > a,
table td > input[type="checkbox"],
table td > label {
    display: inline;
    vertical-align: middle;
    position: relative;
}

/* br 태그 숨기기 (ClearableFileInput 줄바꿈 방지 - my_table_input 내부만 적용) */
.my_table_input td > br {
    display: none;
}

/* 파일 삭제 체크박스 레이아웃 */
table td input[type="checkbox"] {
    width: auto !important;
    height: auto !important;
    min-height: auto !important;
    margin: 0 4px;
    vertical-align: middle;
}

/* 현재 파일 링크 스타일 */
table td > a {
    margin-right: 12px;
    color: var(--primary-soft);
    text-decoration: none;
    padding: 4px 8px;
}

table td > a:hover {
    text-decoration: underline;
}

/* 삭제 라벨 스타일 */
table td > label[for$="-clear_id"] {
    margin-right: 12px;
    padding: 4px 8px;
}

/* ============================================
   Print Styles
   ============================================ */
/* print 시 배경색/텍스트색 초기화 (UI 스타일이 보고서에 적용되는 것 방지) */
@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
}
