/* =========================================================
   Trung Tâm Khuyến Mãi — UI (Figma: UI_NICK)
   Desktop 1920 / Mobile 440. Mobile = desktop × 0.8
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  /* palette */
  --c-red:          #f92b01;
  --c-brown:        #602303;
  --c-ink:          #1d1d1d;
  --c-input-bg:     #f3ded6;
  --c-input-bd:     rgba(88, 42, 22, 0.2);
  --c-captcha-bg:   #f5ab95;
  --c-option-on:    #e0ffe7;
  --c-placeholder:  rgba(0, 0, 0, 0.4);
  --c-scroll:       #cecece;
  --c-ghost-bg:     #dadada;
  --c-ghost-tx:     #4e4e4e;

  --grad-red: linear-gradient(180deg,
      #ff682a 0%, #fb4e1f 25%, #f73415 50%,
      #f31a0a 75%, #f10d05 87.5%, #ef0000 100%);

  /* metrics — desktop */
  --card-w:      500px;
  --head-h:      70px;
  --head-lap:    17px;   /* body overlaps header */
  --pad-x:       12px;
  --pad-y:       23px;
  --r-card:      16px;
  --r-field:     12px;

  --gap-block:   44px;
  --gap-field:   20px;
  --gap-inner:   12px;
  --gap-icon:     8px;

  --icon:        32px;
  --input-h:     44px;
  --btn-h:       46px;
  --btn-w:      328px;
  --btn-w-sm:   178px;
  --btn-gap:     24px;

  --cap-w:      102px;
  --cap-inner-w:100px;
  --cap-inner-h: 40px;

  --menu-max:   230px;
  --menu-gap:     6px;
  --item-py:      6px;
  --item-px:      4px;
  --item-gap:     9px;
  --badge-w:    128px;
  --badge-h:     34px;

  --fs-tab:      24px;
  --fs-title:    24px;
  --fs-label:    20px;
  --fs-input:    16px;
  --fs-note:     18px;
  --fs-badge:    18px;
  --fs-btn:      18px;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
             "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-btn: "Roboto", var(--font-ui);
}

@media (max-width: 620px) {
  :root {
    --card-w:      min(400px, 100vw - 40px);
    --head-h:      56px;
    --head-lap:  13.6px;
    --pad-x:      9.6px;
    --pad-y:     18.4px;
    --r-card:    12.8px;
    --r-field:    9.6px;

    --gap-block:  35.2px;
    --gap-field:  16px;
    --gap-inner:  9.6px;
    --gap-icon:   6.4px;

    --icon:      25.6px;
    --input-h:   35.2px;
    --btn-h:     36.8px;
    --btn-w:    262.4px;
    --btn-w-sm: 142.4px;
    --btn-gap:   19.2px;

    --cap-w:     81.6px;
    --cap-inner-w:80px;
    --cap-inner-h:32px;

    --menu-max:  184px;
    --menu-gap:  4.8px;
    --item-py:   4.8px;
    --item-px:   3.2px;
    --item-gap:  7.2px;
    --badge-w:  102.4px;
    --badge-h:   27.2px;

    --fs-tab:    18px;
    --fs-title:  19.2px;
    --fs-label:  16px;
    --fs-input:  12.8px;
    --fs-note:   14.4px;
    --fs-badge:  14.4px;
    --fs-btn:    14.4px;
  }
}

@media (max-width: 400px) {
  :root { --fs-tab: 16px; --fs-label: 15px; }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: #fff;
  color: #000;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ---------- Page ---------- */
.page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.card {
  width: var(--card-w);
  filter: drop-shadow(2px 4px 43px rgba(0, 0, 0, 0.24));
}

/* =========================================================
   TABS
   ========================================================= */
.tabs {
  position: relative;
  height: var(--head-h);
  background: var(--c-brown);
  border-radius: var(--r-card) var(--r-card) 0 0;
  overflow: hidden;
}

.tabs__ind {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: none;
}
.tabs__ind--left  { left: 0;  width: 60.8%; }
.tabs__ind--right { right: 0; width: 46.8%; transform: scaleX(-1); }

.tabs[data-active="promo"] .tabs__ind--right,
.tabs[data-active="gift"]  .tabs__ind--left { display: none; }

.tab {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0;
  color: #fff;
  font-size: var(--fs-tab);
  font-weight: 500;
  text-transform: capitalize;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -0.2px;
  transition: font-weight 0.15s ease;
}
.tab.is-active { font-weight: 700; }
.tab--promo { left: 0;  width: 60%; justify-content: flex-start; padding-left: 3.6%; }
.tab--gift  { right: 0; width: 40%; justify-content: center; }

/* =========================================================
   CARD BODY
   ========================================================= */
.card__body {
  position: relative;
  z-index: 2;
  margin-top: calc(var(--head-lap) * -1);
  background: #fff;
  border-radius: var(--r-card);
  padding: var(--pad-y) var(--pad-x);
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-block);
}
.pane[hidden] { display: none; }

