.orders-page {
  max-width: 850px;
  margin-top: 140px; /* 60px (main header) + 50px (sub-header) + 30px extra */
  margin-bottom: 100px;
  padding-left: 30px;
  padding-right: 30px;

  /* margin-left: auto;
     margin-right auto;
     Is a trick for centering an element horizontally
     without needing a container. */
  margin-left: auto;
  margin-right: auto;
}

.page-title {
  font-weight: 700;
  font-size: 26px;
  margin-bottom: 25px;
  text-align: center;
}

.orders-grid {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 50px;
}

.order-header {
  background-color: rgb(240, 242, 242);
  border: 1px solid rgb(213, 217, 217);

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 20px 25px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.order-header-left-section {
  display: flex;
  flex-shrink: 0;
}

.order-header-label {
  font-weight: 500;
}

.order-date,
.order-total {
  margin-right: 45px;
}

.order-header-right-section {
  flex-shrink: 1;
}

@media (max-width: 575px) {
  .order-header {
    flex-direction: column;
    align-items: start;
    line-height: 23px;
    padding: 15px;
  }

  .order-header-left-section {
    flex-direction: column;
  }

  .order-header-label {
    margin-right: 5px;
  }

  .order-date,
  .order-total {
    display: grid;
    grid-template-columns: auto 1fr;
    margin-right: 0;
  }

  .order-header-right-section {
    display: grid;
    grid-template-columns: auto 1fr;
  }
}

@media (min-width: 576px) and (max-width: 640px) {
  .order-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .order-header-right-section { width: 100%; }
}

.order-details-grid {
  padding: 40px 25px;
  border: 1px solid rgb(213, 217, 217);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;

  display: grid;
  grid-template-columns: 110px 1fr 220px;
  column-gap: 35px;
  row-gap: 60px;
  align-items: center;
}

@media (max-width: 800px) {
  .order-details-grid {
    grid-template-columns: 110px 1fr;
    row-gap: 0;
    padding-bottom: 8px;
  }
}

@media (max-width: 450px) {
  .order-details-grid {
    grid-template-columns: 1fr;
  }
}

.product-image-container {
  text-align: center;
}

.product-image-container img {
  max-width: 110px;
  max-height: 110px;
}

.product-name {
  font-weight: 700;
  margin-bottom: 5px;
}

.product-delivery-date {
  margin-bottom: 3px;
}

.product-quantity {
  margin-bottom: 8px;
}

.buy-again-button {
  font-size: 15px;
  width: 140px;
  height: 36px;
  border-radius: 8px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.buy-again-icon {
  width: 25px;
  margin-right: 15px;
}

.product-actions {
  align-self: start;
}

.track-package-button {
  width: 100%;
  font-size: 15px;
  padding: 8px;
}

@media (max-width: 800px) {
  .buy-again-button {
    margin-bottom: 10px;
  }

  .product-actions {
    /* grid-column: 2 means this element will be placed
       in column 2 in the grid. (Normally, the column that
       an element is placed in is determined by the order
       of the elements in the HTML. grid-column overrides
       this default ordering). */
    grid-column: 2;
    margin-bottom: 30px;
  }

  .track-package-button {
    width: 140px;
  }
}

@media (max-width: 450px) {
  .product-image-container {
    text-align: center;
    margin-bottom: 25px;
  }

  .product-image-container img {
    max-width: 150px;
    max-height: 150px;
  }

  .product-name {
    margin-bottom: 10px;
  }

  .product-quantity {
    margin-bottom: 15px;
  }

  .buy-again-button {
    width: 100%;
    margin-bottom: 15px;
  }

  .product-actions {
    /* grid-column: auto; undos grid-column: 2; from above.
       This element will now be placed in its normal column
       in the grid. */
    grid-column: auto;
    margin-bottom: 70px;
  }

  .track-package-button {
    width: 100%;
    padding: 12px;
  }
}

/* Mobile main content adjustments for fixed header */
@media (max-width: 768px) {
  .orders-page {
    margin-top: 97px !important; /* 60px header + 32px sub-header + 5px gap */
    padding: 20px 15px !important;
  }
}

@media (max-width: 480px) {
  .orders-page {
    margin-top: 97px !important;
    padding: 15px 10px !important;
  }
}

@media (max-width: 320px) {
  .orders-page {
    margin-top: 92px !important; /* 55px header + 32px sub-header + 5px gap */
    padding: 15px 8px !important;
  }
}

/* ============================================
   Inquiry-history specific (orders.html)
   ============================================ */

/* Same styling as the checkout empty-cart message (checkout.css) */
.empty-orders {
  text-align: center;
  padding: 40px;
  min-height: 400px;
}

.empty-orders:not([hidden]) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.empty-orders-description {
  margin: 20px 0;
}

.empty-orders .continue-shopping-button {
  /* inline-flex centers the label vertically inside the 48px min-height
     that general.css enforces on button-styled anchors */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 10px;
  min-width: 140px;
}

.order-container-highlighted {
  animation: order-highlight-fade 2.5s ease-out 1;
}

@keyframes order-highlight-fade {
  0%   { box-shadow: 0 0 0 3px #ffd814; background-color: #fffbe6; }
  60%  { box-shadow: 0 0 0 3px rgba(255, 216, 20, 0.6); background-color: #fffbe6; }
  100% { box-shadow: 0 0 0 0 rgba(255, 216, 20, 0); background-color: transparent; }
}

.order-status {
  display: flex;
  flex-direction: column;
}

.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid #e7e7e7;
  margin-top: 12px;
}

.order-items-list[hidden] {
  display: none !important;
}

.order-item-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  align-items: start;
}

.order-item-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.order-item-image-link {
  display: block;
  width: 80px;
  height: 80px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.order-item-image-link:hover,
.order-item-image-link:focus-visible {
  border-color: #007185;
  transform: scale(1.03);
  outline: none;
}

.order-item-name-link {
  text-decoration: none;
  color: inherit;
}

.order-item-name-link:hover .order-item-name,
.order-item-name-link:focus-visible .order-item-name {
  color: #007185;
  text-decoration: underline;
}

.order-item-name { font-weight: 600; }
.order-item-code { font-size: 12px; color: #565959; margin-top: 2px; }

.order-item-qty {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 8px;
  border: 1px dashed #c4c4c4;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
  max-width: max-content;
}

.order-item-qty:hover,
.order-item-qty:focus-within {
  border-color: #007185;
  background-color: #f5fafc;
}

.order-item-qty.editing {
  cursor: default;
  border-style: solid;
  background-color: #fff;
}

.order-item-qty-primary { font-weight: 700; color: #0f1111; }
.order-item-qty-secondary { color: #565959; }
.order-item-qty-edit-hint {
  font-size: 11px;
  color: #007185;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.order-item-qty.editing .order-item-qty-edit-hint { display: none; }

.js-qty-input {
  width: 110px;
  padding: 4px 6px;
  font-size: 14px;
  border: 1px solid #c4c4c4;
  border-radius: 3px;
}

.js-qty-save,
.js-qty-cancel {
  cursor: pointer;
  font-size: 13px;
}

.order-item-qty-error {
  color: #b12704;
  font-size: 12px;
  width: 100%;
}

.order-item-line-total { font-size: 13px; color: #b12704; font-weight: 600; margin-top: 4px; }

.order-actions {
  display: grid;
  grid-template-areas:
    "resend details"
    "email email";
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin: 12px auto 0;
}

.order-resend-button {
  grid-area: resend;
  background-color: #128C7E;
  color: #ffffff;
}

.order-resend-button:hover,
.order-resend-button:focus {
  background-color: #0f7a6d;
  color: #ffffff;
}

.order-toggle-details { grid-area: details; }

/* Email fallback next to the WhatsApp resend button for buyers without WhatsApp. */
.order-email-fallback {
  grid-area: email;
  justify-self: center;
  text-align: center;
  font-size: 13px;
  text-decoration: none;
}

.order-email-fallback:hover {
  text-decoration: underline;
}

.order-resend-button,
.order-toggle-details {
  width: 100%;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 450px) {
  .order-actions {
    grid-template-areas:
      "resend"
      "details"
      "email";
    grid-template-columns: 1fr;
  }
}
