/* ============================================
   WECAR HR Platform - Main Stylesheet
   ============================================ */

/* ============================================
   1. CSS Variables & Design Tokens
   ============================================ */
:root {
  /* Colors */
  --primary-color: #1a1a1a;
  --primary-hover: #000000;
  --secondary-color: #666666;
  --accent-color: #000000;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #17a2b8;
  --purple-color: #6f42c1;
  --teal-color: #20c997;
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-light: #f8f9fa;
  --bg-hover: #f5f5f5;
  --bg-active: #e9ecef;
  
  /* Border Colors */
  --border-color: #e5e5e5;
  --border-light: #f0f0f0;
  --border-dark: #d0d0d0;
  
  /* Text Colors */
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-light: #cccccc;
  
  /* Spacing Scale (8px base) */
  --spacing-xs: 0.25rem;   /* 4px */
  --spacing-sm: 0.5rem;     /* 8px */
  --spacing-md: 1rem;       /* 16px */
  --spacing-lg: 1.5rem;     /* 24px */
  --spacing-xl: 2rem;       /* 32px */
  --spacing-2xl: 3rem;      /* 48px */
  --spacing-3xl: 4rem;      /* 64px */
  
  /* Typography */
  --font-family-base: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */
  
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.15);
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-all: all var(--transition-base);
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-flash-message: 9990;
  --z-error-modal: 9999;
  --z-error-modal-content: 10000;
  
  /* Layout */
  --navbar-height: 64px;
  --footer-height: 60px;
  --container-max-width: 1320px;
  --sidebar-width: 280px;
}

/* ============================================
   2. Base Styles & Reset
   ============================================ */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ============================================
   3. Typography System
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  padding: 0;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

h1 { font-size: var(--font-size-4xl); margin-bottom: var(--spacing-lg); }
h2 { font-size: var(--font-size-3xl); margin-bottom: var(--spacing-md); }
h3 { font-size: var(--font-size-2xl); margin-bottom: var(--spacing-md); }
h4 { font-size: var(--font-size-xl); margin-bottom: var(--spacing-sm); }
h5 { font-size: var(--font-size-lg); margin-bottom: var(--spacing-sm); }
h6 { font-size: var(--font-size-base); margin-bottom: var(--spacing-sm); }

p {
  margin: 0 0 var(--spacing-md) 0;
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition-all);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: none;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

/* ============================================
   4. Layout Components
   ============================================ */

/* Wrapper for sidebar layout */
.wrapper {
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-fixed);
  background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 데스크톱에서 사이드바가 열려있을 때 메인 콘텐츠 마진 */
@media (min-width: 992px) {
  .main-wrapper {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
  }
}

.sidebar-header {
  background: rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
  filter: brightness(0) invert(1);
}

.sidebar-menu {
  padding: 0;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.8) !important;
  padding: 12px 20px;
  margin: 2px 12px;
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  display: flex;
  align-items: center;
}

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff !important;
  transform: translateX(4px);
}

.sidebar .nav-link.active {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.nav-divider {
  margin: 16px 0 8px 0;
}

.nav-divider small {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  opacity: 0.6;
}

/* Main wrapper (content area) */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background-color: var(--bg-secondary);
}

/* Top header */
.top-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
}

/* Main Content Area */
.main-content {
  background-color: var(--bg-secondary);
  min-height: calc(100vh - 80px);
  flex: 1;
}

.container-lg {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
}

/* Page Header */
.page-header {
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.page-header-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.page-header-title h1 {
  margin-bottom: 0;
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.page-content {
  padding-top: var(--spacing-md);
}

/* Section Components */
section {
  margin-bottom: var(--spacing-2xl);
}

section:last-child {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-light);
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.section-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

.section-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

/* Divider */
.section-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: var(--spacing-xl) 0;
  border: none;
}

/* ============================================
   5. Navigation
   ============================================ */
.navbar {
  background-color: var(--bg-primary) !important;
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-sm) 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--navbar-height);
}

