/* 전역 공통 스타일: 헤더, 메인 폼, 드로어, 버튼 — 모든 페이지에 적용 */
/* ── 리셋 & 기본 ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  word-break: inherit;
  overflow-wrap: inherit;
}

html {
  word-break: keep-all;
  overflow-wrap: normal;
}

body {
  font-family: 'Pretendard', 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  background: #f0f0f0;
  color: #262B2F;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.hidden { display: none !important; }

/* Figma effect styles — Effects (958:6403) */
:root {
  --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.08);
  /* shadow_Chip & Button (958:6415) — Chip/Button, 추천 칩 */
  --shadow-chip-button: 0 1px 2px 0 rgba(50, 56, 61, 0.08);
  /* shadow_Chat (958:6410) — 채팅 입력 영역 상단 구분 */
  --shadow-chat: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

/* ── 전체 페이지 래퍼 (모바일 프레임 360px) ── */
.page-wrapper {
  width: 360px;
  min-height: 780px;
  background-color: #ffffff;
  background-image: linear-gradient(180deg, rgba(255, 238, 245, 0) 40%, rgba(255, 238, 245, 0.2) 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
}

/* ── App Bar (Figma 56px, transparent) ── */
.app-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0;
  height: 56px;
  background: transparent;
  flex-shrink: 0;
}

.app-header__logo {
  display: block;
  height: 16px;
  width: auto;
}

.icon-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 22px;
  color: #32383D;
}

.header-brand {
  flex: 1;
  font-family: 'Pretendard', sans-serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 150%;
  color: #D70051;
}

.header-spacer { display: none; }

/* ── Content Area (Figma 679:4376) ── */
.form-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px 120px;
  gap: 40px;
  flex: 1;
  min-width: 0;
}

.form-title {
  width: 328px;
  margin: 0;
  font-family: 'Pretendard', sans-serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 36px;
  text-align: center;
  color: #171a1c;
}

/* ── lookupForm (Figma Wrapper 679:4378 — 328×250, gap 20) ── */
.lookup-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: 328px;
  margin: 0;
}

/* Input Field 70px = 라벨 18 + gap 4 + Text Field 48 */
.field-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
}

.field-label {
  font-family: 'Pretendard', sans-serif;
  font-weight: 400;
  font-size: 12px;
  line-height: 18px;
  color: #6b7882;
}

/* Text Field — #eef0f2, radius 4, stroke 없음 (Figma 647:7185) */
.text-field {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 0 0 12px;
  width: 100%;
  height: 48px;
  min-height: 48px;
  background: #eef0f2;
  border: none;
  border-radius: 4px;
  overflow: visible;
}

.text-field.is-open {
  position: relative;
  z-index: 10;
}

/* 접수 유형 — 오른쪽 48px 항상 확보(지우기 버튼 자리), 단말기 구분 chevron과 동일 */
.text-field--autocomplete {
  padding: 0 0 0 12px;
}

.text-field--autocomplete .dropdown-list {
  left: -12px;
  right: -48px;
  width: auto;
}

.field-btn--clear {
  padding: 0;
  visibility: hidden;
  pointer-events: none;
}

.field-btn-clear__icon {
  display: block;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.text-field--autocomplete.is-filled .field-btn--clear {
  visibility: visible;
  pointer-events: auto;
}

/* 단말기 구분 고정 — 드롭다운·chevron 없음 */
.text-field--fixed {
  pointer-events: none;
  cursor: default;
}

.text-field--fixed .field-input {
  color: #262b2f;
  cursor: default;
}

.field-select,
.field-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Pretendard', sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 22.5px;
  color: #171a1c;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.field-input {
  cursor: text;
}

.field-input[readonly] {
  cursor: pointer;
}

.field-input::placeholder {
  color: #929da5;
  font-weight: 400;
}

.field-input:not(:placeholder-shown),
.field-select.has-value {
  font-weight: 500;
}

/* 오른쪽 버튼 영역 (체브론) */
.field-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

.field-btn-icon {
  flex-shrink: 0;
}

