/* ============================================================
   AURORA V2 — Add to Portfolio (Lot Builder) Modal
   ============================================================ */

body.lot-modal-open { overflow: hidden; }

.lot-modal {
  position: fixed;
  inset: 0;
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vw, 24px);
  font-family: var(--f-font-body, var(--f-font-ui));
  animation: lotModalIn 220ms cubic-bezier(.2,.8,.2,1);
}
@keyframes lotModalIn { from { opacity: 0; } to { opacity: 1; } }

.lot-modal__scrim {
  position: absolute;
  inset: 0;
  border: 0;
  cursor: pointer;
  background: rgba(20, 15, 10, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lot-modal__panel {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 40px);
  /* head + preview 固定，lot-list 取彈性空間並內部滾動，summary + actions 永遠可見 */
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr) auto auto;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 0% 0%, rgba(180, 140, 70, 0.10), transparent 38%),
    linear-gradient(180deg, #fffdf8 0%, #f5efe2 100%);
  border: 1px solid rgba(120, 89, 37, 0.22);
  box-shadow: 0 30px 60px rgba(20, 15, 10, 0.32), inset 0 1px 0 rgba(255,255,255,0.7);
  animation: lotPanelIn 280ms cubic-bezier(.2,.8,.2,1);
}
@keyframes lotPanelIn {
  from { transform: translateY(14px) scale(.985); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* — Header — */
.lot-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  border-bottom: 1px dashed rgba(120, 89, 37, 0.28);
}
.lot-modal__eyebrow {
  font-family: var(--f-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(135, 70, 28, 0.92);
}
.lot-modal__title {
  margin: 4px 0 0;
  font-family: var(--f-font-display);
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--f-ink-1);
}
.lot-modal__close {
  width: 38px; height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(120, 89, 37, 0.28);
  background: rgba(255, 255, 255, 0.6);
  font-size: 22px;
  font-weight: 400;
  color: var(--f-ink-2);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.lot-modal__close:hover { background: rgba(255, 255, 255, 0.95); transform: rotate(90deg); }

/* — Card Preview — */
.lot-card-preview {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px dashed rgba(120, 89, 37, 0.20);
  background: rgba(255, 250, 240, 0.55);
}
.lot-card-preview__media { display: grid; gap: 8px; }
.lot-card-preview__photo {
  width: 160px;
  height: 200px;
  border-radius: 8px;
  background: #1a140f;
  overflow: hidden;
  position: relative;
  box-shadow: 0 6px 16px rgba(20, 15, 10, 0.22);
  display: grid;
  place-items: center;
}
.lot-card-preview__photo img {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #1a140f;
}
.lot-card-preview__placeholder {
  font-family: var(--f-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(229, 184, 95, 0.6);
}

.lot-card-preview__upload {
  display: grid;
  gap: 4px;
}

.lot-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid rgba(120, 89, 37, 0.28);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.95);
  color: var(--f-ink-2);
  font-family: var(--f-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}
.lot-upload-btn:hover { border-color: rgba(145, 99, 39, 0.85); transform: translateY(-1px); }
.lot-upload-btn__icon { width: 14px; height: 14px; display: inline-flex; }
.lot-upload-btn__icon svg { width: 100%; height: 100%; }

.lot-upload-reset {
  background: none; border: 0; padding: 4px 0;
  font-family: var(--f-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  color: rgba(105, 78, 30, 0.78);
  cursor: pointer;
  text-align: center;
}
.lot-upload-reset:hover { color: var(--f-ink-1); }

.lot-card-preview__copy { display: grid; gap: 6px; align-content: center; min-width: 0; }
.lot-card-preview__brand {
  font-family: var(--f-font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(135, 70, 28, 0.92);
}
.lot-card-preview__name {
  font-family: var(--f-font-display);
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--f-ink-1);
  line-height: 1.15;
  word-break: break-word;
}
.lot-card-preview__hint {
  font-family: var(--f-font-ui);
  font-size: 12.5px;
  color: var(--f-ink-3);
  line-height: 1.55;
}

/* — Lot list section — */
.lot-list-section {
  padding: 18px 28px 12px;
  overflow: auto;
  min-height: 0; /* critical for grid 1fr child overflow */
  /* sticky 控制：confirm bar (summary + actions) 永遠固定不被擠掉 */
}
.lot-list-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.lot-list-section__title {
  font-family: var(--f-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: rgba(105, 78, 30, 0.85);
}
.lot-list-section__add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.4px solid rgba(145, 99, 39, 0.62);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.92);
  color: rgba(135, 70, 28, 0.95);
  font-family: var(--f-font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.lot-list-section__add:hover { background: var(--f-ink-1); color: #f7e9c5; border-color: var(--f-ink-1); transform: translateY(-1px); }

.lot-list { display: grid; gap: 10px; }

/* — Single Lot Row — */
.lot-row {
  position: relative;
  padding: 14px 16px 12px;
  border: 1px solid rgba(120, 89, 37, 0.18);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(247, 240, 224, 0.85));
  box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset, 0 4px 10px rgba(70, 48, 16, 0.06);
  animation: lotRowIn 200ms ease-out both;
}
@keyframes lotRowIn {
  from { transform: translateY(-4px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.lot-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.lot-row__index {
  font-family: var(--f-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(135, 70, 28, 0.92);
}
.lot-row__remove {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(120, 89, 37, 0.22);
  background: rgba(255, 250, 240, 0.85);
  color: var(--f-ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: all 160ms ease;
}
.lot-row__remove:hover { background: #c25538; color: #fff5dc; border-color: #962a18; transform: rotate(90deg); }

.lot-row__grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.4fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .lot-row__grid { grid-template-columns: 1fr 1fr; }
  .lot-row__grid .lot-field--price { grid-column: 1 / -1; }
}

.lot-field { display: grid; gap: 4px; min-width: 0; }
.lot-field__label {
  font-family: var(--f-font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(105, 78, 30, 0.72);
}
.lot-field__input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(120, 89, 37, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--f-ink-1);
  font-family: var(--f-font-ui);
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.lot-field__input:focus {
  border-color: rgba(145, 99, 39, 0.85);
  box-shadow: 0 0 0 3px rgba(229, 184, 95, 0.22);
}
select.lot-field__input {
  background-image: linear-gradient(45deg, transparent 50%, rgba(120,89,37,0.55) 50%), linear-gradient(135deg, rgba(120,89,37,0.55) 50%, transparent 50%);
  background-position: calc(100% - 14px) 16px, calc(100% - 9px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}

.lot-field--price { min-width: 0; }
.lot-field__price-wrap {
  display: flex;
  gap: 6px;
  min-width: 0;
}
.lot-field__price-wrap .lot-field__input { flex: 1; min-width: 0; }
.lot-field__cur {
  width: 70px;
  height: 38px;
  padding: 0 26px 0 10px;
  border: 1px solid rgba(120, 89, 37, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--f-ink-1);
  font-family: var(--f-font-mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, rgba(120,89,37,0.55) 50%), linear-gradient(135deg, rgba(120,89,37,0.55) 50%, transparent 50%);
  background-position: calc(100% - 14px) 16px, calc(100% - 9px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

/* — Fees row — */
.lot-row__fees {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 234, 205, 0.45);
  border: 1px dashed rgba(120, 89, 37, 0.22);
}
.lot-fee-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.lot-fee-toggle input { width: 16px; height: 16px; accent-color: rgb(145, 99, 39); cursor: pointer; }
.lot-fee-toggle__copy {
  font-family: var(--f-font-ui);
  font-size: 12.5px;
  color: var(--f-ink-2);
}
.lot-fee-toggle__copy strong { color: var(--f-ink-1); font-weight: 700; }

.lot-shipping-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid rgba(120, 89, 37, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
}
.lot-shipping-input span {
  font-family: var(--f-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  color: rgba(105, 78, 30, 0.78);
}
.lot-shipping-input input {
  width: 60px;
  height: 24px;
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--f-font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--f-ink-1);
  text-align: right;
}

/* — Cost preview pills — */
.lot-row__cost-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(120, 89, 37, 0.16);
}
.lot-cost-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(120, 89, 37, 0.18);
  font-family: var(--f-font-mono);
  font-size: 11px;
  color: rgba(105, 78, 30, 0.85);
}
.lot-cost-pill strong {
  color: var(--f-ink-1);
  font-weight: 700;
  font-size: 12px;
}
.lot-cost-pill.is-total {
  background: var(--f-ink-1);
  border-color: var(--f-ink-1);
  color: rgba(247, 233, 197, 0.85);
}
.lot-cost-pill.is-total strong { color: #f7e9c5; }

/* — Summary footer — */
.lot-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px 28px;
  border-top: 1px dashed rgba(120, 89, 37, 0.28);
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.6), rgba(245, 234, 205, 0.5));
}
@media (max-width: 640px) { .lot-summary { grid-template-columns: 1fr 1fr; } }

.lot-summary__cell {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(120, 89, 37, 0.16);
}
.lot-summary__cell.is-total {
  background: var(--f-ink-1);
  border-color: var(--f-ink-1);
}
.lot-summary__label {
  font-family: var(--f-font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(105, 78, 30, 0.72);
}
.lot-summary__cell.is-total .lot-summary__label { color: rgba(229, 184, 95, 0.78); }
.lot-summary__value {
  font-family: var(--f-font-display);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
  color: var(--f-ink-1);
}
.lot-summary__cell.is-total .lot-summary__value { color: #f7e9c5; }

/* — Actions — */
.lot-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 28px 18px;
  border-top: 1px solid rgba(120, 89, 37, 0.16);
}

@media (max-width: 640px) {
  .lot-card-preview { grid-template-columns: 1fr; }
  .lot-card-preview__photo { width: 100%; height: 240px; }
  .lot-modal__head { padding: 18px 18px 12px; }
  .lot-list-section { padding: 16px 18px 8px; }
  .lot-summary { padding: 14px 18px; }
  .lot-modal__actions { padding: 12px 18px 16px; }
}