.navbar-brand {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xl);
  color: var(--text-primary) !important;
  transition: var(--transition-all);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.navbar-brand:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

.navbar-nav {
  gap: var(--spacing-xs);
}

.navbar-nav .nav-link {
  color: var(--text-secondary) !important;
  font-weight: var(--font-weight-normal);
  padding: var(--spacing-sm) var(--spacing-md) !important;
  transition: var(--transition-all);
  position: relative;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.navbar-nav .nav-link:hover {
  color: var(--text-primary) !important;
  background-color: var(--bg-hover);
}

.navbar-nav .nav-link.active {
  color: var(--text-primary) !important;
  font-weight: var(--font-weight-medium);
  background-color: var(--bg-hover);
}

.navbar-nav .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--spacing-md);
  right: var(--spacing-md);
  height: 2px;
  background-color: var(--primary-color);
  border-radius: var(--radius-full);
}

/* ============================================
   6. Buttons
   ============================================ */
.btn {
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--spacing-sm) var(--spacing-lg);
  transition: var(--transition-all);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  cursor: pointer;
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: var(--font-size-base);
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: #fff;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline-primary {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background-color: transparent;
}

.btn-outline-primary:hover {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.btn-outline-secondary {
  border-color: var(--border-color);
  color: var(--text-secondary);
  background-color: transparent;
}

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

/* ============================================
   7. Cards
   ============================================ */
.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-all);
  background-color: var(--bg-primary);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-dark);
}

.card-header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-md) var(--spacing-lg);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: var(--spacing-lg);
}

.card-footer {
  background-color: var(--bg-light);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-md) var(--spacing-lg);
}

/* Module Card (Dashboard) */
.card-module {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  transition: var(--transition-all);
  cursor: pointer;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card-module:hover,
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
  cursor: pointer;
}

.card-module .icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background-color: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  color: var(--text-primary);
  transition: var(--transition-all);
  flex-shrink: 0;
}

.card-module:hover .icon-wrap {
  background-color: var(--primary-color);
  color: #fff;
}

/* ============================================
   8. Tables
   ============================================ */
.table {
  color: var(--text-primary);
  width: 100%;
  margin-bottom: 0;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th,
.table tbody td {
  min-width: 200px;
  padding: var(--spacing-md) var(--spacing-lg);
  white-space: nowrap;
  word-break: keep-all;
}

.table thead th {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
  padding: var(--spacing-md) var(--spacing-lg);
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  background-color: #f8f9fa;
  vertical-align: middle;
  border-right: 1px solid #dee2e6;
  border-left: 1px solid transparent;
}

.table thead th:first-child {
  border-left: 1px solid #dee2e6;
}

.table thead th:last-child {
  border-right: 1px solid #dee2e6;
}

.table tbody td {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid #e9ecef;
  border-right: 1px solid #e9ecef;
  border-left: 1px solid transparent;
  vertical-align: middle;
}

.table tbody td:first-child {
  border-left: 1px solid #e9ecef;
}

.table tbody td:last-child {
  border-right: 1px solid #e9ecef;
}

.table tbody tr {
  transition: var(--transition-fast);
}

.table tbody tr:nth-child(odd) {
  background-color: #f9fbff;
}

.table .text-wrap {
  white-space: normal;
}

.table .col-actions {
  min-width: 180px;
  width: 180px;
}

.table tbody tr:nth-child(even) {
  background-color: #ffffff;
}

.table tbody tr:hover {
  background-color: #eef3ff;
}

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

/* 고정된 테이블 헤더 스타일 */
.table-sticky thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 1020 !important;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%) !important;
  background-color: #f8f9fa !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 -2px 0 #dee2e6 !important;
  border-bottom: 3px solid #dee2e6 !important; /* 제목행 아래 가로바 */
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #495057;
  padding: var(--spacing-md) var(--spacing-lg);
  vertical-align: middle;
  white-space: nowrap;
}

