/* =====================================================
   ALBERTINO ROSSI — COMMERCE V4

   Customer checkout, delivery configuration, merchant
   order fulfilment and customer profile presentation.
===================================================== */

[hidden] {
  display: none !important;
}

/* -----------------------------------------------------
   SHARED CLOSE CONTROLS
----------------------------------------------------- */

.checkout-heading .dialog-close,
.management-dialog .dialog-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #f1f1f3;
  color: #050505;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  font-size: 1.8rem;
  line-height: 1;
}

.checkout-heading .dialog-close:hover,
.checkout-heading .dialog-close:focus-visible,
.management-dialog .dialog-close:hover,
.management-dialog .dialog-close:focus-visible {
  background: #e4e4e7;
}

/* -----------------------------------------------------
   STOREFRONT CHECKOUT
----------------------------------------------------- */

.checkout-dialog {
  width: min(780px, calc(100% - 24px));
  max-height: min(92vh, 900px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 28px;
  color: #050505;
  background: #fff;
}

.checkout-dialog::backdrop {
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(4px);
}

.checkout-shell {
  padding: 23px;
}

.checkout-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e5e7;
}

.checkout-heading h2 {
  margin: 0;
  font: 500 clamp(1.7rem, 5vw, 2.6rem)/1.05 var(--store-font);
}

.checkout-heading .eyebrow {
  color: #050505;
}

.checkout-section {
  margin: 0;
  padding: 24px 0;
  border: 0;
  border-bottom: 1px solid #e5e5e7;
}

.checkout-section h3,
.checkout-section legend {
  margin: 0 0 15px;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.checkout-grid {
  display: grid;
  gap: 14px;
}

.checkout-grid label,
.delivery-settings-form label,
.management-form-grid label {
  display: grid;
  gap: 6px;
  font-size: .88rem;
  font-weight: 750;
}

.checkout-grid input,
.checkout-grid select,
.checkout-grid textarea,
.delivery-settings-form input,
.delivery-settings-form select,
.delivery-settings-form textarea,
.management-form-grid input,
.management-form-grid select,
.management-form-grid textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid #d8d8da;
  border-radius: 13px;
  outline: none;
  background: #fff;
  color: #050505;
  font: inherit;
}

.checkout-grid textarea,
.management-form-grid textarea {
  resize: vertical;
}

.checkout-grid input:focus,
.checkout-grid select:focus,
.checkout-grid textarea:focus,
.delivery-settings-form input:focus,
.delivery-settings-form select:focus,
.delivery-settings-form textarea:focus,
.management-form-grid input:focus,
.management-form-grid select:focus,
.management-form-grid textarea:focus {
  border-color: #050505;
  box-shadow: 0 0 0 3px rgba(5, 5, 5, .08);
}

.fulfilment-options {
  display: grid;
  gap: 10px;
}

.fulfilment-options legend {
  margin-bottom: 15px;
}

.fulfilment-options > label {
  position: relative;
  cursor: pointer;
}

.fulfilment-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fulfilment-options label > span {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px;
  border: 1px solid #dedee1;
  border-radius: 17px;
}

.fulfilment-options label small {
  color: #6f6f73;
}

.fulfilment-options input:checked + span {
  border-color: #050505;
  background: #050505;
  color: #fff;
}

.fulfilment-options input:checked + span small {
  color: #d2d2d5;
}

.fulfilment-options input:focus-visible + span {
  outline: 3px solid rgba(5, 5, 5, .18);
  outline-offset: 2px;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .88rem;
  font-weight: 700;
}

.check-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 2px;
  accent-color: #050505;
}

.billing-section {
  display: grid;
  gap: 18px;
}

.checkout-summary {
  display: grid;
  gap: 9px;
  margin: 22px 0;
  padding: 18px;
  border-radius: 18px;
  background: #f3f3f5;
}

