/* Hide the standard selector + Add to cart when the grid replaces them */
.product-actions:has(.cg-hide-default) .product-variants,
.product-actions:has(.cg-hide-default) .product-add-to-cart .control-label,
.product-actions:has(.cg-hide-default) .product-add-to-cart .product-quantity,
.product-actions:has(.cg-hide-default) .product-add-to-cart .product-minimal-quantity,
body.cg-grid-active .product-actions .product-variants,
body.cg-grid-active .product-actions .product-add-to-cart .control-label,
body.cg-grid-active .product-actions .product-add-to-cart .product-quantity,
body.cg-grid-active .product-actions .product-add-to-cart .product-minimal-quantity {
  display: none;
}

.combination-grid {
  margin: 1.5rem 0;
}

.cg-table-wrap {
  overflow-x: auto;
}

.cg-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.9rem;
}

.cg-table th,
.cg-table td {
  border: 1px solid #e5e5e5;
  padding: 0.9rem 0.75rem;
  text-align: center;
  vertical-align: middle;
}

.cg-table th {
  background: #f6f6f6;
  font-weight: 700;
  color: #232323;
}

.cg-table td {
  color: #555;
}

.cg-table tr.cg-unavailable td {
  color: #aaa;
}

.cg-oos {
  font-size: 0.8rem;
  color: #c0392b;
}

.cg-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cg-qty-input {
  width: 64px;
  height: 40px;
  border: 1px solid #ccc;
  text-align: center;
  font-size: 0.9rem;
}

.cg-qty-input.cg-invalid {
  border-color: #c0392b;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15);
}

.cg-qty-buttons {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cg-btn {
  width: 22px;
  height: 19px;
  padding: 0;
  line-height: 1;
  font-size: 0.8rem;
  border: 1px solid #ccc;
  background: #fff;
  color: #555;
  cursor: pointer;
}

.cg-btn:hover {
  background: #f0f0f0;
}

.cg-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.cg-add[disabled] {
  opacity: 0.6;
  cursor: wait;
}

/* Popup */
.cg-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1060;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cg-modal.is-open {
  display: flex;
}

.cg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.cg-modal-box {
  position: relative;
  background: #fff;
  width: 100%;
  max-width: 460px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cg-modal-x {
  position: absolute;
  top: 8px;
  right: 12px;
  border: 0;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #777;
}

.cg-modal-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.cg-modal.is-error .cg-modal-title {
  color: #c0392b;
}

.cg-modal.is-success .cg-modal-title {
  color: #2e7d32;
}

.cg-modal-body ul {
  margin: 0;
  padding-left: 1.2rem;
}

.cg-modal-body li {
  margin-bottom: 0.3rem;
}

.cg-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.cg-modal.is-error .js-cg-checkout {
  display: none;
}

/* Phone: stack each combination as a card */
@media (max-width: 575px) {
  .cg-table thead {
    display: none;
  }

  .cg-table,
  .cg-table tbody,
  .cg-table tr,
  .cg-table td {
    display: block;
    width: 100%;
  }

  .cg-table tr {
    border: 1px solid #e5e5e5;
    margin-bottom: 0.75rem;
  }

  .cg-table td {
    border: 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    padding: 0.6rem 0.75rem;
  }

  .cg-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #232323;
    text-align: left;
  }
}