/* 테이블 헤더 호버 효과 */
.table-sticky thead th:hover {
  background: linear-gradient(180deg, #e9ecef 0%, #dee2e6 100%);
}

/* 테이블 바디 셀에 세로 구분선 추가 */
.table-sticky tbody td {
  border-right: 1px solid #e9ecef;
  border-left: 1px solid transparent;
}

.table-sticky tbody td:first-child {
  border-left: 1px solid #e9ecef;
}

.table-sticky tbody td:last-child {
  border-right: 1px solid #e9ecef;
}

/* 테이블 헤더에도 세로 구분선 추가 */
.table-sticky thead th {
  border-right: 1px solid #dee2e6;
  border-left: 1px solid transparent;
}

.table-sticky thead th:first-child {
  border-left: 1px solid #dee2e6;
}

.table-sticky thead th:last-child {
  border-right: 1px solid #dee2e6;
}

/* 테이블 하단 고정 바 (최하단 가로바) */
.table-sticky tfoot tr:last-child {
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: linear-gradient(180deg, #e9ecef 0%, #f8f9fa 100%);
  background-color: #f8f9fa !important;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1), inset 0 2px 0 #dee2e6;
  border-top: 3px solid #dee2e6; /* 최하단 가로바 */
  font-weight: var(--font-weight-semibold);
}

.table-sticky tfoot td {
  border-right: 1px solid #dee2e6;
  border-left: 1px solid transparent;
  padding: var(--spacing-md) var(--spacing-lg);
}

.table-sticky tfoot td:first-child {
  border-left: 1px solid #dee2e6;
}

.table-sticky tfoot td:last-child {
  border-right: 1px solid #dee2e6;
}

/* 모든 테이블에 제목행 고정화 적용 */
.table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 1020 !important;
  background-color: #f8f9fa !important;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%) !important;
  border-bottom: 3px solid #dee2e6 !important; /* 제목행 아래 가로바 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* table-wrap 내부의 테이블 헤더도 고정 */
.table-wrap .table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 1020 !important;
  background-color: #f8f9fa !important;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%) !important;
  border-bottom: 3px solid #dee2e6 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* 모든 모달이 테이블 헤더(z-index: 1020) 위에 표시되도록 보장 - 최고 우선순위 */
body .modal,
body > .modal,
.modal.fade,
.modal.fade.show,
#addSettingModal,
#addSettingModal.fade,
#addSettingModal.fade.show {
  z-index: 9999 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}

body .modal .modal-dialog,
body > .modal .modal-dialog,
.modal.fade .modal-dialog,
.modal.fade.show .modal-dialog,
#addSettingModal .modal-dialog,
#addSettingModal.fade .modal-dialog,
#addSettingModal.fade.show .modal-dialog {
  z-index: 10000 !important;
  position: relative !important;
  margin: 1.75rem auto !important;
}

body .modal .modal-content,
body > .modal .modal-content,
.modal.fade .modal-content,
.modal.fade.show .modal-content,
#addSettingModal .modal-content,
#addSettingModal.fade .modal-content,
#addSettingModal.fade.show .modal-content {
  z-index: 10000 !important;
  position: relative !important;
}

/* 모달 백드롭도 최상단 설정 */
body .modal-backdrop,
.modal-backdrop.fade,
.modal-backdrop.show {
  z-index: 9998 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}

