/* 전체 레이아웃, 사이드바, 카드, 테이블 등 프로젝트 공통 스타일 정의 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

/* ==============================
   웹 폰트 (Web Fonts) 정의
============================== */
@font-face {
    font-family: 'Pretendard';
    src: url('../fonts/PretendardVariable.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'RIDIBatang';
    src: url('../fonts/RIDIBatang.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SILEOT';
    src: url('../fonts/SILEOT.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'GalSIL';
    src: url('../fonts/GalSILR.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==============================
   전역 초기화 및 기본 설정
============================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --sidebar-width: 270px;
    --header-height: 56px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
    --radius: 8px;
    --transition: 0.2s ease;
}

body {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 14px;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* ==============================
   전체 레이아웃 래퍼
============================== */
#wrapper {
    display: flex;
    min-height: 100vh;
}

/* ==============================
   사이드바
============================== */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition);
}

#sidebar .sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid #334155;
}

#sidebar .sidebar-header h5 {
    font-size: 26px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 4px;
}

#sidebar .sidebar-header small {
    font-size: 18px;
    color: #94a3b8;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
}

.sidebar-menu li a {
    display: block;
    padding: 8px 20px;
    font-size: 18px;
    color: var(--sidebar-text);
    transition: background var(--transition), color var(--transition);
    border-radius: 0;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background-color: var(--sidebar-hover);
    color: #f8fafc;
}

.sidebar-menu li a.active {
    background-color: var(--sidebar-active);
}

.sidebar-menu .menu-section {
    padding: 10px 20px 6px;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-top: 8px;
    border-top: 1px solid #334155;
}

/* 첫 번째 menu-section(대시보드 바로 아래)은 margin-top 줄임 */
.sidebar-menu li:nth-of-type(2).menu-section {
    margin-top: 4px;
}

/* ==============================
   콘텐츠 래퍼
============================== */
#content-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==============================
   상단 헤더
============================== */
#top-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left .page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
}

#sidebar-toggle .bar {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-main);
    transition: var(--transition);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.manager-info {
    font-size: 15px;
    color: var(--text-muted);
}

.btn-header {
    padding: 5px 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-header:hover { background-color: var(--bg-main); }
.btn-logout { border-color: var(--danger); color: var(--danger); }
.btn-logout:hover { background-color: #fef2f2; }

/* ==============================
   메인 콘텐츠 영역
============================== */
#main-content {
    padding: 20px;
    flex: 1;
}

/* ==============================
   공통 카드
============================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    background-color: #f8fafc;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-body { padding: 16px; }

/* 요약 카드 (대시보드 / 합계 표시용) */
.summary-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-md);
}

.summary-card .label {
    font-size: 12px;
    opacity: 0.85;
    margin-bottom: 4px;
}

.summary-card .value {
    font-size: 22px;
    font-weight: 700;
}

/* ==============================
   공통 테이블
============================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.tbl thead th {
    background-color: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.tbl tbody tr:hover { background-color: #f8fafc; }

.tbl tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-color);
}

.tbl tbody tr:last-child td { border-bottom: none; }

.tbl tbody tr.selected td { background-color: #eff6ff; }

/* 오른쪽 정렬 (금액 컬럼) */
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ==============================
   공통 버튼
============================== */
.btn-primary {
    background-color: var(--primary);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    cursor: pointer;
    transition: background var(--transition);
}

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

.btn-secondary {
    background-color: var(--secondary);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-secondary:hover { background-color: #475569; }

.btn-danger {
    background-color: var(--danger);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 12.5px;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-danger:hover { background-color: #b91c1c; }

.btn-success {
    background-color: var(--success);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 12.5px;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ==============================
   공통 폼 요소
============================== */
.form-group { margin-bottom: 12px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13.5px;
    transition: border var(--transition);
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

/* ==============================
   이름 자동완성 드롭다운
============================== */
.autocomplete-dropdown {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 2000;
    max-height: 200px;
    overflow-y: auto;
    min-width: 200px;
}

.autocomplete-dropdown .ac-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13.5px;
    transition: background var(--transition);
}

.autocomplete-dropdown .ac-item:hover { background-color: #eff6ff; }

/* ==============================
   페이지네이션
============================== */
.pagination-wrap {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* ==============================
   하단 푸터
============================== */
#main-footer {
    padding: 12px 20px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    text-align: center;
}

/* ==============================
   로딩 오버레이
============================== */
#loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

#loading-overlay.show { display: flex; }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ==============================
   Select2 커스텀 오버라이드
============================== */
.select2-container--default .select2-selection--single {
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 32px;
    font-size: 13.5px;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 32px;
}

/* ==============================
   Flatpickr 커스텀 오버라이드
============================== */
.flatpickr-input {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
}

/* ==============================
   반응형: 사이드바 축소
============================== */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #content-wrapper { margin-left: 0; }
}
