/* =========================================================================
   Tango School — Pagina Checkout (shortcode [tango_checkout])
   Estratto da assets/tango.css (FASE B).
   Layout 1 colonna mobile, 2 colonne desktop (riepilogo prodotto + form pagamento).
   Copre Stripe Elements e pagamento in segreteria (COD).
   ========================================================================= */

/* ---------- Container checkout ---------- */
.ts-card .ts-checkout-container,
.ts-checkout-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ts-s-8);
  margin-top: var(--ts-s-5);
  width: 100%;
  box-sizing: border-box;
  max-width: 800px;
  margin-inline: auto;
}

#ts-checkout-message { scroll-margin-top: 24px; }
.ts-checkout-actions .ts-btn[aria-busy="true"] { cursor: wait; opacity: .72; }

/* ---------- Card riepilogo prodotto ---------- */
.ts-checkout-product,
.ts-card .ts-checkout-product {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  padding: var(--ts-s-6);
  border-radius: var(--ts-r-3);
  border: 1px solid #e9ecef;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform var(--ts-dur-base) var(--ts-ease),
              box-shadow var(--ts-dur-base) var(--ts-ease);
}

.ts-checkout-product:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.ts-checkout-product h3 {
  margin: 0 0 var(--ts-s-5);
  color: var(--ts-red);
  font-size: 1.4em;
  font-weight: 700;
  border-bottom: 2px solid var(--ts-red);
  padding-bottom: var(--ts-s-3);
}

.ts-product-summary {
  background: var(--ts-paper);
  padding: var(--ts-s-5);
  border-radius: var(--ts-r-2);
  border: 1px solid #e9ecef;
}

.ts-product-summary h4 {
  margin: 0 0 var(--ts-s-4);
  color: var(--ts-ink);
  font-size: 1.2em;
  font-weight: 600;
  line-height: 1.3;
}

/* ---------- Card form pagamento ---------- */
.ts-checkout-form,
.ts-card .ts-checkout-form {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  padding: var(--ts-s-6);
  border-radius: var(--ts-r-3);
  border: 1px solid #e9ecef;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform var(--ts-dur-base) var(--ts-ease),
              box-shadow var(--ts-dur-base) var(--ts-ease);
}

.ts-checkout-form:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.ts-checkout-form h3 {
  margin: 0 0 var(--ts-s-5);
  color: var(--ts-red);
  font-size: 1.4em;
  font-weight: 700;
  border-bottom: 2px solid var(--ts-red);
  padding-bottom: var(--ts-s-3);
}

.ts-checkout-form p {
  color: var(--ts-gray-dark);
  line-height: 1.6;
  margin-bottom: var(--ts-s-5);
}

/* ---------- Bottone "torna indietro" ---------- */
.ts-checkout-back {
  margin-top: var(--ts-s-6);
  padding-top: var(--ts-s-4);
  border-top: 1px solid #e0e0e0;
}

.ts-checkout-back .ts-btn {
  padding: var(--ts-s-3) var(--ts-s-5);
  font-weight: 500;
  border-radius: var(--ts-r-1);
  text-decoration: none;
  display: inline-block;
  transition: all var(--ts-dur-base) var(--ts-ease);
}

.ts-checkout-back .ts-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

/* ---------- Opzioni di pagamento (radio card) ---------- */
.ts-payment-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ts-s-3);
  margin-bottom: var(--ts-s-8);
}

@media (min-width: 640px) {
  .ts-payment-options {
    grid-template-columns: 1fr 1fr;
    gap: var(--ts-s-4);
  }
}

.ts-payment-option {
  position: relative;
}

.ts-payment-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ts-payment-option label {
  display: block;
  padding: var(--ts-s-6);
  border: 2px solid #e0e0e0;
  border-radius: var(--ts-r-2);
  cursor: pointer;
  transition: all var(--ts-dur-base) var(--ts-ease);
  background: var(--ts-paper);
}

@media (max-width: 639.98px) {
  .ts-payment-option label {
    padding: var(--ts-s-4);
  }
}