.table-wrap {
  overflow-x: scroll !important;
  overflow-y: scroll !important;
  position: relative;
  border: 1px solid #dee2e6;
  border-radius: var(--radius-lg);
  background-color: var(--bg-primary);
  max-height: calc(100vh - 300px);
  min-height: 400px;
  height: auto;
  width: 100%;
  /* 스크롤바 항상 표시 (Firefox) */
  scrollbar-width: thin !important;
  scrollbar-color: #888 #f0f0f0 !important;
  /* 스크롤바 항상 표시 (Chrome/Safari) */
  -webkit-overflow-scrolling: touch;
  /* 스크롤바 강제 표시 */
  overflow: -moz-scrollbars-vertical;
  overflow: -moz-scrollbars-horizontal;
  /* 모달이 위에 표시되도록 z-index 설정 (낮게 유지) */
  z-index: 1;
  /* stacking context 문제 방지 - 모달이 위에 표시되도록 */
  contain: layout style paint;
}

/* 테이블 래퍼 내부의 테이블에 추가 스타일 */
.table-wrap table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1200px; /* 최소 너비 설정으로 가로 스크롤 유도 */
  margin-bottom: 0;
}

/* 스크롤 시 헤더와 푸터가 잘 보이도록 */
.table-wrap::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  z-index: 99;
  border-bottom: 3px solid #dee2e6; /* 제목행 아래 가로바 강화 */
  pointer-events: none;
}

.table-wrap::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  z-index: 99;
  border-top: 3px solid #dee2e6; /* 최하단 가로바 강화 */
  pointer-events: none;
}

/* Chrome/Safari용 스크롤바 - 항상 표시 */
.table-wrap::-webkit-scrollbar {
  height: 14px !important;
  width: 14px !important;
  display: block !important;
  -webkit-appearance: none;
}

.table-wrap::-webkit-scrollbar-track {
  background: #f0f0f0 !important;
  border-radius: 7px;
  border: 1px solid #e0e0e0;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #888 !important;
  border-radius: 7px;
  border: 2px solid #f0f0f0;
  min-height: 20px;
  min-width: 20px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #666 !important;
}

.table-wrap::-webkit-scrollbar-corner {
  background: #f0f0f0;
}

/* ============================================
   9. Forms
   ============================================ */
.form-control {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  transition: var(--transition-all);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

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

.form-control::placeholder {
  color: var(--text-muted);
}

.form-label {
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-sm);
  display: block;
}

.form-select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  transition: var(--transition-all);
  font-size: var(--font-size-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.05);
  outline: none;
}

/* ============================================
   10. Alerts & Flash Messages
   ============================================ */
.flash-stack {
  position: relative;
  z-index: var(--z-sticky);
  margin-bottom: var(--spacing-lg);
}

.alert {
  border-radius: var(--radius-md);
  border: none;
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
}

.alert:last-child {
  margin-bottom: 0;
}

/* ============================================
   11. Badges
   ============================================ */
.badge {
  font-weight: var(--font-weight-medium);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  line-height: 1.2;
}

/* ============================================
   12. List Groups
   ============================================ */
.list-group-item {
  border-color: var(--border-color);
  padding: var(--spacing-md) var(--spacing-lg);
  transition: var(--transition-fast);
}

.list-group-item:hover {
  background-color: var(--bg-hover);
}

.list-group-item a {
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

.list-group-item a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

/* ============================================
   13. Modals
   ============================================ */
/* 모든 모달이 최상단에 위치하도록 설정 */
.modal {
  z-index: var(--z-error-modal) !important;
}

.modal.show {
  z-index: var(--z-error-modal) !important;
}

.modal-dialog {
  z-index: var(--z-error-modal-content) !important;
}

.modal.show .modal-dialog {
  z-index: var(--z-error-modal-content) !important;
}

.modal-content {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-error-modal-content) !important;
  position: relative;
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-lg);
}

.modal-body {
  padding: var(--spacing-lg);
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-lg);
}

/* 모달 백드롭 최상단 설정 */
.modal-backdrop {
  z-index: calc(var(--z-error-modal) - 1) !important;
}

.modal-backdrop.show {
  z-index: calc(var(--z-error-modal) - 1) !important;
  opacity: 0.5 !important;
}

/* ============================================
   14. Dropdowns
   ============================================ */
