/* 차단기 · 장비 상세(모바일 순서) · 헬스체크 이동 버튼 */

/* ===== 차단기 조작부 (빠른 창 · 장비 상세 공용, js/barrier.js controlHtml) =====
   1) 차단기 번호를 고르고  2) 열기 · 열림 고정 · 닫기 중 하나를 누른다. */
.br-ctl { display: flex; flex-direction: column; gap: 10px; }

/* 번호 고르기: 알약 모양 단일 선택 */
.br-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.br-pick-btn {
  height: 32px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong, var(--border)); background: var(--surface); color: var(--text-muted);
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  transition: background .15s, border-color .15s, color .15s;
}
.br-pick-btn:hover { border-color: var(--accent); color: var(--text); }
.br-pick-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.br-pick-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.br-pick-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 세 동작: 같은 폭으로 한 줄 */
.br-ops { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.br-op {
  min-height: 44px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; font-family: inherit; font-size: 14px; font-weight: 800;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.br-op:active:not(:disabled) { transform: translateY(1px); }
.br-op:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.br-op:disabled { opacity: .5; cursor: not-allowed; }

/* 열기 — 가장 자주 쓰는 동작이라 주 버튼 색 */
.br-op-open { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.br-op-open:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }

/* 열림 고정 — 계속 열려 있게 되므로 주의 색 */
.br-op-hold { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text-strong); }
.br-op-hold:hover:not(:disabled) { border-color: var(--warn-dot); background: color-mix(in srgb, var(--warn-dot) 22%, var(--warn-bg)); }

/* 닫기 — 고정을 푸는 평상 동작. 테두리만 있는 기본 버튼 */
.br-op-close { background: var(--surface); border-color: var(--border-strong, var(--border)); color: var(--text); }
.br-op-close:hover:not(:disabled) { border-color: var(--text-muted); background: var(--off-bg); }

.br-ctl .br-msg { margin-top: 0; }

/* 빠른 창 안에서는 조금 더 넉넉하게 */
.br-modal .br-ctl { gap: 14px; }
.br-modal .br-op { min-height: 52px; font-size: 15px; }

/* ===== 자동 열림 · 장비 설정값 접기 ===== */
.br-fold {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 9px 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 12.5px; font-weight: 800; text-align: left;
}
.br-fold:hover { border-color: var(--accent); }
.br-fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.br-fold-state {
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.br-fold[aria-expanded="true"] .br-fold-state { background: var(--off-bg); color: var(--text-muted); }
.br-settings { display: flex; flex-direction: column; gap: 14px; }
.br-settings[hidden] { display: none; }

/* ===== 헬스체크 패널 제목 줄: [지금 검사] ===== */
.dp-head-btn + .dp-head-btn { margin-left: 6px; }

/* ===== 장비 상세(폰): 미리보기 → 차단기 → 헬스체크 → 장비 정보 → 위치 =====
   (LPR 이 아닌 장비의 이벤트 로그 · 하위 장비는 그 뒤) */
@media (max-width: 767px) {
  .detail-layout > .detail-panel[data-panel="thumbnail"] { order: 1; }
  .detail-layout > .detail-panel[data-panel="barrier"] { order: 2; }
  .detail-layout > .detail-panel[data-panel="health"] { order: 3; }
  .detail-layout > .detail-panel[data-panel="info"] { order: 4; }
  .detail-layout > .detail-panel[data-panel="map"] { order: 5; }
  .detail-layout > .detail-panel[data-panel="events"] { order: 6; }
  .detail-layout > .detail-panel[data-panel="children"] { order: 7; }

  /* 차단기 칸은 내용만큼 늘어난다(접기를 펼치면 같이 길어진다). 안에서 따로 구르지 않게 한다. */
  .detail-layout > .detail-panel[data-panel="barrier"] { min-height: 0; }
  .detail-panel[data-panel="barrier"] .br-host { height: auto; overflow: visible; }

  .br-op { min-height: 48px; }
}

/* ===== 입출차 기록 패널 (js/entryHistory.js) ===== */
.detail-panel[data-panel="entries"] .detail-panel-body { padding: 10px 12px 6px; display: flex; flex-direction: column; }
.eh-host { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.eh { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.eh-tools { display: flex; gap: 6px; }
.eh-date, .eh-plate {
  min-width: 0; height: 34px; padding: 0 10px; box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.eh-date { flex: 0 0 auto; width: 138px; }
.eh-plate { flex: 1; }
.eh-refresh {
  flex: none; width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.eh-refresh:hover { border-color: var(--accent); color: var(--accent); }
.eh-chips { display: flex; align-items: center; gap: 4px; }
.eh-chip {
  height: 28px; padding: 0 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  font-size: 12px; font-weight: 700;
}
.eh-chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.eh-count { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--text-faint); }
.eh-list { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid var(--border-subtle); }
.eh-row {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px 8px;
  padding: 8px 2px; border-bottom: 1px solid var(--border-subtle); font-size: 13px;
}
.eh-time { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12.5px; }
.eh-dir { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; }
.eh-dir-in { background: var(--ok-bg); color: var(--ok-text); }
.eh-dir-out { background: var(--info-bg, var(--accent-soft)); color: var(--info-text, var(--accent-ink)); }
.eh-dir-unknown { background: var(--surface-sunken); color: var(--text-faint); }
.eh-plate-txt { font-weight: 800; letter-spacing: .3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-type { font-size: 11px; font-weight: 700; color: var(--text-faint); }
.eh-type-regular { color: var(--ok-text); }
.eh-type-booking { color: var(--accent-ink); }
.eh-type-black { color: var(--err-text); }
.eh-photo {
  grid-row: span 2; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.eh-photo:hover { border-color: var(--accent); color: var(--accent); }
.eh-cam { grid-column: 3 / 5; font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-empty { padding: 18px 4px; text-align: center; font-size: 12.5px; color: var(--text-faint); }
.eh-error { color: var(--err-text); }
.eh-loading { padding: 10px; text-align: center; font-size: 12px; color: var(--text-faint); }
.eh-foot:empty { display: none; }
.eh-more {
  width: 100%; height: 36px; margin-top: 6px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 700;
}
.eh-more:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 767px) {
  .detail-layout > .detail-panel[data-panel="entries"] { order: 6; min-height: 0; }
  .detail-panel[data-panel="entries"] .detail-panel-body { overflow: visible; }
  .eh-list { max-height: 60vh; }
  .eh-date, .eh-plate, .eh-refresh { height: 40px; }
  .eh-refresh { width: 40px; }
  .eh-photo { width: 40px; height: 40px; }
  .eh-chip { height: 32px; }
}

/* 입출차 칸이 생겨 PC 에서 차단기 칸이 좁아졌다 — 버튼 글자가 두 줄로 꺾이지 않게 한다 */
.br-op { white-space: nowrap; padding-left: 8px; padding-right: 8px; min-width: 0; }

/* 입출차 칸이 좁을 때(노트북 화면 등): 사진 버튼이 생겨 번호판이 눌리지 않게 한다.
   차량 종류(방문 등)는 빼고, 검색칸은 다음 줄로 내린다. */
.eh { container-type: inline-size; }
@container (max-width: 260px) {
  .eh-tools { flex-wrap: wrap; }
  .eh-date { flex: 1 1 auto; width: auto; }
  .eh-plate { order: 3; flex: 1 1 100%; }
  /* 두 줄: [시각 번호판 | 사진] / [입출 카메라 | 사진] */
  .eh-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .eh-time { grid-row: 1; grid-column: 1; }
  .eh-plate-txt { grid-row: 1; grid-column: 2; }
  .eh-dir { grid-row: 2; grid-column: 1; justify-self: start; }
  .eh-cam { grid-row: 2; grid-column: 2; }
  .eh-photo { grid-row: 1 / span 2; grid-column: 3; width: 28px; height: 28px; }
  .eh-type { display: none; }
}