.ts-payment-option label:hover {
  border-color: var(--ts-red);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ts-payment-option input[type="radio"]:checked + label {
  border-color: var(--ts-red);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.05) 0%, rgba(192, 57, 43, 0.05) 100%);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

.ts-payment-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: var(--ts-s-2);
}

@media (max-width: 639.98px) {
  .ts-payment-icon {
    font-size: 1.5rem;
  }
}

.ts-payment-title {
  display: block;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ts-ink);
  margin-bottom: var(--ts-s-1);
}

.ts-payment-desc {
  display: block;
  font-size: 0.9rem;
  color: var(--ts-gray-dark);
}

/* ---------- Form pagamento ---------- */
.ts-payment-form {
  margin-top: var(--ts-s-6);
}

/* ---------- Cash on Delivery / Pagamento segreteria ---------- */
.ts-cod-info {
  background: #f8f9fa;
  padding: var(--ts-s-6);
  border-radius: var(--ts-r-2);
  margin-bottom: var(--ts-s-6);
}

.ts-cod-details {
  margin: var(--ts-s-4) 0;
}

.ts-cod-details .ts-info-item,
.ts-stripe-details .ts-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--ts-s-3) 0;
  border-bottom: 1px solid #e0e0e0;
}

.ts-cod-details .ts-info-item:last-child,
.ts-stripe-details .ts-info-item:last-child {
  border-bottom: none;
}

.ts-cod-note {
  background: #e3f2fd;
  padding: var(--ts-s-4);
  border-radius: var(--ts-r-1);
  margin-top: var(--ts-s-4);
  border-left: 4px solid var(--ts-red);
}

/* ---------- Stripe info ---------- */
.ts-stripe-info {
  background: #f8f9fa;
  padding: var(--ts-s-6);
  border-radius: var(--ts-r-2);
  margin-bottom: var(--ts-s-6);
}

.ts-stripe-details {
  margin: var(--ts-s-4) 0;
}

.ts-stripe-note {
  background: #fff3cd;
  padding: var(--ts-s-4);
  border-radius: var(--ts-r-1);
  margin-top: var(--ts-s-4);
  border-left: 4px solid #ffc107;
  color: #856404;
}

/* ---------- Azioni finali ---------- */
.ts-checkout-actions {
  display: flex;
  flex-direction: column;
  gap: var(--ts-s-4);
  margin-top: var(--ts-s-6);
}

@media (min-width: 640px) {
  .ts-checkout-actions {
    flex-direction: row;
  }
}

.ts-checkout-actions .ts-btn {
  flex: 1;
  text-align: center;
  padding: var(--ts-s-3) var(--ts-s-5);
  font-weight: 600;
  border-radius: var(--ts-r-2);
  transition: all var(--ts-dur-base) var(--ts-ease);
  text-decoration: none;
  display: inline-block;
}

.ts-checkout-actions .ts-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ts-checkout-actions .ts-btn-secondary {
  background: var(--ts-gray-light);
  color: var(--ts-ink);
  border: 2px solid var(--ts-gray);
}

.ts-checkout-actions .ts-btn-secondary:hover {
  background: #e9ecef;
  border-color: var(--ts-red);
  color: var(--ts-red);
}

.ts-checkout-actions .ts-btn-primary {
  background: linear-gradient(135deg, var(--ts-red) 0%, var(--ts-red-deep) 100%);
  color: var(--ts-paper);
  border: 2px solid var(--ts-red);
}

.ts-checkout-actions .ts-btn-primary:hover {
  background: linear-gradient(135deg, var(--ts-red-deep) 0%, var(--ts-red) 100%);
  border-color: var(--ts-red-deep);
}

/* ---------- Alert specifici checkout ---------- */
.ts-checkout-container .ts-alert {
  margin: 0;
  border-radius: var(--ts-r-2);
  border-left-width: 4px;
}

.ts-checkout-container .ts-alert h3 {
  margin: 0 0 var(--ts-s-3);
  font-size: 1.1em;
  border: none;
  padding: 0;
}

