/* =========================================================
   공통 스타일 (PC / 모바일 공용)
   - 페이지별 <style> 에는 색상 등 페이지 고유 스타일만 둔다.
   - 모바일(<=700px)에서 table.table-cards 는 행 단위 카드로 바뀐다.
     각 td 에 data-label="컬럼명" 을 넣어야 라벨이 표시된다.
   ========================================================= */

:root {
  --text: #222;
  --text-sub: #666;
  --text-muted: #888;
  --line: #e3e3e3;
  --bg-soft: #f6f7f9;
  --nav-bg: #2c3e50;
  --accent: #3498db;
  --radius: 6px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  word-break: keep-all;          /* 한글 단어 중간에서 줄바꿈되지 않도록 */
  overflow-wrap: anywhere;       /* 단, 긴 URL 등은 넘치지 않게 */
}

.container { padding-left: 16px; padding-right: 16px; }

/* ---------- 페이지 제목 ---------- */
.page-title {
  font-size: clamp(22px, 4.5vw, 30px);
  font-weight: 700;
  margin-bottom: 8px;
}
.page-subtitle {
  color: var(--text-sub);
  margin-bottom: 20px;
  font-size: 15px;
}
.result-count {
  color: var(--text-sub);
  font-size: 14px;
}

/* ---------- 알림 메시지 ---------- */
.message-box {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #e9f7ef;
  border: 1px solid #bee5d3;
  color: #155724;
  border-radius: var(--radius);
}
.message-box.is-error {
  background: #fdecea;
  border-color: #f5c6cb;
  color: #721c24;
}

/* ---------- 폼 ---------- */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
  padding: 9px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px;               /* iOS 에서 16px 미만이면 포커스 시 자동 확대됨 */
  max-width: 100%;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.add-form input[type="text"] { flex: 1 1 280px; }

.filter-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: var(--radius);
}

