/**
 * Kasro [price-calculation] shortcode
 */

.kasro-pcalc {
  box-sizing: border-box;
  width: 100%;
  padding: 20px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-family: inherit;
}

.kasro-pcalc *,
.kasro-pcalc *::before,
.kasro-pcalc *::after {
  box-sizing: border-box;
}

.kasro-pcalc__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px 16px;
  align-items: end;
  margin-bottom: 18px;
}

.kasro-pcalc__field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kasro-pcalc__field-label {
  font-size: 12px;
  line-height: 1.3;
  color: #6b7280;
  text-align: center;
}

.kasro-pcalc__value-box,
.kasro-pcalc__total-box {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.kasro-pcalc__field--total .kasro-pcalc__total-box {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #fef2f2;
  border-color: #fecaca;
  min-height: 56px;
}

.kasro-pcalc__unit-price {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
  text-align: center;
}

.kasro-pcalc__unit-price .woocommerce-Price-amount,
.kasro-pcalc__total .woocommerce-Price-amount {
  color: inherit;
  font-weight: inherit;
}

.kasro-pcalc__total-heading {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  line-height: 1.2;
}

.kasro-pcalc__total {
  font-size: 20px;
  font-weight: 700;
  color: #8b1a1a;
  line-height: 1.15;
  text-align: center;
}

.kasro-pcalc__qty {
  display: inline-flex;
  align-items: stretch;
  width: 100%;
  max-width: 132px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.kasro-pcalc__qty-btn {
  flex: 0 0 36px;
  width: 36px;
  padding: 0;
  border: none;
  background: #f3f4f6;
  color: #374151;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.kasro-pcalc__qty-btn:hover {
  background: #e5e7eb;
  color: #8b1a1a;
}

.kasro-pcalc__qty-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 10px 4px;
  border: none;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: #111827;
  appearance: textfield;
  -moz-appearance: textfield;
}

.kasro-pcalc__qty-input::-webkit-outer-spin-button,
.kasro-pcalc__qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.kasro-pcalc__qty-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(139, 26, 26, 0.15);
}

.kasro-pcalc__atc {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  margin: 0;
  border: none !important;
  border-radius: 8px !important;
  background: #8b1a1a !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.kasro-pcalc__atc:hover:not(:disabled) {
  background: #7f1d1d !important;
}

.kasro-pcalc__atc:active:not(:disabled) {
  transform: translateY(1px);
}

.kasro-pcalc__atc:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.kasro-pcalc__atc.loading {
  opacity: 0.85;
  pointer-events: none;
}

.kasro-pcalc__atc-loading {
  display: none;
}

.kasro-pcalc__atc.loading .kasro-pcalc__atc-loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: kasro-pcalc-spin 0.65s linear infinite;
}

.kasro-pcalc__hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #9ca3af;
  text-align: center;
}

.kasro-pcalc__notice {
  margin: 12px 0 0;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.kasro-pcalc__notice--error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.kasro-pcalc__notice[hidden] {
  display: none !important;
}

@keyframes kasro-pcalc-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .kasro-pcalc__grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .kasro-pcalc__field--total .kasro-pcalc__total-box {
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 14px;
  }

  .kasro-pcalc__total {
    font-size: 18px;
  }

  .kasro-pcalc__qty {
    max-width: 100%;
  }
}

/* Hide native WooCommerce qty + button when [price-calculation] is active */
html.kasro-has-price-calculation .wd-single-add-cart,
html.kasro-has-price-calculation .woocommerce-variation-add-to-cart,
html.kasro-has-price-calculation form.cart .quantity,
html.kasro-has-price-calculation form.cart > .single_add_to_cart_button,
html.kasro-has-price-calculation form.cart button.single_add_to_cart_button,
html.kasro-has-price-calculation form.cart button[name="add-to-cart"],
body.kasro-has-price-calculation .wd-single-add-cart,
body.kasro-has-price-calculation .woocommerce-variation-add-to-cart,
body.kasro-has-price-calculation form.cart .quantity,
body.kasro-has-price-calculation form.cart > .single_add_to_cart_button,
body.kasro-has-price-calculation form.cart button.single_add_to_cart_button,
body.kasro-has-price-calculation form.cart button[name="add-to-cart"] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
