/* ============================================================
   CHECKOUT PAGE STYLES
   segma-commerce-theme/assets/css/checkout.css
   ============================================================ */

.segma-checkout-page {
  padding: 28px 0 60px;
}

/* Layout: form (right) + order summary (left) in RTL */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 28px;
  align-items: start;
}

/* Section titles */
.checkout-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--clr-border);
}

/* ── CHECKOUT FORM ───────────────────────────────────────────── */
.checkout-form-wrap {
  background: var(--clr-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
  order: 1; /* right column in RTL grid */
}

.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--clr-text);
}

.form-label .required {
  color: var(--clr-primary);
  margin-right: 3px;
}

.form-name-group {
  position: relative;
}

.form-input {
  width: 100%;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--clr-text);
  background: var(--clr-white);
  direction: rtl;
  text-align: right;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input::placeholder {
  color: #bbb;
  text-align: right;
}

.form-input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--shadow-primary-focus);
}

.form-input:invalid:not(:placeholder-shown),
.form-input.is-invalid {
  border-color: var(--clr-flash);
  box-shadow: 0 0 0 3px var(--shadow-flash-focus);
}

.form-input.is-valid {
  border-color: var(--clr-price-good);
}

/* Totals inside form (mobile only) */
.checkout-totals-mini {
  background: #f9f9f9;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: none; /* hidden on desktop, shown on mobile */
}

.checkout-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--clr-text-muted);
  border-bottom: 1px dashed var(--clr-border);
}

.checkout-total-row:last-child { border-bottom: none; }

.checkout-total-row--grand {
  font-size: 15px;
  font-weight: 700;
  color: var(--clr-text);
  padding-top: 10px;
}

.checkout-total-row--grand span:last-child {
  color: var(--clr-primary);
  font-size: 17px;
}

/* Submit button */
.checkout-submit-btn {
  font-size: 16px;
  padding: 13px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.checkout-submit-btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.checkout-submit-btn.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* ── ORDER SUMMARY ───────────────────────────────────────────── */
.checkout-order-summary {
  background: var(--clr-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
  order: 2;
  position: sticky;
  top: calc(var(--topbar-h) + var(--header-h) + 12px);
}

.checkout-order-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.checkout-order-table th {
  font-size: 12px;
  font-weight: 700;
  color: var(--clr-text-muted);
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1.5px solid var(--clr-border);
}

.checkout-order-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
  font-size: 13px;
}

.checkout-order-table tbody tr:last-child td { border-bottom: none; }

/* Product cell */
.co-product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.co-item-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.co-item-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--clr-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 140px;
}

.co-item-qty {
  font-size: 11px;
  color: var(--clr-text-muted);
  display: block;
}

.co-product-price {
  font-weight: 700;
  color: var(--clr-primary);
  white-space: nowrap;
}

/* Action icons */
.co-product-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.co-remove-btn,
.co-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  color: #bbb;
}

.co-remove-btn:hover { background: var(--shadow-flash-soft); color: var(--clr-flash); }
.co-edit-btn:hover   { background: var(--shadow-primary-soft); color: var(--clr-primary); }

/* Desktop totals (inside summary column) */
.checkout-totals-desktop {
  border-top: 1.5px solid var(--clr-border);
  padding-top: 12px;
}

.checkout-totals-desktop .checkout-total-row {
  padding: 7px 0;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .checkout-layout {
    grid-template-columns: 1fr;
  }

  .checkout-order-summary {
    order: 1; /* summary first on mobile */
    position: static;
  }

  .checkout-form-wrap { order: 2; }

  .checkout-totals-mini { display: block; }
  .checkout-totals-desktop { display: none; }
}

@media (max-width: 480px) {
  .checkout-form-wrap,
  .checkout-order-summary {
    padding: 16px;
    border-radius: var(--radius-sm);
  }

  .co-item-name { max-width: 100px; }

  .checkout-order-table th:nth-child(3),
  .checkout-order-table td:nth-child(3) {
    display: none;
  }
}

/* WooCommerce notices */
.woocommerce-notices-wrapper,
.woocommerce-error,
.woocommerce-message {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.woocommerce-error {
  background: #fff0f0;
  border: 1px solid #ffcdd2;
  color: #c0392b;
}

.woocommerce-message {
  background: #f0fff4;
  border: 1px solid #b2dfdb;
  color: var(--clr-price-good);
}


/* Shopingo French/LTR overrides */
body.segma-preset-shopingo .segma-checkout-page,
body.segma-preset-shopingo .checkout-layout,
body.segma-preset-shopingo .checkout-form,
body.segma-preset-shopingo .checkout-order-summary { direction: ltr; text-align: left; }
body.segma-preset-shopingo .form-input,
body.segma-preset-shopingo .checkout-form textarea,
body.segma-preset-shopingo .checkout-form select {
  direction: ltr;
  text-align: left;
}
body.segma-preset-shopingo .form-input::placeholder,
body.segma-preset-shopingo .checkout-form textarea::placeholder {
  direction: ltr;
  text-align: left;
}
body.segma-preset-shopingo .checkout-order-table th {
  text-align: left;
}
body.segma-preset-shopingo .checkout-submit-btn.loading::after {
  margin-right: 0;
  margin-left: 8px;
}