/* ---------- 버튼 ---------- */
.btn-done {
  background: #4CAF50;
  color: #fff;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
}
.btn-done:hover { background: #3d8b40; }
.btn-done:disabled { background: #ccc; cursor: not-allowed; }

.link-text {
  background: #FFA500;
  color: #fff;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.link-text:hover { color: #fff; opacity: 0.9; }
.link-text:visited { background: #424242; color: #BDBDBD; }

/* ---------- 표 (PC 기본) ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
th, td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: center;
  vertical-align: middle;
}
th {
  background: var(--bg-soft);
  color: #555;
  font-weight: 600;
}
td.text-left { text-align: left; }

/* 표가 화면보다 넓을 때 가로 스크롤 */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 셀 안의 버튼 묶음 */
.cell-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.status-y { color: #27ae60; font-weight: bold; }
.status-n { color: #e74c3c; font-weight: bold; }

/* PC/모바일 전용 표시 */
.mobile-only { display: none; }

/* ---------- 내비게이션 바 ---------- */
.nav-menu {
  background: var(--nav-bg);
  padding: 12px 20px;
  margin-bottom: 25px;
  display: flex;
  gap: 16px;
  align-items: center;
  position: relative;
}
/* 메뉴 링크: 넘치면 가로 스크롤 (펼침 메뉴가 잘리지 않도록 스크롤은 이 영역에만) */
.nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-menu a,
.nav-more-btn {
  color: #bdc3c7;
  text-decoration: none;
  font-weight: bold;
  font-size: 15px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex: 0 0 auto;
  border-bottom: 2px solid transparent;
}
.nav-menu a .icon,
.nav-more-btn .icon { margin-right: 6px; font-size: 17px; }
.nav-menu a:hover,
.nav-menu a.active,
.nav-more-btn:hover,
.nav-more.open .nav-more-btn,
.nav-more:has(a.active) .nav-more-btn {   /* 현재 페이지가 펼침 메뉴 안에 있으면 버튼도 표시 */
  color: #fff;
  border-bottom-color: var(--accent);
}

/* ---------- 펼침 메뉴 (☰ 메뉴) ---------- */
.nav-more { position: relative; flex: 0 0 auto; }
.nav-more-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.nav-more-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  background: var(--nav-bg);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  padding: 6px 0;
  z-index: 200;
}
.nav-more.open .nav-more-panel { display: block; }
.nav-more-panel a {
  display: flex;
  padding: 10px 16px;
  border-bottom: none;
  border-left: 3px solid transparent;
}
.nav-more-panel a:hover,
.nav-more-panel a.active {
  border-left-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- 툴팁 (마우스 오버 + 터치/포커스) ---------- */
.tip-container {
  position: relative;
  display: inline-block;
  padding: 15px 20px;           /* 반응 영역 확장 */
  margin: -15px -20px;
  cursor: help;
  outline: none;
}
.tip-box {
  visibility: hidden;
  width: 220px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 4px;
  padding: 8px;
  position: absolute;
  z-index: 10;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.4;
}
.tip-box::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}
.tip-container:hover .tip-box,
.tip-container:focus .tip-box,
.tip-container:focus-within .tip-box {
  visibility: visible;
  opacity: 1;
}

/* =========================================================
   모바일
   ========================================================= */
@media (max-width: 700px) {
  body { font-size: 15px; }
  .container { padding-left: 12px; padding-right: 12px; }

  .mobile-only { display: block; }
  .pc-only { display: none !important; }

  /* 메뉴: 라벨을 유지한 채 가로 스크롤, 상단 고정 */
  .nav-menu {
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 4px;
    padding: 8px 10px;
    margin-bottom: 16px;
  }
  .nav-links { gap: 4px; }
  .nav-menu a, .nav-more-btn { font-size: 14px; padding: 6px 8px; }
  .nav-menu a .icon, .nav-more-btn .icon { margin-right: 4px; font-size: 15px; }
  .nav-more-panel { top: calc(100% + 8px); }

  /* 폼 요소는 한 줄 전체 사용 */
  .add-form input[type="text"] { flex-basis: 100%; }
  .add-form button { flex: 1 1 100%; padding: 12px; }
  .filter-box { padding: 10px; }

  /* 터치하기 쉬운 버튼 크기 */
  button, .btn-done, .link-text { min-height: 40px; }

  /* 카드형 표는 가로 스크롤이 필요 없음 (툴팁이 잘리지 않도록) */
  .table-scroll { overflow-x: visible; }

  /* ----- 표 → 카드 ----- */
  table.table-cards,
  table.table-cards tbody,
  table.table-cards tr,
  table.table-cards td {
    display: block;
    width: 100%;
  }
  table.table-cards colgroup,
  table.table-cards thead { display: none; }

  table.table-cards tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 4px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  table.table-cards tbody tr:hover { background: #fff; }

  table.table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 9px 0;
    text-align: right;
    font-size: 15px;
  }
  table.table-cards td:last-child { border-bottom: none; }
  table.table-cards td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
  }
  table.table-cards td.text-left { text-align: right; }

  /* 긴 텍스트: 라벨 아래에 본문 */
  table.table-cards td.cell-block {
    display: block;
    text-align: left;
  }
  table.table-cards td.cell-block::before {
    display: block;
    margin-bottom: 4px;
  }

  /* 카드 상단 제목 셀 */
  table.table-cards td.cell-title {
    font-size: 16px;
    font-weight: 700;
    text-align: left;
  }

  /* 데이터 없음 행 */
  table.table-cards td[colspan] {
    display: block;
    text-align: center;
    color: var(--text-muted);
  }
  table.table-cards td[colspan]::before { content: none; }

  /* 툴팁: 카드 오른쪽 기준으로 펼침 */
  .tip-container { padding: 6px 4px; margin: 0; }
  .tip-box {
    left: auto;
    right: 0;
    transform: none;
    width: min(260px, 80vw);
  }
  .tip-box::after { left: auto; right: 16px; }
}