.pane__fields {
  display: flex;
  flex-direction: column;
  gap: var(--gap-field);
  width: 100%;
}

/* ---------- Field ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--gap-inner);
  width: 100%;
}
.field[hidden] { display: none; }

.field__head {
  display: flex;
  align-items: center;
  gap: var(--gap-icon);
}
.field__icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
}
.field__label {
  color: var(--c-red);
  font-size: var(--fs-label);
  font-weight: 700;
  line-height: 1.4;
}

/* ---------- Input ---------- */
.input {
  width: 100%;
  height: var(--input-h);
  padding: 0 var(--gap-icon);
  background: var(--c-input-bg);
  border: 1px solid var(--c-input-bd);
  border-radius: var(--r-field);
  font-size: var(--fs-input);
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s ease;
}
.input::placeholder { color: var(--c-placeholder); }
.input:focus { border-color: var(--c-red); }
.input.is-error { border-color: var(--c-red); box-shadow: 0 0 0 2px rgba(249, 43, 1, 0.15); }

/* ---------- Thông báo lỗi dưới input ---------- */
.err {
  margin: 0;
  color: var(--c-red);
  font-size: calc(var(--fs-input) * 0.9);
  font-weight: 500;
  line-height: 1.3;
}
.err[hidden] { display: none; }
/* bù lại gap của .field để lỗi bám sát ô nhập */
.field > .err { margin-top: calc(6px - var(--gap-inner)); }

/* ---------- Note ---------- */
.note {
  margin: 0;
  color: var(--c-red);
  font-size: var(--fs-note);
  font-weight: 500;
  line-height: 1.25;
}
.note--center { text-align: center; }

/* =========================================================
   CUSTOM SELECT (Thông tin khuyến mãi)
   ========================================================= */
.select { position: relative; width: 100%; }

.select__control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: var(--input-h);
  padding: 0 9px;
  background: #fff;
  border: 1px solid var(--c-input-bd);
  border-radius: var(--r-field);
  font-size: var(--fs-input);
  font-weight: 700;
  text-align: left;
  transition: border-color 0.15s ease;
}
.select__control:hover { border-color: rgba(88, 42, 22, 0.45); }
.select__control:focus-visible,
.native-select select:focus-visible {
  outline: 2px solid var(--c-red);
  outline-offset: 1px;
}
.select.is-open .select__control { border-color: var(--c-red); }

.select__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select__value.is-placeholder { color: #000; }

.select__chevron {
  width: calc(var(--fs-input) * 1.25);
  height: calc(var(--fs-input) * 1.25);
  flex: none;
  transition: transform 0.2s ease;
}
.select.is-open .select__chevron { transform: rotate(180deg); }

/* menu */
.select__menu {
  position: absolute;
  top: calc(100% + var(--menu-gap));
  left: 0;
  right: 0;
  z-index: 20;
  max-height: var(--menu-max);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  border: 1px solid var(--c-red);
  border-radius: var(--r-field);
  display: none;
}
.select.is-open .select__menu { display: block; }

/* scrollbar — matches the 6px / #cecece track in the design */
.select__menu { scrollbar-width: thin; scrollbar-color: var(--c-scroll) transparent; }
.select__menu::-webkit-scrollbar { width: 6px; }
.select__menu::-webkit-scrollbar-track { background: transparent; margin: 10px 0; }
.select__menu::-webkit-scrollbar-thumb { background: var(--c-scroll); border-radius: 24px; }
.select__menu::-webkit-scrollbar-button:vertical:start {
  height: 6px;
  background: url("../assets/arrow-drop-up.svg") center / 6px 6px no-repeat;
}
.select__menu::-webkit-scrollbar-button:vertical:end {
  height: 6px;
  background: url("../assets/arrow-drop-down.svg") center / 6px 6px no-repeat;
}

.promo-item {
  display: flex;
  align-items: center;
  gap: var(--item-gap);
  padding: var(--item-py) var(--item-px);
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.promo-item:hover,
.promo-item.is-selected { background: var(--c-option-on); }

.promo-item__badge {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--badge-w);
  height: var(--badge-h);
  padding: 0 10px;
  background: var(--c-red);
  border-radius: 36px;
  color: #fff;
  font-size: var(--fs-badge);
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
}
.promo-item__name {
  min-width: 0;
  font-size: var(--fs-input);
  font-weight: 700;
  line-height: 1.2;
}

/* =========================================================
   DETAIL BAR — thông tin đã nhập ở modal
   ========================================================= */
.detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-icon);
  width: 100%;
  min-height: var(--input-h);
  padding: 6px 9px;
  background: #fff;
  border: 1px solid var(--c-red);
  border-radius: var(--r-field);
}
.detail[hidden] { display: none; }

