/* 파크앤소프트 오픈요청서 — 기존 Flutter 화면(흰 배경, 외곽선 입력, 2열 반응형) 을 따른다 */

:root {
  --text: rgba(0, 0, 0, 0.87);
  --text-muted: rgba(0, 0, 0, 0.54);
  --border: rgba(0, 0, 0, 0.12);
  --outline: #757575;
  --outline-focus: #1976d2;
  --danger: #f44336;
  --success: #599e5d;
  --grey: #9e9e9e;
  --blue: #2196f3;
  /* 입력란·드롭다운 글자 크기. iOS Safari 는 16px 미만 입력란에 포커스가 가면 화면을 확대한 채 되돌리지 않으므로
     16px 아래로 내리지 않는다(로그인 직후 요청서 우측이 잘려 보이던 원인) */
  --field-font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

[hidden] { display: none !important; }

/* ── 로그인 ────────────────────────────────────────── */
/* 거래코드 입력란+버튼 행을 화면 정중앙에 두고 로고는 그 바로 위에 얹는다(로고는 중앙 계산에서 제외).
   카드를 1fr·auto·1fr 세 행으로 나누면 위·아래 행이 같은 높이가 되어 가운데 행(입력 행) 이 정중앙에 오고,
   로고는 첫 행의 바닥에 붙는다. 화면이 로고를 담기에 너무 낮으면 로고가 잘리는 대신 페이지가 스크롤된다 */
#sign-in {
  display: flex;
  justify-content: center;
  padding: 0 16px;
}

.sign-in-card {
  /* 입력 행을 정중앙에서 위로 올릴 거리. 0 = 정중앙, 기존 Flutter 배치와 같은 높이는 108px */
  --sign-in-lift: 0px;
  width: 300px;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--sign-in-lift) * 2);
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}

.sign-in-logo {
  align-self: end;
  width: 100%;
  padding: 0 5px;
  margin-bottom: 10px;
}

.sign-in-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.sign-in-field {
  flex: 1;
  margin: 0;
}

/* legend 가 테두리 위에 걸치는 만큼(대략 절반 높이) 아래로 내려 입력란 테두리와 같은 높이로 맞춘다 */
.icon-btn.sign-in-btn {
  align-self: stretch;
  margin-top: 8px;
  margin-bottom: 8px;
  width: 48px;
  height: auto;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
}

.icon-btn.sign-in-btn:hover { background: #1e88e5; }

/* ── 요청서 시트 ───────────────────────────────────── */
#request-form {
  padding: 20px 16px 40px;
}

.sheet {
  position: relative;
  max-width: 800px;
  margin: 20px auto 0;
  padding: 30px 30px 50px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
}

.title {
  margin: 10px 0 5px;
  font-size: 24px;
  font-weight: 700;
  /* 우측 상단 아이콘(관리자 4개: 40px × 4 + 간격) 과 겹치지 않게 비워 둔다 */
  padding-right: 175px;
}

.subtitle {
  margin: 0 0 40px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0 -30px;
}

.notice {
  margin: 40px 0 60px;
  font-size: 14px;
  font-weight: 700;
}

.section-title {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
}

.section-title:not(:first-of-type) {
  margin-top: 60px;
}

/* ── 입력 ─────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.grid .full { grid-column: 1 / -1; }

.field {
  margin: 0 0 8px;
  padding: 0 10px 8px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  min-width: 0;
}

.field legend {
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.field:focus-within {
  border-color: var(--outline-focus);
  border-width: 2px;
  padding: 0 9px 7px;
}

.field:focus-within legend { color: var(--outline-focus); }

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--field-font-size);
  padding: 6px 2px;
}

.field input:read-only { color: var(--text-muted); }

.field textarea { resize: vertical; min-height: 110px; }

.field select { cursor: pointer; }

/* ── 커스텀 드롭다운 (OS 기본 select 팝업 대신 직접 그린 목록) ── */
.dropdown { position: relative; }

.dropdown-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--field-font-size);
  text-align: left;
}

.dropdown-toggle:focus-visible { outline: none; }

.dropdown-arrow {
  width: 24px;
  height: 24px;
  fill: var(--text-muted);
  flex: none;
  transition: transform 0.15s ease-out;
}

.dropdown[data-open] .dropdown-arrow { transform: rotate(180deg); }

.dropdown-list {
  position: absolute;
  left: -10px;
  right: -10px;
  top: calc(100% + 10px);
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 20;
  max-height: 60vh;
  overflow-y: auto;
  outline: none;
}

.dropdown-option {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: var(--field-font-size);
  color: var(--text);
}

.dropdown-option:hover,
.dropdown-option[data-active] { background: rgba(0, 0, 0, 0.05); }