.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-xs);
  margin-top: var(--spacing-xs);
}

.dropdown-item {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-size: var(--font-size-sm);
}

.dropdown-item:hover {
  background-color: var(--bg-hover);
}

/* ============================================
   15. Footer
   ============================================ */
.app-footer {
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-lg) 0;
  margin-top: auto;
  height: var(--footer-height);
  display: flex;
  align-items: center;
}

.footer-content {
  width: 100%;
}

.footer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  margin: 0;
}

/* ============================================
   16. Login Page - Modern Design
   ============================================ */
.login-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  padding: var(--spacing-xl);
  z-index: 9999;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 배경 애니메이션 도형 */
.login-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  animation: float 20s infinite ease-in-out;
  pointer-events: none;
}

.bg-shape-1 {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  top: -200px;
  left: -200px;
  animation-delay: 0s;
}

.bg-shape-2 {
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  bottom: -150px;
  right: -150px;
  animation-delay: 5s;
}

.bg-shape-3 {
  width: 350px;
  height: 350px;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  top: 50%;
  right: -175px;
  animation-delay: 10s;
}

.bg-shape-4 {
  width: 250px;
  height: 250px;
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  bottom: 20%;
  left: -125px;
  animation-delay: 15s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(50px, -50px) scale(1.1); }
  50% { transform: translate(-30px, 30px) scale(0.9); }
  75% { transform: translate(30px, 50px) scale(1.05); }
}

.login-container {
  position: relative;
  z-index: 100000;
  width: 100%;
  max-width: 450px;
  animation: slideUp 0.6s ease-out;
  pointer-events: auto;
}

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

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(255, 255, 255, 0.5);
  padding: 3rem 2.5rem;
  width: 100%;
  position: relative;
  overflow: hidden;
  z-index: 100000;
  pointer-events: auto;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.login-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 1.5rem;
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.login-logo {
  max-width: 140px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
  transition: transform 0.3s ease;
}

.login-logo:hover {
  transform: scale(1.05);
}

.login-title {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: #6b7280;
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0;
}

.login-form {
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 100000;
  pointer-events: auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
  margin-bottom: 0.75rem;
}

.form-label i {
  color: #667eea;
  font-size: 1rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 100000;
  pointer-events: auto;
}

.form-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 0.95rem;
  background: #ffffff;
  transition: all 0.3s ease;
  outline: none;
  color: #1f2937;
  position: relative;
  z-index: 100000;
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
}

.form-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  transform: translateY(-2px);
}

.form-input::placeholder {
  color: #9ca3af;
}

.input-icon {
  position: absolute;
  left: 1rem;
  color: #9ca3af;
  font-size: 1.1rem;
  pointer-events: none;
  transition: color 0.3s ease;
}

.form-input:focus + .input-icon {
  color: #667eea;
}

.password-toggle {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  z-index: 1;
}

.password-toggle:hover {
  color: #667eea;
}

.error-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
}

.error-message i {
  font-size: 1rem;
}

.login-button {
  width: 100%;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  margin-top: 0.5rem;
  position: relative;
  overflow: hidden;
}

