/*
 * KAX VOUCHERS — Gift Certificate Desk (Scoped for KAX base.html)
 * 주의: base.html / main.css의 전역 스타일(body, header, footer)을 절대 덮어쓰지 않도록
 * .desk 및 #inquiry-modal 하위 컴포넌트로 스타일을 한정합니다.
 */

:root {
  --desk-surface: #faf3f2;
  --desk-border: #f2dedc;
  --rose-line: #e8d2cf;
  --card-border: #dec0bc;
  --burgundy: #7d3c40;
  --burgundy-hover: #642e32;
  --burgundy-soft: #faf3f2;
  --emerald: #065f46;
  --emerald-2: #115e59;
  --emerald-soft: #f4faf7;
  --charcoal: #1c1919;
  --ink: #2a2324;
  --muted: #7a6b6c;
  --white: #ffffff;
  --cream: #faf6f5;
  --settlement-bg: #1c1919;
  --radius: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --accent: var(--burgundy);
  --accent-hover: var(--burgundy-hover);
  --accent-soft: var(--burgundy-soft);
}

.desk [hidden],
.modal-backdrop[hidden] { display: none !important; }

.desk .num,
.modal .num { font-variant-numeric: tabular-nums; }

.desk .eyebrow,
.modal .eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--burgundy);
}

/* --- Desk layout ----------------------------------------------------- */

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  align-items: start;
  color: var(--ink);
}

.desk button,
.modal button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.desk button:disabled,
.modal button:disabled {
  cursor: default;
}

.desk__main {
  min-width: 0;
  background: var(--desk-surface);
  border: 1px solid var(--desk-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.desk__card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rose-line);
}

/* --- Steps (breadcrumb) ---------------------------------------------- */

.steps {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 8px;
  overflow-x: auto;
}
.steps__item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  white-space: nowrap;
}
.steps__item:disabled { opacity: .45; }
.steps__item.is-active { color: var(--accent); }
.steps__item.is-active .steps__name { font-weight: 800; }
.steps__no { font-size: 12px; font-weight: 700; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.steps__name { font-size: 14px; letter-spacing: -0.01em; }
.steps__rule { flex: 0 0 32px; height: 1px; background: var(--card-border); }

/* --- Stage (slide transition) ---------------------------------------- */

.stage { overflow: hidden; margin: 0 -8px; }

.stage__track {
  display: flex;
  align-items: flex-start;
  width: 200%;
  transition: transform .5s var(--ease);
}
.stage__track[data-step="1"] { transform: translateX(0); }
.stage__track[data-step="2"] { transform: translateX(-50%); }

.stage__panel { width: 50%; padding: 0 8px 4px; }
.stage__panel[inert] { max-height: 0; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .stage__track { transition: none; }
}

.panel-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 4px 16px;
  margin: 12px 0 18px;
}
.panel-head .eyebrow { grid-column: 1 / -1; color: var(--accent); }
.panel-head__title {
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--charcoal);
}

.text-button {
  padding: 6px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.text-button:hover { color: var(--accent-hover); }

.placeholder { color: var(--muted); }

/* --- Banknote card (공통 조형) --------------------------------------- */

.note {
  position: relative;
  isolation: isolate;
  background-color: var(--white);
  background-image:
    repeating-linear-gradient(135deg, rgba(125, 60, 64, .035) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(45deg, rgba(125, 60, 64, .025) 0 1px, transparent 1px 11px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  text-align: left;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.note::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 3px double rgba(125, 60, 64, .18);
  border-radius: 4px;
  pointer-events: none;
  z-index: -1;
}
button.note:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 30px -18px rgba(28, 25, 25, .45);
}
button.note[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
button.note[aria-pressed="true"]::before { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* --- Step 01: brand cards -------------------------------------------- */

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.brand-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  min-height: 176px;
  padding: 22px 22px 18px;
  width: 100%;
}
.brand-card > span { display: block; width: 100%; }
.brand-card__top { display: flex !important; justify-content: space-between; align-items: baseline; gap: 12px; }
.brand-card__series { font-size: 10px; letter-spacing: .22em; color: var(--muted); }
.brand-card__wordmark {
  display: block;
  margin: 14px 0 2px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--burgundy);
}
.brand-card__name { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--charcoal); }
.brand-card__range {
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--rose-line);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- Step 02: denomination cards (액면가만 표시) -------------------- */

.denom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 16px;
}
.denom-card { width: 100%; padding: 20px 22px; }
.denom-card__label { display: block; font-size: 10px; letter-spacing: .22em; color: var(--muted); }
.denom-card__face {
  display: block;
  margin: 10px 0 2px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--charcoal);
  font-variant-numeric: tabular-nums;
}
.denom-card__face small { font-size: 15px; font-weight: 700; margin-left: 2px; }