/* Figma Arrow / Chevron_Down·Up — stroke 2, #929da5 */
.field-btn-icon--down path,
.field-btn-icon--up path {
  stroke: #929da5;
  stroke-width: 2;
}

.field-btn-icon--up {
  display: none;
}

.field-btn.is-open .field-btn-icon--down {
  display: none;
}

.field-btn.is-open .field-btn-icon--up {
  display: block;
}

.search-box {
  position: relative;
  flex: 1;
  display: flex;
  min-width: 0;
  height: 100%;
}

.search-box .field-input {
  width: 100%;
}

.dropdown-list {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  background: #fff;
  border: none;
  border-radius: 4px;
  list-style: none;
  z-index: 100;
  box-shadow: var(--shadow-dropdown);
}

/* 검색마다 viewport를 새로 만들어 스크롤 위치가 이전 검색에 묶이지 않게 함 */
.dropdown-list__viewport {
  max-height: 192px;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  border-radius: 4px;
}

.text-field:not(.text-field--autocomplete) .dropdown-list {
  left: -12px;
  right: -48px;
  width: auto;
}

/* Dropdown_Text Field — 기본 48px / 호버·선택 #32383d (Figma 792:4093) */
.dropdown-list__item {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  cursor: pointer;
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 22.5px;
  color: #171a1c;
  background: #fff;
  transition: background 0.1s, color 0.1s;
}

.dropdown-list__item:hover,
.dropdown-list__item.is-highlighted,
.dropdown-list__item:focus-visible {
  background: #32383d;
  color: #fff;
  font-weight: 600;
}

/* ── 단말기 구분 토글 그룹 ── */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 328px;
}

.toggle-btn {
  padding: 0 16px;
  height: 36px;
  background: #EFF0F1;
  border: none;
  border-radius: 20px;
  font-family: 'Pretendard', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #7B858C;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.toggle-btn:hover { background: #dde0e2; }
.toggle-btn.selected { background: #262B2F; color: #fff; }

/* ── 조회하기 (Figma Button_Main) ── */
.btn-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 16px;
  position: absolute;
  height: 48px;
  left: 0;
  right: 0;
  bottom: 60px;
  background: transparent;
}

.btn-lookup {
  width: 328px;
  height: 48px;
  border: none;
  border-radius: 4px;
  background: #cad0d4;
  font-family: 'Pretendard', sans-serif;
  font-weight: 500;
  font-size: 15px;
  line-height: 22.5px;
  color: #ffffff;
  cursor: not-allowed;
  transition: background 0.15s;
}

.btn-lookup:disabled {
  background: #cad0d4;
  cursor: not-allowed;
}

.btn-lookup:hover {
  background: #cad0d4;
}

.btn-lookup.active {
  background: #292f32;
  cursor: pointer;
}

.btn-lookup.active:hover {
  background: #292f32;
}

.btn-temp-logout {
  position: absolute;
  right: 16px;
  bottom: 18px;
  width: 72px;
  height: 30px;
  background: #EFF0F1;
  border: none;
  border-radius: 15px;
  font-family: 'Pretendard', sans-serif;
  font-weight: 500;
  font-size: 12px;
  color: #525D65;
  cursor: pointer;
  z-index: 2;
}

.btn-temp-logout:hover {
  background: #DDE0E2;
}

/* ── Safe Area (하단 34px) ── */
.safe-area {
  position: absolute;
  height: 34px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #FFFFFF;
}

/* ── 채팅 목록 드로어 ── */
.drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 50;
}

.drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: 300px;
  height: 100%;
  background: #FFFFFF;
  border-right: 1px solid #EFF0F1;
  z-index: 51;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e8e8e8;
  background: #fff;
}

.drawer-title {
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #262B2F;
}

/* ── 채팅 목록 — Figma Content (1019:4477): Card 100px + Line #f6f7f7 266×1 (inset 17px) ── */
.drawer-rooms {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-sizing: border-box;
}

/* 카드 사이 분리선 — 행(100px) 밖에 두어 선택·호버 시 상·하 4px 여백 유지 */
.drawer-rooms .room-item-divider {
  flex-shrink: 0;
  height: 1px;
  margin: 0 9px;
  background: #f6f7f7;
}