.login-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.login-button:hover::before {
  left: 100%;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.login-button:active {
  transform: translateY(0);
}

.login-button i {
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

.login-button:hover i {
  transform: translateX(4px);
}

.login-footer {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.admin-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #6b7280;
  font-size: 0.875rem;
  padding: 0.75rem;
  background: rgba(102, 126, 234, 0.05);
  border-radius: 8px;
}

.admin-info i {
  color: #667eea;
  font-size: 1rem;
}

.admin-info code {
  background: rgba(102, 126, 234, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.85rem;
  color: #667eea;
  font-weight: 600;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .login-wrapper {
    padding: var(--spacing-md);
  }

  .login-card {
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }

  .login-title {
    font-size: 1.75rem;
  }

  .bg-shape {
    filter: blur(60px);
  }

  .bg-shape-1,
  .bg-shape-2,
  .bg-shape-3,
  .bg-shape-4 {
    width: 200px;
    height: 200px;
  }
}

/* 로고 이미지 최적화 */
.sidebar-logo,
.login-logo,
img[src*="lpgo.png"] {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: high-quality;
}

/* ============================================
   17. Utility Classes
   ============================================ */
.gap-xs { gap: var(--spacing-xs) !important; }
.gap-sm { gap: var(--spacing-sm) !important; }
.gap-md { gap: var(--spacing-md) !important; }
.gap-lg { gap: var(--spacing-lg) !important; }
.gap-xl { gap: var(--spacing-xl) !important; }

.mb-section { margin-bottom: var(--spacing-2xl) !important; }
.mt-section { margin-top: var(--spacing-2xl) !important; }

.shadow-hover {
  transition: var(--transition-all);
}

.shadow-hover:hover {
  box-shadow: var(--shadow-md);
}

/* Additional color utilities */
.bg-purple { background-color: var(--purple-color) !important; }
.bg-teal { background-color: var(--teal-color) !important; }
.border-purple { border-color: var(--purple-color) !important; }
.border-teal { border-color: var(--teal-color) !important; }

/* ============================================
   18. Responsive Design
   ============================================ */

/* 반응형 기본 설정 */
* {
  box-sizing: border-box;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* 컨테이너 반응형 최적화 */
.container-fluid {
  width: 100%;
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
}

/* 대형 화면 (1400px 이상) */
@media (min-width: 1400px) {
  .container-fluid {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding-left: var(--spacing-xl);
    padding-right: var(--spacing-xl);
  }
}

/* 중형 화면 (1200px 이상) */
@media (min-width: 1200px) and (max-width: 1399px) {
  .container-fluid {
    max-width: 1140px;
    margin: 0 auto;
  }
}

@media (max-width: 1200px) {
  .container-lg {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
  
  .main-wrapper {
    margin-left: 0;
  }
  
  /* 테이블 반응형 */
  .table-wrap {
    max-height: calc(100vh - 250px);
  }
  
  .table-wrap table {
    min-width: 1000px;
  }
}

@media (max-width: 992px) {
  /* 사이드바 반응형 */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1050;
    box-shadow: none;
  }
  
  .sidebar.show {
    transform: translateX(0);
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
  }
  
  .main-wrapper {
    margin-left: 0 !important;
    width: 100%;
  }
  
  /* 사이드바 오버레이 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    transition: opacity 0.3s ease;
  }
  
  .sidebar-overlay.show {
    display: block;
    animation: fadeIn 0.3s ease;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  .main-content {
    padding-top: var(--spacing-lg);
    padding-bottom: var(--spacing-xl);
  }
  
  .page-header-title h1 {
    font-size: var(--font-size-2xl);
  }
  
  .section-title {
    font-size: var(--font-size-lg);
  }
  
  /* 테이블 반응형 */
  .table-wrap {
    max-height: calc(100vh - 200px);
    min-height: 300px;
  }
  
  .table-wrap table {
    min-width: 800px;
  }
  
  /* 카드 그리드 반응형 */
  .row.g-3 > * {
    margin-bottom: var(--spacing-md);
  }
}

@media (max-width: 768px) {
  /* 모바일에서는 사이드바를 숨기고 오프캔버스로 표시 */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  /* 사이드바 오버레이 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }
  
  .main-content {
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-lg);
  }
  
  .container-fluid {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
  }
  
  .page-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
  }
  
  .page-header-title {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }
  
  .page-header-title h1 {
    font-size: var(--font-size-xl);
    line-height: 1.3;
  }
  
  .page-header-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }
  
  section {
    margin-bottom: var(--spacing-xl);
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }
  
  .card-module {
    margin-bottom: var(--spacing-md);
  }
  
  .card-body {
    padding: var(--spacing-md);
  }
  
  .table-wrap {
    border-radius: var(--radius-md);
    max-height: calc(100vh - 180px);
    min-height: 250px;
    overflow-x: scroll !important;
    overflow-y: scroll !important;
  }
  
  .table-wrap table {
    min-width: 600px;
  }
  
  .table thead th,
  .table tbody td {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    min-width: 80px;
    white-space: nowrap;
  }
  
  /* 폼 반응형 */
  .form-control,
  .form-select {
    font-size: var(--font-size-sm);
  }
  
  .row.g-3 > * {
    margin-bottom: var(--spacing-sm);
  }
  
  .btn-group {
    flex-wrap: wrap;
  }
  
  .btn-group .btn {
    margin-bottom: var(--spacing-xs);
  }
  
  .login-card {
    margin: var(--spacing-md);
    padding: var(--spacing-lg);
  }
  
  .btn {
    font-size: var(--font-size-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    white-space: nowrap;
  }
  
  /* 모달 반응형 */
  .modal-dialog {
    margin: var(--spacing-sm);
    max-width: calc(100% - var(--spacing-md));
  }
  
  /* 조직도 반응형 */
  .org-chart-wrapper {
    padding: var(--spacing-sm);
  }
  
  .org-card {
    min-width: 120px;
    max-width: 150px;
    padding: var(--spacing-sm);
  }
  
  .org-name {
    font-size: 0.85em;
  }
  
  .org-type {
    font-size: 0.7em;
  }
}

@media (max-width: 576px) {
  .container-lg,
  .container-fluid {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
  }
  
  .page-header-title h1 {
    font-size: var(--font-size-lg);
    line-height: 1.2;
  }
  
  .page-header-actions .btn {
    width: 100%;
    margin-bottom: var(--spacing-xs);
  }
  
  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-sm);
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-md);
  }
  
  .modal-dialog {
    margin: var(--spacing-xs);
    max-width: calc(100% - var(--spacing-sm));
  }
  
  .table-wrap {
    max-height: calc(100vh - 150px);
    min-height: 200px;
  }
  
  .table-wrap table {
    min-width: 500px;
  }
  
  .table thead th,
  .table tbody td {
    padding: var(--spacing-xs);
    font-size: 0.7rem;
    min-width: 70px;
  }
  
  /* 버튼 그룹 세로 배치 */
  .btn-group-vertical {
    width: 100%;
  }
  
  .btn-group-vertical .btn {
    width: 100%;
    margin-bottom: var(--spacing-xs);
  }
  
  /* 조직도 초소형 화면 */
  .org-chart-wrapper {
    padding: var(--spacing-xs);
  }
  
  .org-card {
    min-width: 100px;
    max-width: 120px;
    padding: var(--spacing-xs);
  }
  
  .org-name {
    font-size: 0.75em;
  }
  
  .org-type {
    font-size: 0.65em;
  }
  
  .org-count {
    font-size: 0.6em;
  }
}

/* ============================================
   19. Print Styles
   ============================================ */
@media print {
  .navbar,
  .app-footer,
  .page-header-actions,
  .btn,
  .dropdown-menu {
    display: none !important;
  }
  
  .main-content {
    padding: 0;
  }
  
  .card {
    border: 1px solid #000;
    box-shadow: none;
    page-break-inside: avoid;
  }
}

/* ============================================
   모달과 알림 메시지 최상단 표시
   ============================================ */
   
/* Flash 메시지 최상단 표시 */
.flash-stack {
  position: relative !important;
  z-index: var(--z-flash-message) !important;
}

.flash-stack .alert {
  position: relative !important;
  z-index: calc(var(--z-flash-message) + 1) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* 에러 모달 최상단 표시 (위의 일반 모달 스타일로 이미 적용됨) */
#errorModal .modal-content {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
}

/* 모든 Bootstrap 모달 백드롭 z-index 강제 (위에서 이미 정의됨, 중복 제거) */