.checkout-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.checkout-summary .checkout-total {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid #d6d6d9;
  font-size: 1.08rem;
}

.checkout-summary p {
  margin: 2px 0 0;
  color: #666;
  font-size: .8rem;
}

.marketing-row {
  margin: 20px 0;
}

.checkout-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.checkout-success {
  padding: 55px 10px 35px;
  text-align: center;
}

.checkout-success > span {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 25px;
  border-radius: 20px;
  background: #050505;
  color: #fff;
  font-size: 1.7rem;
}

.checkout-success h2 {
  font: 500 clamp(2rem, 6vw, 3rem)/1.05 var(--store-font);
}

.checkout-success p:not(.eyebrow) {
  max-width: 510px;
  margin: 0 auto 25px;
  color: #666;
}

/* -----------------------------------------------------
   MERCHANT MANAGEMENT
----------------------------------------------------- */

.dash-bottom-nav {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.view-record {
  border: 0;
  background: transparent;
  color: #050505;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.order-row .view-record {
  grid-column: 2;
  justify-self: end;
}

.status-on-hold {
  background: #050505 !important;
  color: #fff !important;
}

.management-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: 92vh;
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 28px;
}

.management-dialog::backdrop {
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
}

.management-dialog form {
  padding: 24px;
}

.management-dialog .dialog-title {
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid #e4e4e7;
}

.management-dialog .dialog-title h2 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}

.order-detail-grid,
.customer-profile-grid {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.order-detail-grid section,
.customer-profile-grid section {
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 16px;
  border-radius: 16px;
  background: #f3f3f5;
}

.order-detail-grid small,
.customer-profile-grid small {
  color: #747478;
}

.order-detail-grid span {
  color: #59595d;
  white-space: pre-line;
}

.order-lines {
  display: grid;
  margin: 20px 0;
  border-top: 1px solid #e4e4e7;
}

.order-lines > div,
.customer-order-history #customer-order-history > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 13px 0;
  border-bottom: 1px solid #e4e4e7;
}

.order-lines small,
.customer-order-history small {
  color: #707074;
}

.management-form-grid,
.delivery-settings-form {
  display: grid;
  gap: 14px;
}

.management-dialog .actions {
  justify-content: flex-end;
  margin-bottom: 0;
}

.customer-order-history {
  margin-top: 24px;
}

.customer-order-history h3 {
  margin-bottom: 8px;
}

.delivery-settings-block {
  padding-top: 0 !important;
}

.delivery-settings-form {
  margin-top: 20px;
  padding: 20px;
  border-radius: 18px;
  background: #f4f4f6;
}

.delivery-settings-form .settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.delivery-settings-form .settings-toggle input {
  width: 20px;
  min-height: 20px;
  flex: 0 0 20px;
  accent-color: #050505;
}

.delivery-settings-form .button {
  justify-self: start;
}

.delivery-settings-form .form-help {
  margin: 0;
  color: #68686d;
  font-size: .8rem;
  line-height: 1.5;
}

@media (min-width: 650px) {
  .checkout-shell,
  .management-dialog form {
    padding: 34px;
  }

  .checkout-grid,
  .order-detail-grid,
  .customer-profile-grid,
  .management-form-grid,
  .delivery-settings-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checkout-grid .wide,
  .order-detail-grid .wide,
  .customer-profile-grid .wide,
  .management-form-grid .wide,
  .delivery-settings-form .wide,
  .delivery-settings-form .button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .checkout-dialog,
  .management-dialog {
    width: 100%;
    max-width: none;
    max-height: 96vh;
    margin: auto 0 0;
    border-radius: 28px 28px 0 0;
  }

  .checkout-actions,
  .management-dialog .actions {
    flex-direction: column-reverse;
  }

  .checkout-actions .button,
  .checkout-actions .store-button,
  .management-dialog .actions .button {
    width: 100%;
  }

  .dash-bottom-nav small {
    font-size: .58rem;
  }
}