.detail__info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  min-width: 0;
  font-size: var(--fs-input);
  font-weight: 700;
  line-height: 1.3;
}
.detail__k {
  color: var(--c-red);
  font-weight: 500;
}
.detail__v {
  color: #000;
  word-break: break-word;
}

.detail__edit {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--c-red);
  border-radius: 36px;
  color: #fff;
  font-size: calc(var(--fs-input) * 0.875);
  font-weight: 600;
  line-height: 1;
  transition: filter 0.15s ease;
}
.detail__edit:hover { filter: brightness(1.1); }
.detail__edit svg {
  width: calc(var(--fs-input) * 0.95);
  height: calc(var(--fs-input) * 0.95);
  flex: none;
}

/* =========================================================
   NATIVE SELECT (Sảnh game)
   ========================================================= */
.native-select { position: relative; width: 100%; }
.native-select select {
  width: 100%;
  height: var(--input-h);
  padding: 0 calc(var(--fs-input) * 1.25 + 18px) 0 9px;
  background: #fff;
  border: 1px solid var(--c-red);
  border-radius: var(--r-field);
  font-size: var(--fs-input);
  font-weight: 700;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.native-select .select__chevron {
  position: absolute;
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
  pointer-events: none;
}

/* =========================================================
   CAPTCHA
   ========================================================= */
.captcha {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.captcha__row {
  display: flex;
  align-items: center;
  gap: var(--gap-icon);
  width: 100%;
}
.captcha__input { flex: 1 1 auto; min-width: 0; }

.captcha__btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cap-w);
  height: var(--input-h);
  background: var(--c-captcha-bg);
  border: 1px solid var(--c-input-bd);
  border-radius: var(--r-field);
  overflow: hidden;
}
.captcha__btn:active { transform: scale(0.97); }
.captcha__canvas {
  width: var(--cap-inner-w);
  height: var(--cap-inner-h);
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--btn-h);
  width: var(--btn-w-sm);
  border-radius: var(--r-field);
  font-family: var(--font-btn);
  font-size: var(--fs-btn);
  text-transform: uppercase;
  line-height: 1;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn--wide { width: var(--btn-w); max-width: 100%; }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--grad-red);
  color: #fff;
  font-weight: 900;
  text-shadow: 2px 2px 4px rgba(201, 18, 0, 0.91),
              -1px -1px 4px rgba(255, 255, 255, 0.56);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--primary[disabled] { filter: grayscale(0.4) brightness(0.9); cursor: not-allowed; }

.btn--ghost {
  background: var(--c-ghost-bg);
  color: var(--c-ghost-tx);
  font-weight: 700;
}
.btn--ghost:hover { background: #cfcfcf; }

/* =========================================================
   MODAL
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fade 0.18s ease;
}

.modal__panel {
  position: relative;
  width: var(--card-w);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-block);
  padding: var(--pad-y) var(--pad-x);
  background: #fff;
  border-radius: var(--r-card);
  animation: pop 0.2s ease;
}

.modal__content {
  display: flex;
  flex-direction: column;
  gap: var(--gap-field);
  width: 100%;
}

.modal__title {
  margin: 0;
  color: var(--c-red);
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.modal__actions {
  display: flex;
  align-items: center;
  gap: var(--btn-gap);
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 200;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 40px);
  padding: 12px 20px;
  background: rgba(30, 12, 4, 0.94);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-ok { background: rgba(10, 90, 35, 0.95); }
