/* KNS 거래처 관리 시스템 커스텀 스타일 */
* { font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif; }

/* ════════════════════════════════════════════════════════════════
   🌙 다크 모드 (야근 직원 눈 보호용)
   <html class="dark"> 또는 <body class="dark"> 가 켜지면 적용
   Tailwind 클래스를 부드럽게 오버라이드 (사이드바/카드/배경 중심)
   ════════════════════════════════════════════════════════════════ */
html.dark { color-scheme: dark; }
html.dark body { background: #0f172a; color: #e2e8f0; }

/* 메인 배경/사이드바/헤더 */
html.dark .bg-slate-50,
html.dark .bg-slate-100 { background-color: #0f172a !important; }
html.dark .bg-white { background-color: #1e293b !important; }
html.dark .bg-gradient-to-br.from-slate-50 { background: #0f172a !important; }

/* 보더 */
html.dark .border-slate-200,
html.dark .border-slate-300 { border-color: #334155 !important; }

/* 텍스트 */
html.dark .text-slate-700,
html.dark .text-slate-800 { color: #e2e8f0 !important; }
html.dark .text-slate-500,
html.dark .text-slate-600 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #64748b !important; }

/* 카드/입력 박스 */
html.dark input[type="text"],
html.dark input[type="password"],
html.dark input[type="email"],
html.dark input[type="number"],
html.dark input[type="date"],
html.dark input[type="time"],
html.dark input[type="search"],
html.dark select,
html.dark textarea {
  background-color: #0f172a !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #64748b; }

/* 사이드바 네비 호버/활성 */
html.dark .nav-item:hover:not(.active) { background-color: #334155 !important; }
html.dark .nav-item { color: #cbd5e1 !important; }
html.dark .nav-item.active { background-color: #2563eb !important; color: white !important; }
html.dark .hover\:bg-slate-100:hover { background-color: #334155 !important; }
html.dark .bg-slate-50 { background-color: #0f172a !important; }

/* 모달 배경 */
html.dark .modal-content { background: #1e293b !important; color: #e2e8f0; }

/* 테이블 줄무늬 */
html.dark .even\:bg-slate-50:nth-child(even),
html.dark .odd\:bg-white:nth-child(odd) { background-color: #0f172a !important; }
html.dark tbody tr:hover { background-color: #1e293b !important; }
html.dark thead { background-color: #0f172a !important; }

/* 스크롤바 */
html.dark ::-webkit-scrollbar-track { background: #1e293b; }
html.dark ::-webkit-scrollbar-thumb { background: #475569; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* FullCalendar 다크 모드 */
html.dark .fc { color: #e2e8f0; }
html.dark .fc-theme-standard td,
html.dark .fc-theme-standard th,
html.dark .fc-theme-standard .fc-scrollgrid { border-color: #334155 !important; }
html.dark .fc-col-header-cell { background-color: #1e293b !important; }
html.dark .fc-day-today { background-color: #1e3a8a40 !important; }
html.dark .fc-button-primary {
  background-color: #334155 !important;
  border-color: #475569 !important;
}
html.dark .fc-button-primary:hover { background-color: #475569 !important; }
html.dark .fc-button-active { background-color: #2563eb !important; }

/* ════════════════════════════════════════════════════════════════
   ✨ 로고 호버 애니메이션 (시스템 설정에서 효과 선택)
   .logo-hover-fade / .logo-hover-scale / .logo-hover-rotate
   ════════════════════════════════════════════════════════════════ */
.logo-hover-fade,
.logo-hover-scale,
.logo-hover-rotate {
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.35s ease;
  will-change: opacity, transform;
}
.logo-hover-fade:hover {
  opacity: 0.6;
  filter: brightness(1.1);
}
.logo-hover-scale:hover {
  transform: scale(1.08);
}
.logo-hover-rotate:hover {
  transform: rotate(-6deg) scale(1.04);
}

/* 다크모드 토글 버튼 */
.dark-mode-toggle {
  transition: background-color 0.2s, color 0.2s;
}
.dark-mode-toggle:hover { background-color: rgba(100, 116, 139, 0.15); }
html.dark .dark-mode-toggle:hover { background-color: rgba(148, 163, 184, 0.2); }

/* ───────── 한글 IME 기본화 ─────────
 * 한글 입력이 예상되는 필드에 lang="ko" 속성을 추가하면
 * 브라우저/OS가 한글 IME를 우선 활성화하도록 힌트를 줍니다.
 * - ime-mode: 구형 Edge/Firefox 한정 지원 (Chrome은 자체 IME 관리)
 * - lang="ko": 모든 브라우저가 인식하는 표준 속성
 * - Chrome/Edge: OS IME 상태 + lang 속성을 종합해 한글 IME 우선 활성화
 */
input[lang="ko"],
textarea[lang="ko"] {
  ime-mode: active; /* deprecated but still respected by some browsers */
}
input[lang="ko"]:focus,
textarea[lang="ko"]:focus {
  ime-mode: active;
}

/* 사이드바 활성 메뉴 */
.nav-item.active {
  background-color: rgb(37 99 235);
  color: white;
}
.nav-item:hover:not(.active) {
  background-color: rgb(241 245 249);
}

/* FullCalendar 커스텀 */
.fc-theme-standard .fc-scrollgrid { border-radius: 0.5rem; overflow: hidden; }
.fc .fc-toolbar-title { font-size: 1.25rem !important; font-weight: 600; }
.fc-day-sun .fc-daygrid-day-number { color: #dc2626; }
.fc-day-sat .fc-daygrid-day-number { color: #2563eb; }
.fc-day.holiday { background-color: #fef2f2 !important; }
.fc-day.holiday .fc-daygrid-day-number { color: #dc2626 !important; font-weight: 600; }

/* 휴일 유형별 셀 배경 색상 차별화 */
.fc-day.holiday-national { background-color: #fef2f2 !important; }    /* 법정: 연빨강 */
.fc-day.holiday-national .fc-daygrid-day-number { color: #dc2626 !important; }
.fc-day.holiday-temporary { background-color: #fff7ed !important; }   /* 임시: 연주황 */
.fc-day.holiday-temporary .fc-daygrid-day-number { color: #c2410c !important; font-weight: 600; }
.fc-day.holiday-company { background-color: #f5f3ff !important; }     /* 사내: 연보라 */
.fc-day.holiday-company .fc-daygrid-day-number { color: #6d28d9 !important; font-weight: 600; }
.holiday-label {
  font-size: 0.7rem;
  color: #dc2626;
  padding: 2px 4px;
  background: #fef2f2;
  border-radius: 4px;
  margin: 2px;
  display: inline-block;
}

/* 모달 */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 0.5rem;
}
.modal-content {
  background: white;
  border-radius: 1rem;
  max-width: 32rem;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* Tailwind sm:max-w-* 유틸리티가 .modal-content의 기본 max-width를 덮어쓸 수 있도록 우선순위 향상 */
@media (min-width: 640px) {
  .modal-content.sm\:max-w-md { max-width: 28rem; }
  .modal-content.sm\:max-w-lg { max-width: 32rem; }
  .modal-content.sm\:max-w-2xl { max-width: 42rem; }
  .modal-content.sm\:max-w-3xl { max-width: 48rem; }
  .modal-content.sm\:max-w-5xl { max-width: 64rem; }
  .modal-content.sm\:max-w-6xl { max-width: 72rem; }
  .modal-content[class*="sm:max-w-\["] { max-width: 95vw; }
}
/* line-clamp 폴리필 (Tailwind 3+에는 내장되어 있지만 안전망) */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* 모바일: 더 큰 모달, 더 적은 패딩 */
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-content {
    border-radius: 1rem 1rem 0 0;
    max-height: 95vh;
    max-width: 100%;
    /* iOS 안전영역 대응 */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* 모바일 터치 친화: 최소 44px 터치 타겟 */
@media (max-width: 640px) {
  button, .nav-item, input[type="checkbox"], input[type="radio"] {
    min-height: 36px;
  }
  /* FullCalendar 셀 모바일 최적화 */
  .fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .fc .fc-toolbar-title { font-size: 1.1rem !important; }
  .fc .fc-button { padding: 0.35em 0.65em !important; font-size: 0.8rem !important; }
  .fc .fc-daygrid-day-number { font-size: 0.75rem !important; padding: 2px 4px !important; }
  .fc .fc-event { font-size: 0.65rem !important; }
  .day-manpower { font-size: 0.55rem !important; }
}

/* 가로 스크롤 표 (모바일에서 테이블을 부드럽게 스크롤) */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { min-width: 600px; }

/* 갱신 임박 배지 */
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* 인력 부족 셀 (예정 > 가용) */
.fc-day.day-shortage {
  background: repeating-linear-gradient(
    -45deg,
    #fff7ed,
    #fff7ed 6px,
    #ffedd5 6px,
    #ffedd5 12px
  ) !important;
  box-shadow: inset 0 0 0 2px #fb923c;
}
.fc-day.day-shortage.holiday {
  background: repeating-linear-gradient(
    -45deg,
    #fef2f2,
    #fef2f2 6px,
    #fee2e2 6px,
    #fee2e2 12px
  ) !important;
}

/* 일별 인력 표시 줄 */
.day-manpower {
  font-variant-numeric: tabular-nums;
}
.day-manpower i {
  margin-right: 1px;
  opacity: 0.7;
}

/* 모달 보호 — 바깥 클릭 시 흔들림 애니메이션 (입력 보호 피드백) */
@keyframes modal-shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
}
.animate-shake {
  animation: modal-shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

/* 스크롤바 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ════════════════════════════════════════════════════════════════
   청구 캘린더 — 이벤트 거래처명 가독성 개선
   ════════════════════════════════════════════════════════════════ */
#billingCalendar .fc-daygrid-event {
  white-space: normal !important;
  align-items: flex-start;
  border-radius: 4px;
  padding: 1px 2px;
  margin-bottom: 2px;
  min-height: 28px;
  cursor: pointer;
}
#billingCalendar .fc-daygrid-event:hover {
  filter: brightness(1.1);
}
#billingCalendar .fc-event-main {
  padding: 0 !important;
}
/* 모바일에서도 두 줄 표시 보장 */
@media (max-width: 640px) {
  #billingCalendar .fc-daygrid-event {
    min-height: 24px;
    padding: 0 1px;
  }
  #billingCalendar .fc-event .text-\[11px\] { font-size: 10px !important; }
  #billingCalendar .fc-event .text-\[10px\] { font-size: 9px !important; }
}
/* 일자 셀 안에서 이벤트 영역 충분히 확보 */
#billingCalendar .fc-daygrid-day-events {
  min-height: 2em;
  padding: 2px 1px;
}
/* +N건 더보기 링크 스타일 */
#billingCalendar .fc-daygrid-more-link {
  color: #2563eb !important;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  background: #eff6ff;
  border-radius: 3px;
  margin-top: 2px;
  display: inline-block;
}
#billingCalendar .fc-daygrid-more-link:hover {
  background: #dbeafe;
  text-decoration: none !important;
}

/* ════════════════════════════════════════════════════════════════
   방문 캘린더 — timeGridWeek/Day 시간축 가독성
   ════════════════════════════════════════════════════════════════ */
#calendar .fc-timegrid-slot-label {
  font-size: 11px;
  color: #64748b;
}
#calendar .fc-timegrid-event {
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
}
#calendar .fc-timegrid-event .fc-event-time {
  font-weight: 600;
  font-size: 10px;
  opacity: 0.95;
}
#calendar .fc-timegrid-event .fc-event-title {
  font-weight: 500;
  white-space: normal;
  line-height: 1.25;
}
/* 현재 시각 표시 라인 */
#calendar .fc-timegrid-now-indicator-line {
  border-color: #ef4444;
  border-width: 2px;
}
#calendar .fc-timegrid-now-indicator-arrow {
  border-color: #ef4444;
}
/* allDay 영역 강조 */
#calendar .fc-timegrid .fc-timegrid-axis-cushion,
#calendar .fc-timegrid .fc-daygrid-day-frame {
  font-size: 11px;
}
#calendar .fc-timegrid-axis-cushion {
  color: #475569;
  font-weight: 600;
}
/* 모바일 timeGridWeek 대응 */
@media (max-width: 640px) {
  #calendar .fc-timegrid-slot-label { font-size: 9px; }
  #calendar .fc-timegrid-event { font-size: 9px; padding: 1px 2px; }
  #calendar .fc-timegrid-event .fc-event-time { font-size: 9px; }
  #calendar .fc-col-header-cell-cushion { font-size: 10px; }
}

/* ============================================================ */
/* 🆕 출장 캘린더 - 예정 출장 시각화                              */
/* ============================================================ */
/* 예정 출장이 있는 날짜 셀: 좌측 파란 띠 + 연한 배경 */
#expenseCalendar .fc-daygrid-day.exp-planned-day {
  background-color: #eff6ff !important;  /* blue-50 */
  position: relative;
}
#expenseCalendar .fc-daygrid-day.exp-planned-day::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-radius: 0 2px 2px 0;
  pointer-events: none;
  z-index: 1;
}
/* 예정 출장 이벤트 자체에 점선 테두리로 "예정" 강조 */
#expenseCalendar .exp-planned-event {
  border: 1.5px dashed #1e40af !important;
  font-weight: 600;
}
/* 연차관리 휴가 이벤트 — 왼쪽에 두꺼운 띠 */
#expenseCalendar .exp-leave-event {
  border-left: 4px solid rgba(0,0,0,0.25) !important;
  font-weight: 600;
}

/* ============================================================ */
/* 🆕 방문 캘린더 - 휴가자 배지                                   */
/* ============================================================ */
.day-leave-users {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px 4px 0 4px;
  font-size: 10px;
  line-height: 13px;
  pointer-events: none;
}
.day-leave-users .leave-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #fef3c7;       /* amber-100 */
  color: #92400e;             /* amber-800 */
  border: 1px solid #fcd34d;  /* amber-300 */
  padding: 0 4px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: auto;
}
.day-leave-users .leave-chip.half {
  background: #cffafe;       /* cyan-100 */
  color: #155e75;             /* cyan-800 */
  border-color: #67e8f9;      /* cyan-300 */
}
.day-leave-users .leave-chip.sick {
  background: #fee2e2;       /* red-100 */
  color: #991b1b;             /* red-800 */
  border-color: #fca5a5;
}
.day-leave-users .leave-chip.more {
  background: #e2e8f0;        /* slate-200 */
  color: #475569;             /* slate-600 */
  border-color: #cbd5e1;
}