/* Figma Card_Chat list 행: 100px = inset 4px + 카드 92px */
.drawer-rooms .room-item {
  box-sizing: border-box;
  height: 100px;
  min-height: 100px;
  padding: 4px 0;
  cursor: pointer;
  background: #ffffff;
}

.drawer-rooms .room-item-card {
  box-sizing: border-box;
  width: 100%;
  height: 92px;
  min-height: 92px;
  padding: 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* 선택(현재 채팅) — Figma Card_Chat list: fill·stroke #eef0f2, radius 12 */
.drawer-rooms .room-item.active .room-item-card {
  background: #eef0f2;
  border-color: #eef0f2;
}

/* 호버·프레스 #e3e6e8 */
.drawer-rooms .room-item:hover:not(.room-item--placeholder) .room-item-card {
  background: #e3e6e8;
  border-color: #e3e6e8;
}

.drawer-rooms .room-item.active:hover:not(.room-item--placeholder) .room-item-card {
  background: #e3e6e8;
  border-color: #eef0f2;
}

.drawer-rooms .room-item--placeholder {
  cursor: default;
}

.drawer-rooms .room-item--placeholder:hover .room-item-card {
  background: transparent;
  border-color: transparent;
}

.drawer-rooms .room-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.drawer-rooms .room-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 21px;
}

.drawer-rooms .room-item-datetime {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.drawer-rooms .room-item-date,
.drawer-rooms .room-item-time {
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
  letter-spacing: 0;
  color: #929da5;
  white-space: nowrap;
}

.drawer-rooms .room-item-title {
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 22.5px;
  letter-spacing: 0;
  color: #171a1c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-rooms .room-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  min-width: 0;
}

.drawer-rooms .room-item-meta-part {
  font-family: 'Pretendard', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 19.5px;
  letter-spacing: 0;
  color: #6b7882;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-rooms .room-item-meta-dot {
  flex-shrink: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #b9c0c6;
}

.drawer-rooms .room-status-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  height: 21px;
  box-sizing: border-box;
  border-radius: 4px;
  font-family: 'Pretendard', sans-serif;
  font-weight: 500;
  font-size: 11px;
  line-height: 16.5px;
  letter-spacing: 0;
  white-space: nowrap;
}

.drawer-rooms .status-조치중 {
  background: #ebf2fe;
  color: #3676e0;
}

.drawer-rooms .status-조치완료 {
  background: #f6f7f7;
  color: #929da5;
}

.drawer-rooms .status-재방문예정,
.drawer-rooms .status-재방문필요 {
  background: #feebea;
  color: #fa7571;
}

/* ── 드로어 검색창 — Figma Input Field_Search (679:5857): 40px pill, #f6f7f7, 24px 아이콘 ── */
.drawer-search {
  padding: 12px 14px 8px;
  box-sizing: border-box;
}

.drawer-search-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  background: #f6f7f7;
  border-radius: 999px;
  overflow: hidden;
}

.drawer-search-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #525d65;
}

.drawer-search-icon img {
  flex-shrink: 0;
  display: block;
}

.drawer-search-clear {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.drawer-search-clear[hidden] {
  display: none;
}

.drawer-search-clear__icon {
  display: block;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.drawer-search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  padding: 0 4px 0 0;
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 22.5px;
  color: #171a1c;
}

.drawer-search-box input::placeholder {
  color: #929da5;
  font-weight: 500;
}

/* ── 드로어 상태 필터 — Figma Content Area_Short (816:12574) ── */
.drawer-filter {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  box-sizing: border-box;
  background: #ffffff;
}

.drawer-filter::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  box-sizing: border-box;
  height: 30px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid #eef0f2;
  border-radius: 999px;
  background: #ffffff;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  color: #6b7882;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-chip:hover:not(.active) {
  background: #f6f7f7;
}

.filter-chip.active {
  background: #32383d;
  border-color: #32383d;
  color: #ffffff;
  font-weight: 500;
}