.ts-checkout-container .ts-alert p {
  margin: 0 0 var(--ts-s-4);
  font-size: 0.95em;
}

/* ---------- Prezzo dentro il box prodotto checkout ---------- */
.ts-checkout-container .ts-product-price {
  margin: var(--ts-s-4) 0;
  padding: var(--ts-s-4);
  background: #f8f9fa;
  border-radius: var(--ts-r-1);
  border: 1px solid #e9ecef;
}

.ts-checkout-container .ts-price-strikethrough {
  font-size: 1.1em;
  margin-right: var(--ts-s-3);
}

.ts-checkout-container .ts-price-effective {
  font-size: 1.4em;
  font-weight: 700;
}

/* ---------- Header con logout dentro checkout ---------- */
.ts-checkout-container .ts-header-with-logout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--ts-s-6);
  padding-bottom: var(--ts-s-4);
  border-bottom: 2px solid var(--ts-gray);
}

@media (max-width: 767.98px) {
  .ts-checkout-container .ts-header-with-logout {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ts-s-4);
  }

  .ts-checkout-container .ts-logout-btn {
    width: 100%;
    text-align: center;
  }
}

.ts-checkout-container .ts-title {
  margin: 0;
  color: var(--ts-red);
  font-size: 1.8em;
  font-weight: 700;
}

.ts-checkout-container .ts-logout-btn {
  padding: var(--ts-s-2) var(--ts-s-4);
  font-size: 0.9em;
  border-radius: var(--ts-r-1);
}

/* ---------- Info-item riepilogo ---------- */
.ts-checkout-info {
  background: var(--ts-paper);
  padding: var(--ts-s-5);
  border-radius: var(--ts-r-2);
  border: 1px solid #e9ecef;
  margin: var(--ts-s-5) 0;
}

.ts-info-item {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--ts-s-4);
  padding: var(--ts-s-3);
  background: #f8f9fa;
  border-radius: var(--ts-r-1);
  border-left: 3px solid var(--ts-red);
}

.ts-info-item:last-child {
  margin-bottom: 0;
}

.ts-info-item strong {
  color: var(--ts-red);
  font-size: 0.95em;
  font-weight: 600;
  margin-bottom: var(--ts-s-1);
}

.ts-info-item span {
  color: var(--ts-gray-dark);
  font-size: 0.85em;
  line-height: 1.4;
}

/* ---------- Bottoni dentro alert ---------- */
.ts-alert .ts-btn {
  margin-top: var(--ts-s-4);
  display: inline-block;
  padding: var(--ts-s-3) var(--ts-s-5);
  font-weight: 600;
  border-radius: var(--ts-r-1);
  text-decoration: none;
  transition: all var(--ts-dur-base) var(--ts-ease);
}

.ts-alert .ts-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ts-alert .ts-btn-primary {
  background: linear-gradient(135deg, var(--ts-red) 0%, var(--ts-red-deep) 100%);
  color: var(--ts-paper);
  border: 2px solid var(--ts-red);
}

.ts-alert .ts-btn-primary:hover {
  background: linear-gradient(135deg, var(--ts-red-deep) 0%, var(--ts-red) 100%);
  border-color: var(--ts-red-deep);
  color: var(--ts-paper);
}

/* ---------- Form Stripe (card element) ---------- */
.ts-checkout-payment {
  background: var(--ts-paper);
  padding: var(--ts-s-5);
  border-radius: var(--ts-r-2);
  border: 1px solid #e9ecef;
  margin: var(--ts-s-5) 0;
}

.ts-payment-section h4 {
  margin: 0 0 var(--ts-s-4);
  color: var(--ts-red);
  font-size: 1.1em;
  font-weight: 600;
}

#ts-card-element {
  background: #f8f9fa;
  padding: var(--ts-s-4);
  border: 1px solid #e9ecef;
  border-radius: var(--ts-r-1);
  margin-bottom: var(--ts-s-4);
  transition: border-color var(--ts-dur-base) var(--ts-ease);
}

