@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700;900&display=swap');

:root {
  --ink: #1F2937;
  --sub: #6B7280;
  --muted: #9CA0A3;
  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --border: #E3E5E0;
  --accent: #2F6F62;
  --accent-dark: #1F4F44;
  --accent-soft: #E7F0ED;
  --amber-bg: #FDF3E7;
  --amber-text: #92400E;
  --gray-bg: #F1F1EF;
  --gray-text: #52524C;
  --sidebar-bg: #1B2420;
  --sidebar-active: #28443D;
  --sidebar-text: #C9CDC9;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Noto Sans KR', system-ui, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }

.app { display: flex; min-height: 100vh; }

.sidebar { width: 240px; flex: 0 0 auto; background: var(--sidebar-bg); min-height: 100vh; box-sizing: border-box; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.sidebar .brand { padding: 8px 12px 24px 12px; }
.sidebar .brand .name { color: #FFFFFF; font-size: 15px; font-weight: 700; }
.sidebar .brand .sub { color: var(--sidebar-text); font-size: 12px; margin-top: 4px; }
.sidebar a.nav-item { display: block; box-sizing: border-box; padding: 11px 12px; border-radius: 8px; color: var(--sidebar-text); font-size: 14px; text-decoration: none; }
.sidebar a.nav-item.active { background: var(--sidebar-active); color: #FFFFFF; font-weight: 700; }
/* 자식이 선택돼서 "열려있는" 1차 메뉴 — 자식 자체를 가리키는 active 블록과는 다르게, 글자만 강조 */
.sidebar a.nav-item.section-open { color: #FFFFFF; font-weight: 700; background: none; }

.sidebar .nav-children { margin: 0 4px 10px 22px; padding: 3px 0 3px 12px; border-left: 2px solid rgba(255,255,255,0.22); display: flex; flex-direction: column; gap: 1px; }
.sidebar .nav-children a.nav-item { font-size: 12.5px; padding: 7px 10px; border-radius: 6px; color: var(--sidebar-text); opacity: 0.7; font-weight: 400; }
.sidebar .nav-children a.nav-item:hover { opacity: 1; }
.sidebar .nav-children a.nav-item.active { opacity: 1; background: var(--sidebar-active); color: #FFFFFF; font-weight: 700; }

.content { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.topbar { height: 72px; flex: 0 0 auto; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; box-sizing: border-box; }
.topbar .title { font-size: 19px; font-weight: 900; }
.topbar .subtitle { font-size: 12px; color: var(--sub); margin-top: 2px; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }

.main { flex: 1 1 auto; padding: 28px 32px; box-sizing: border-box; display: flex; flex-direction: column; gap: 20px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-sizing: border-box; }
.card-tight { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-8 { grid-template-columns: repeat(8, minmax(0,1fr)); }
.grid-7 { grid-template-columns: repeat(7, minmax(0,1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* 카드 2개짜리 목록(출력관리 등)이 넓은 화면에서 끝까지 늘어나 휑해 보이지 않게, 폭을 절반으로
   제한한다 — 모바일 폭(아래 860px 미디어쿼리에서 1열로 바뀌는 화면)에서는 제한하지 않는다. */
@media (min-width: 861px) {
  .grid-narrow { max-width: 50%; }
}

.form-grid { display: grid; gap: 12px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea { width: 100%; box-sizing: border-box; }
.form-section { margin-top: 14px; }

.stat-label { font-size: 12px; color: var(--sub); }
.stat-value { font-size: 24px; font-weight: 900; margin-top: 6px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
input[type=text], input[type=password], input[type=date], input[type=number], select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; border: none; text-decoration: none; }
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-outline { background: var(--surface); color: var(--ink); border: 1px solid var(--border); font-weight: 400; }
.btn-danger-outline { background: var(--amber-bg); color: var(--amber-text); border: 1px solid #DDBE94; }

/* <summary>를 버튼처럼 쓸 때(펼침 화살표/마커 제거) — .btn과 나란히 놓였을 때 생김새를 맞춘다 */
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
summary.btn::marker { content: ''; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; font-size: 12px; color: var(--sub); font-weight: 700; border-bottom: 1px solid var(--border); background: #FAFAF8; white-space: nowrap; }
td { padding: 13px 16px; font-size: 13px; border-bottom: 1px solid #EEF0EC; white-space: nowrap; }
/* 글자가 세로로 쪼개지는 대신, 표가 지금 폭에 다 안 들어가면 카드 자체가 가로 스크롤된다 */
.card { overflow-x: auto; }

/* 위아래 여백을 절반으로 줄인 목록 (시스템관리 등 항목 수가 많은 화면용) */
.table-compact th { padding: 6px 16px; }
.table-compact td { padding: 6px 16px; }

/* 드래그 앤 드롭 순서변경 중, 지금 옮기고 있는 행이 뭔지 뚜렷하게 보여줌 */
tr.dragging-row { background: var(--accent-soft) !important; outline: 2px dashed var(--accent); outline-offset: -2px; }
tr.dragging-row td { background: transparent; color: var(--accent-dark); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-gray { background: var(--gray-bg); color: var(--gray-text); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }

.avatar-sm { width: 26px; height: 26px; border-radius: 999px; background: var(--gray-bg); color: var(--gray-text); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; vertical-align: middle; margin-right: 8px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); }
.login-card { width: 380px; background: var(--surface); border-radius: 16px; padding: 36px; box-sizing: border-box; }
.login-card .eyebrow { font-size: 12px; color: var(--sub); font-weight: 700; }
.login-card h1 { font-size: 20px; margin: 6px 0 24px; }
.login-card label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.login-card .field { margin-bottom: 18px; }
.login-card input { width: 100%; }
.login-card .error { color: #B91C1C; font-size: 12px; margin-bottom: 14px; }
.login-card button { width: 100%; padding: 14px; font-size: 15px; }

.password-field { position: relative; }
.password-field input { padding-right: 40px; }
/* .login-card button { width:100% } 쪽이 class 1개뿐인 .password-toggle-btn보다 상세도가
   높아서(class+tag) 그냥 두면 이 버튼도 전체 폭으로 늘어나 아이콘이 가운데로 밀렸다 —
   .login-card를 붙여 상세도를 맞춰 덮어쓴다. */
.login-card .password-toggle-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 0;
}
.login-card .password-toggle-btn:hover { background: var(--bg); color: var(--sub); }

.pager { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--sub); }

/* 반응형 — 좁은 화면에서는 사이드바를 햄버거 버튼으로 여닫는 오프캔버스로 전환 */
.hamburger-btn { display: none; background: none; border: none; cursor: pointer; padding: 6px; margin-right: 8px; flex: 0 0 auto; }
.hamburger-btn span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 4px 0; border-radius: 2px; }
.sidebar-overlay { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 200; width: 240px;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 2px 0 16px rgba(0,0,0,0.35);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150; }
  .hamburger-btn { display: inline-flex; flex-direction: column; justify-content: center; }
  .topbar { flex-wrap: wrap; height: auto; min-height: 72px; padding: 12px 16px; row-gap: 8px; }
  .topbar > div:first-child { display: flex; align-items: center; }
  .main { padding: 16px; }
  .grid-2, .grid-3, .grid-4, .grid-6, .grid-7, .grid-8, .form-grid { grid-template-columns: 1fr !important; }
}

/* 한글 날짜/월 선택 팝업(admin-datepicker.js) — 브라우저 기본 달력의 영문 표기를 피하려고
   직접 만든 것. 토큰은 전부 위에서 이미 쓰는 --accent/--border 등을 그대로 재사용. */
.js-datepicker { cursor: pointer; background: #fff; }
.dp-popup {
  /* 위치(top/left)는 JS가 input 기준 좌표를 계산해서 인라인으로 넣는다 — body에 직접 붙여서
     .card의 overflow-x:auto(표 가로 스크롤용, 스펙상 overflow-y도 같이 클리핑됨) 등 조상
     요소의 overflow에 안 잘리게 한다. */
  position: fixed; z-index: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 10px; width: 240px; box-sizing: border-box;
}
.dp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.dp-nav {
  border: none; background: none; cursor: pointer; font-size: 13px; color: var(--sub);
  padding: 4px 8px; border-radius: 6px;
}
.dp-nav:hover { background: var(--accent-soft); color: var(--accent-dark); }
.dp-weekrow { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.dp-weekday { text-align: center; font-size: 11px; color: var(--muted); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-day {
  border: none; background: none; cursor: pointer; font-size: 12px; color: var(--ink);
  padding: 6px 0; border-radius: 6px; text-align: center;
}
.dp-day:hover { background: var(--accent-soft); }
.dp-day.dp-blank { cursor: default; }
.dp-day.dp-blank:hover { background: none; }
.dp-day.dp-selected { background: var(--accent); color: #fff; font-weight: 700; }
.dp-month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-month-cell {
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px;
  color: var(--ink); padding: 10px 0; border-radius: 8px; text-align: center;
}
.dp-month-cell:hover { background: var(--accent-soft); }
.dp-month-cell.dp-selected { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.dp-day-disabled, .dp-day:disabled, .dp-month-cell:disabled {
  color: var(--muted); cursor: not-allowed; opacity: 0.5;
}
.dp-day-disabled:hover, .dp-month-cell:disabled:hover { background: none; }
.dp-nav:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.4; }
.dp-nav:disabled:hover { background: none; color: var(--muted); }

/* 페이지별 도움말 아이콘 + 레이어 팝업 (_bootstrap.php의 render_help_icon()이 생성) */
.help-icon-btn {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
  border: none; background: none; color: var(--sub);
  cursor: pointer; margin-left: 8px; padding: 0; line-height: 1;
}
.help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--surface); color: var(--sub);
  font-size: 12px; font-weight: 700; line-height: 1;
}
.help-icon-label { font-size: 13px; font-weight: 500; }
.help-icon-btn:hover .help-icon { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-dark); }
.help-icon-btn:hover .help-icon-label { color: var(--accent-dark); }
.help-modal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 2000;
  align-items: center; justify-content: center;
}
.help-modal-content {
  background: var(--surface); border-radius: 12px; padding: 20px; width: 480px; max-width: 90vw;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.help-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 15px; font-weight: 700; color: var(--ink); }
.help-modal-close { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--sub); line-height: 1; padding: 0; }
.help-modal-body { font-size: 13px; line-height: 1.7; color: var(--ink); }
.help-modal-body p { margin: 0 0 10px; }
.help-modal-body ul { padding-left: 20px; margin: 0 0 10px; }
.help-modal-body li { margin-bottom: 6px; }