.filter-chip:focus-visible {
  outline: 2px solid #32383d;
  outline-offset: 2px;
}

/* ── 새 채팅 / 채팅 목록 헤더 — 동일 타이포 (14 Medium, lh 21, letter-spacing 0); 색은 노드별 Figma 값 ── */
.drawer-new-chat__label,
.drawer-section-title {
  font-family: 'Pretendard', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 21px;
  letter-spacing: 0;
}

/* ── 새 채팅 시작하기 — Figma Button_New Chat (816:12575) / Text #171a1c ── */
.drawer-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  min-height: 56px;
  padding: 16px;
  cursor: pointer;
  background: #ffffff;
  border: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: #171a1c;
  transition: background 0.15s ease;
}
.drawer-new-chat__label {
  flex: 1;
  min-width: 0;
  color: #171a1c;
}
.drawer-new-chat__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: currentColor;
}
.drawer-new-chat__icon img {
  display: block;
}
/* 카드 호버와 동일 — Selected Background #e3e6e8 */
.drawer-new-chat:hover {
  background: #e3e6e8;
}
.drawer-new-chat:focus-visible {
  outline: 2px solid #32383d;
  outline-offset: -2px;
}

/* ── 채팅 목록 — Figma Content Area_Short (816:12576) 56px, Text #929da5 ── */
.drawer-section-title {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 17px 16px;
  color: #929da5;
}

/* 조회 실패 모달 — page-wrapper(360px) 안에만 덮음 (뷰포트 전체 X) */
.lookup-error-overlay {
  position: absolute;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.45);
}

.lookup-error-overlay.hidden {
  display: none !important;
}

.lookup-error-dialog {
  width: 100%;
  max-width: 328px;
  box-sizing: border-box;
  padding: 24px 20px 20px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.lookup-error-title {
  margin: 0;
  font-family: 'Pretendard', sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 27px;
  color: #171a1c;
  text-align: center;
}

.lookup-error-message {
  margin: 0;
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 22.5px;
  color: #6b7882;
  text-align: center;
  word-break: keep-all;
  white-space: pre-line;
}

.lookup-error-btn {
  margin-top: 8px;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #171a1c;
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 22.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lookup-error-btn:hover {
  background: transparent;
}

.lookup-error-btn:active {
  background: #171a1c;
  color: #ffffff;
}

/* 동일 이력 확인 — Figma Popup/Double Action (998:5705) */
.duplicate-history-overlay {
  position: absolute;
  inset: 0;
  z-index: 310;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.45);
}

.duplicate-history-overlay.hidden {
  display: none !important;
}

.duplicate-history-dialog {
  width: 100%;
  max-width: 312px;
  box-sizing: border-box;
  padding: 24px 26px 20px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

.duplicate-history-title {
  margin: 0;
  font-family: 'Pretendard', sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: 0;
  color: #171a1c;
  text-align: center;
}

.duplicate-history-message {
  margin: 0;
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 22.5px;
  letter-spacing: 0;
  color: #424b52;
  text-align: center;
  word-break: keep-all;
  white-space: pre-line;
}

.duplicate-history-actions {
  display: flex;
  flex-direction: row;
  gap: 12px;
  width: 100%;
}

.duplicate-history-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  border: none;
  border-radius: 4px;
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  line-height: 22.5px;
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.duplicate-history-btn:hover {
  opacity: 0.92;
}

.duplicate-history-btn:active {
  opacity: 0.85;
}

.duplicate-history-btn--secondary {
  background: #f6f7f7;
  color: #424b52;
  font-weight: 500;
}

.duplicate-history-btn--primary {
  background: #2e3338;
  color: #ffffff;
  font-weight: 600;
}

/* 모바일 화면에서는 고정 프레임 대신 기기 viewport 너비를 사용 */
@media (max-width: 767px) {
  body {
    background: #ffffff;
  }

  .page-wrapper {
    width: 100%;
    box-shadow: none;
  }

  /* 모바일 메인 헤더 고정 */
  .app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: #ffffff;
  }

  .form-main {
    padding-top: 96px;
  }
}