#ts-card-element:focus-within {
  border-color: var(--ts-red);
  box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.1);
}

#ts-card-errors {
  color: var(--ts-red-deep);
  font-size: 0.9em;
  margin-top: var(--ts-s-3);
  padding: var(--ts-s-3);
  background: var(--ts-red-pastel);
  border: 1px solid var(--ts-red-soft);
  border-radius: var(--ts-r-1);
  display: none;
}

#ts-card-errors.show {
  display: block;
}

#ts-submit-payment {
  position: relative;
}

#ts-submit-payment:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#ts-submit-payment.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: ts-spin 1s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes ts-spin {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ---------- Responsive extra: mobile stretto ---------- */
@media (max-width: 479.98px) {
  .ts-card .ts-checkout-container {
    gap: var(--ts-s-4);
    padding: 0 var(--ts-s-1);
  }

  .ts-card .ts-checkout-product,
  .ts-card .ts-checkout-form {
    padding: var(--ts-s-4);
  }

  .ts-card .ts-checkout-product h3,
  .ts-card .ts-checkout-form h3 {
    font-size: 1.1em;
  }

  .ts-checkout-container .ts-title {
    font-size: 1.2em;
  }

  .ts-product-summary h4 {
    font-size: 1.1em;
  }

  .ts-checkout-container .ts-product-price {
    padding: var(--ts-s-3);
  }

  .ts-checkout-container .ts-price-effective {
    font-size: 1.2em;
  }

  .ts-checkout-actions .ts-btn,
  .ts-checkout-back .ts-btn {
    padding: var(--ts-s-3) var(--ts-s-4);
    font-size: 0.95em;
  }

  .ts-payment-title {
    font-size: 0.95em;
  }

  .ts-payment-desc {
    font-size: 0.85em;
  }
}

/* ---------- Esperienza studente 2026 ----------
   Override finale intenzionalmente scoped: conserva i selettori usati dal JS
   di pagamento, ma riallinea il checkout allo shop e all'area personale. */
.ts-view-checkout .ts-card:not(.ts-checkout-card) {
  width: min(100%, 760px);
  margin-inline: auto;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid #eadfe0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 28px rgb(47 14 18 / 7%);
}

.ts-view-checkout .ts-card:not(.ts-checkout-card) .ts-header-with-logout {
  margin-bottom: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid #eee7e7;
}

.ts-view-checkout .ts-card:not(.ts-checkout-card) .ts-alert { margin: 0; }

.ts-view-checkout .ts-checkout-card {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid #eadfe0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 28px rgb(47 14 18 / 7%);
}

.ts-checkout-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee7e7;
}

.ts-checkout-eyebrow {
  display: block;
  color: var(--ts-red-deep, #8f1724);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .11em;
  line-height: 1.3;
  text-transform: uppercase;
}

.ts-checkout-header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 16px;
}

.ts-checkout-header-actions a {
  min-height: 36px;
  color: #3d3536;
  font-size: .82rem;
  font-weight: 600;
  line-height: 36px;
  text-decoration: underline;
  text-decoration-color: #cfc5c5;
  text-underline-offset: 4px;
}