.dropdown-option[aria-selected="true"] {
  background: #e3f2fd;
  color: var(--outline-focus);
  font-weight: 700;
}

.dropdown-option[aria-selected="true"]:hover,
.dropdown-option[aria-selected="true"][data-active] { background: #d6ebfb; }

/* ── 초소·차로 ─────────────────────────────────────── */
#gates { padding: 0 5px; }

.gate {
  margin: 16px 0;
  padding: 8px;
  border: 1px solid var(--grey);
  border-radius: 5px;
}

.gate-header,
.lane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gate-header .gate-name {
  font-weight: 700;
  padding-left: 12px;
}

.lane {
  margin: 4px 10px;
  padding: 8px;
  border: 1px solid var(--grey);
  border-radius: 5px;
}

.devices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.device {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  cursor: pointer;
  user-select: none;
}

.device input {
  width: 18px;
  height: 18px;
  accent-color: var(--danger);
  cursor: pointer;
}

.gate-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.row-end {
  display: flex;
  justify-content: flex-end;
  padding: 20px 5px 0;
}

.submit-row {
  margin-top: 40px;
  padding: 0 5px;
}

/* ── 버튼 ─────────────────────────────────────────── */
button { font: inherit; cursor: pointer; }

.btn-outline {
  padding: 10px 18px;
  border: 1px solid #000000;
  border-radius: 5px;
  background: #ffffff;
  color: #000000;
}

.btn-outline:hover { background: #f5f5f5; }

.btn-primary {
  width: 100%;
  padding: 14px 24px;
  border: 0;
  border-radius: 5px;
  background: #212121;
  color: #ffffff;
  font-weight: 700;
}

.btn-primary:hover { background: #000000; }

.btn-primary:disabled,
.btn-outline:disabled { opacity: 0.5; cursor: default; }

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: rgba(0, 0, 0, 0.06); }

.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

.icon-btn.remove { color: var(--danger); width: 36px; height: 36px; }

/* ── 다이얼로그 (시트와 같은 흰 배경·외곽선 입력·짙은 버튼) ── */
.dialog {
  width: min(92vw, 420px);
  padding: 24px 24px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }

.dialog-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.dialog-message {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.dialog-field { margin-bottom: 4px; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.dialog-actions .btn-primary {
  width: auto;
  padding: 10px 20px;
}

.dialog-actions .btn-outline {
  padding: 10px 18px;
  border-color: var(--outline);
  color: var(--text);
}

.field-error {
  margin: 0 0 0 4px;
  font-size: 12px;
  color: var(--danger);
}

.dialog-field.invalid,
.dialog-field.invalid:focus-within { border-color: var(--danger); }

.dialog-field.invalid legend { color: var(--danger); }

/* 정산기 추가: 입력란이 여러 개라 간격을 두고, 종류 드롭다운 목록이 다이얼로그 밖으로 펼쳐질 수 있게 한다 */
#payment-device-dialog { overflow: visible; }

#payment-device-dialog .dialog-field { margin-top: 12px; }

.dialog-field:disabled { opacity: 0.5; }

.dialog-field:disabled .dropdown-toggle { cursor: default; }

/* 조회 결과·추가 전 확인 표시 */
.dialog-info {
  margin: 10px 4px 0;
  font-size: 14px;
  font-weight: 700;
}

.dialog-note {
  margin: 4px 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── 펼침 메뉴 (요청서 목록: 아이콘 바로 아래) ── */
.menu-anchor { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 240px;
  max-width: min(80vw, 420px);
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 30;
  outline: none;
}

.menu-item {
  display: block;
  min-height: 44px;
  padding: 12px 16px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.menu-item:hover,
.menu-item[data-active] { background: rgba(0, 0, 0, 0.05); }

/* ── 토스트 ────────────────────────────────────────── */
/* 데스크톱은 좌상단, 모바일(≤700px) 은 상단 중앙 고정. 위에서 살짝 내려오며 나타나고(0.2초), 사라질 때는 페이드아웃 */
.toast {
  position: fixed;
  left: 24px;
  top: 24px;
  transform: translate(0, -16px);
  opacity: 0;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 24px;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  text-align: center;
  pointer-events: none;
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

.toast.show {
  transform: translate(0, 0);
  opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ── 반응형 ────────────────────────────────────────── */
@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .sheet { padding: 24px 16px 40px; }
  .divider { margin: 0 -16px; }
  .title { padding-right: 0; margin-top: 44px; }
  .toolbar { top: 4px; right: 4px; }
  .toast { left: 50%; top: 16px; transform: translate(-50%, -16px); }
  .toast.show { transform: translate(-50%, 0); }
}