/* --- Step 02: order bar (수량 + 구매/판매 버튼) ---------------------- */

.order-bar {
  margin-top: 20px;
  padding: 18px 20px 20px;
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: 14px;
}
.order-bar[aria-disabled="true"] { opacity: .5; }
.order-bar[aria-disabled="true"] .stepper,
.order-bar[aria-disabled="true"] .trade-btn { pointer-events: none; }

.order-bar__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.order-bar__label { margin: 0; font-size: 16px; font-weight: 800; color: var(--charcoal); letter-spacing: -0.01em; }

.stepper {
  display: grid;
  grid-template-columns: 40px 64px 40px;
  height: 44px;
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.stepper__btn { background: none; border: 0; font-size: 18px; font-weight: 700; color: var(--muted); }
.stepper__btn:hover { color: var(--charcoal); }
.stepper__input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-left: 1px solid var(--rose-line);
  border-right: 1px solid var(--rose-line);
  text-align: center;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--charcoal);
  background: transparent;
  -moz-appearance: textfield;
}
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.order-bar__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.trade-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "top amount"
    "top unit";
  align-items: center;
  gap: 2px 12px;
  padding: 14px 18px;
  border: 0;
  border-radius: 10px;
  color: #ffffff !important;
  text-align: left;
  transition: background-color .2s, transform .1s;
}
.trade-btn:active { transform: translateY(1px); }
.trade-btn--buy { background: var(--burgundy); }
.trade-btn--buy:hover { background: var(--burgundy-hover); }
.trade-btn--sell { background: var(--emerald); }
.trade-btn--sell:hover { background: var(--emerald-2); }

.trade-btn__top { grid-area: top; display: flex; align-items: baseline; gap: 8px; }
.trade-btn__en { font-size: 11px; font-weight: 700; letter-spacing: .2em; opacity: .75; }
.trade-btn__label { font-size: 19px; font-weight: 900; letter-spacing: -0.02em; }
.trade-btn__amount { grid-area: amount; justify-self: end; font-size: 19px; font-weight: 900; }
.trade-btn__unit { grid-area: unit; justify-self: end; font-size: 12px; opacity: .8; }

/* --- Summary (우측 통합 명세 + 최종 정산) ---------------------------- */

.summary {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 116px);
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.summary__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--rose-line);
}
.summary__title { margin: 4px 0 0; font-size: 18px; font-weight: 900; letter-spacing: -0.02em; color: var(--charcoal); }
.summary__head .text-button { color: var(--muted); }
.summary__head .text-button:hover { color: var(--burgundy); }

.summary__lines {
  flex: 1;
  min-height: 96px;
  margin: 0;
  padding: 4px 22px;
  list-style: none;
  overflow-y: auto;
}
.summary__empty { padding: 22px 0; font-size: 13px; line-height: 1.6; color: var(--muted); }