.ts-checkout-header-actions a:hover { color: var(--ts-red-deep, #8f1724); }

.ts-view-checkout .ts-card .ts-checkout-container {
  grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
  align-items: start;
  gap: clamp(14px, 2.2vw, 24px);
  max-width: none;
  margin-top: 14px;
}

.ts-view-checkout .ts-card :where(.ts-checkout-product, .ts-checkout-form) {
  min-width: 0;
  padding: clamp(16px, 2.6vw, 24px);
  border: 1px solid #eadfe0;
  border-radius: 13px;
  background: #fff;
  box-shadow: none;
  transform: none;
}

.ts-view-checkout .ts-card :where(.ts-checkout-product, .ts-checkout-form):hover {
  box-shadow: none;
  transform: none;
}

.ts-view-checkout .ts-card :where(.ts-checkout-product, .ts-checkout-form) > h2 {
  margin: 5px 0 13px;
  padding: 0;
  border: 0;
  color: var(--ts-ink);
  font-family: var(--ts-font-serif);
  font-size: clamp(1.2rem, 2.6vw, 1.5rem);
  font-weight: 700;
  line-height: 1.15;
  text-transform: uppercase;
}

.ts-view-checkout .ts-card .ts-product-summary {
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid #eee7e7;
  border-radius: 0;
  background: transparent;
}

.ts-view-checkout .ts-product-price { margin-bottom: 12px; }
.ts-view-checkout .ts-price-effective { font-size: 1.35rem; }
.ts-view-checkout .ts-product-description { color: #655c5d; font-size: .9rem; line-height: 1.5; }
.ts-view-checkout .ts-product-description > :first-child { margin-top: 0; }
.ts-view-checkout .ts-product-description > :last-child { margin-bottom: 0; }

.ts-view-checkout .ts-checkout-back {
  margin-top: 12px;
  padding: 0;
  border: 0;
}

.ts-view-checkout .ts-checkout-back-link {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 4px;
  width: auto;
  min-height: 36px;
  padding: 4px 0;
  color: var(--ts-red-deep, #8f1724) !important;
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
}

.ts-view-checkout .ts-checkout-back-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ts-view-checkout .ts-checkout-back-link .ts-icon { width: 17px; height: 17px; }

.ts-view-checkout .ts-checkout-form > p {
  margin: 0 0 17px;
  color: #655c5d;
  font-size: .91rem;
  line-height: 1.5;
}

.ts-view-checkout .ts-checkout-payment-heading {
  margin: 0 0 9px;
  padding: 0;
  border: 0;
  color: #4f4647;
  font-family: var(--ts-font-sans);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ts-view-checkout .ts-payment-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.ts-view-checkout .ts-payment-option label {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 92px;
  padding: 13px;
  border: 1px solid #dcd3d4;
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
}

.ts-view-checkout .ts-payment-option label:hover { border-color: #bcaeb0; box-shadow: none; }
.ts-view-checkout .ts-payment-option input[type="radio"]:checked + label {
  border-color: var(--ts-red);
  background: #fff8f8;
  box-shadow: inset 0 0 0 1px var(--ts-red);
}

.ts-view-checkout .ts-payment-option input[type="radio"]:focus-visible + label {
  outline: 3px solid var(--ts-gold, #b7822e);
  outline-offset: 2px;
}

.ts-view-checkout .ts-payment-icon {
  grid-row: 1 / span 2;
  display: grid;
  width: 28px;
  height: 28px;
  margin: 0;
  place-items: center;
  border-radius: 50%;
  background: #f3eded;
  color: var(--ts-red-deep, #8f1724);
}

.ts-view-checkout .ts-payment-icon svg { width: 16px; height: 16px; }
.ts-view-checkout .ts-payment-title { margin: 1px 0 2px; font-size: .92rem; line-height: 1.25; }
.ts-view-checkout .ts-payment-desc { color: #746b6c; font-size: .76rem; line-height: 1.35; }
.ts-view-checkout .ts-payment-form { margin-top: 14px; }
.ts-view-checkout .ts-checkout-actions { margin: 0; }
.ts-view-checkout .ts-checkout-actions .ts-btn { width: 100%; min-height: 46px; padding: 10px 16px; }

@media (max-width: 767.98px) {
  .ts-view-checkout .ts-checkout-card { padding: 16px; }
  .ts-checkout-header { padding-bottom: 8px; }
  .ts-view-checkout .ts-card .ts-checkout-container { grid-template-columns: 1fr; margin-top: 14px; }
}

@media (max-width: 419.98px) {
  .ts-view-checkout .ts-checkout-card { padding: 13px; }
  .ts-view-checkout .ts-payment-options { grid-template-columns: 1fr; }
  .ts-view-checkout .ts-payment-option label { min-height: 76px; }
}