.ledger-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--rose-line);
}
.ledger-line:last-child { border-bottom: 0; }
.ledger-line__tag {
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
}
.ledger-line--buy .ledger-line__tag { background: var(--burgundy); }
.ledger-line--sell .ledger-line__tag { background: var(--emerald); }
.ledger-line__name { font-size: 14px; font-weight: 700; color: var(--charcoal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-line__amount { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.ledger-line--buy .ledger-line__amount { color: var(--burgundy); }
.ledger-line--sell .ledger-line__amount { color: var(--emerald); }
.ledger-line__meta { grid-column: 2; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ledger-line__remove {
  grid-column: 3;
  justify-self: end;
  padding: 0;
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  font-size: 12px;
  color: var(--muted);
}
.ledger-line__remove:hover { color: var(--burgundy); }

.summary__totals { margin: 0; padding: 12px 22px; border-top: 1px solid var(--rose-line); }
.summary__row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; }
.summary__row dt { font-size: 13px; color: var(--muted); }
.summary__row dd { margin: 0; font-size: 16px; font-weight: 800; }
.summary__row--buy dd { color: var(--burgundy); }
.summary__row--sell dd { color: var(--emerald); }

/* NET SETTLEMENT — 에디토리얼 다크 차콜 */
.settlement {
  margin: 0;
  padding: 20px 22px 22px;
  background: var(--settlement-bg);
  color: #f4ecea;
}
.settlement__label { margin: 0; font-size: 10px; letter-spacing: .22em; color: #b9a8a6; }
.settlement__caption { margin: 8px 0 0; font-size: 13px; color: #d9cbc9; }
.settlement__result { margin: 4px 0 0; font-size: 32px; font-weight: 900; letter-spacing: -0.02em; }
.settlement[data-direction="pay"] .settlement__result { color: #f2c9cb; }
.settlement[data-direction="receive"] .settlement__result { color: #b8e6d3; }

.settlement__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.settlement__btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: #f4ecea !important;
  text-align: left;
  transition: background-color .16s ease, border-color .16s ease, opacity .16s ease;
}
.settlement__btn--reserve {
  background: var(--burgundy);
  border-color: var(--burgundy);
}
.settlement__btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.42);
}
.settlement__btn--reserve:hover:not(:disabled) {
  background: #673034;
  border-color: #673034;
}
.settlement__btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}
.settlement__btn-en {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .2em;
  opacity: .72;
}
.settlement__btn-ko {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.receipt-note {
  margin: 12px;
  padding: 14px 16px;
  border: 1px solid var(--emerald);
  border-radius: var(--radius);
  background: var(--emerald-soft);
  color: var(--charcoal);
  font-size: 13px;
  line-height: 1.55;
}
.receipt-note__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.receipt-note__badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--emerald);
}
.receipt-note__ref {
  font-size: 12px;
  font-weight: 800;
  color: var(--charcoal);
}
.receipt-note__body {
  margin: 0;
  color: var(--charcoal);
}

.error-note {
  margin: 12px;
  padding: 12px 14px;
  border: 1px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--burgundy-soft);
  color: var(--burgundy);
  font-size: 13px;
}

/* --- Inquiry & Reservation Modal ------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px 26px;
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.32);
  color: var(--ink);
}

.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rose-line);
}
.modal__title {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--charcoal);
}

.modal__digest {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--rose-line);
  border-radius: var(--radius);
  background: var(--cream);
}
.modal__digest-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--muted);
}
.modal__digest-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 150px;
  overflow-y: auto;
}
.modal__digest-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--rose-line);
  font-size: 13px;
}
.modal__digest-line:last-child { border-bottom: 0; }
.modal__digest-tag {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
}
.modal__digest-tag--buy { background: var(--burgundy); }
.modal__digest-tag--sell { background: var(--emerald); }
.modal__digest-meta {
  font-size: 12px;
  color: var(--muted);
}
.modal__digest-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rose-line);
  font-size: 12px;
  color: var(--muted);
}
.modal__digest-totals strong { color: var(--charcoal); font-weight: 800; }
.modal__digest-net {
  margin-left: auto;
  font-size: 13px;
  font-weight: 900;
  color: var(--charcoal);
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row[hidden] { display: none; }
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--charcoal);
}
.form-field__label em {
  margin-left: 4px;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: var(--burgundy);
}
.form-field__label span {
  margin-left: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.form-field__input,
.form-field__textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rose-line);
  border-radius: var(--radius);
  background: var(--white);
  font: inherit;
  font-size: 14px;
  color: var(--charcoal);
}
.form-field__textarea { resize: vertical; min-height: 76px; }
.form-field__input:focus,
.form-field__textarea:focus {
  outline: 2px solid var(--burgundy);
  outline-offset: -1px;
  border-color: var(--burgundy);
}

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.form-check input {
  margin-top: 2px;
  accent-color: var(--burgundy);
}

#modal-error {
  margin: 0;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--rose-line);
}
.modal__cancel {
  padding: 11px 18px;
  border: 1px solid var(--rose-line);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.modal__cancel:hover { color: var(--charcoal); border-color: var(--charcoal); }
.modal__submit {
  padding: 11px 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--burgundy);
  font-size: 13px;
  font-weight: 800;
  color: #ffffff !important;
}
.modal__submit:hover:not(:disabled) { background: #673034; }
.modal__submit:disabled { opacity: .5; cursor: not-allowed; }

/* --- Responsive ------------------------------------------------------ */

@media (max-width: 960px) {
  .desk { grid-template-columns: 1fr; }
  .summary { position: static; max-height: none; }
}

@media (max-width: 560px) {
  .desk__main { padding: 18px 16px; border-radius: 18px; }
  .summary { border-radius: 18px; }
  .order-bar__head { flex-direction: column; align-items: stretch; }
  .stepper { grid-template-columns: 44px 1fr 44px; }
  .order-bar__actions { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
