/* ==============================
   CSA Order Form — Modern Style
   Clean, farm-fresh, trustworthy
================================ */

/* ── Reset & Base ── */
#csa-order-form *,
#csa-order-form *::before,
#csa-order-form *::after {
  box-sizing: border-box;
}

#csa-order-form {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1a1a1a;
  max-width: 860px;
  margin: 0 auto;
  padding: 0;
}

/* ── Section Headings ── */
#csa-order-form h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 0.25rem;
  padding-bottom: 0;
  border-bottom: none;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

#csa-order-form h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin: 1.5rem 0 0.5rem;
}

/* ════════════════════════════════
   STEP PROGRESS BAR
   ════════════════════════════════ */
.csa-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0 auto 2rem;
  max-width: 860px;
  padding: 1.5rem 1rem 0;
}

.csa-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #9ca3af;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .25s, color .25s, box-shadow .25s;
  border: 2px solid #e5e7eb;
}

.step-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #9ca3af;
  white-space: nowrap;
  transition: color .25s;
  letter-spacing: 0.01em;
}

.csa-step.active .step-circle {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.csa-step.active .step-label {
  color: #2563eb;
}

.csa-step.completed .step-circle {
  background: #047857;
  color: #fff;
  border-color: #047857;
  font-size: 0;
}

.csa-step.completed .step-circle::after {
  content: "✓";
  font-size: 0.85rem;
}

.csa-step.completed .step-label {
  color: #047857;
}

.step-connector {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  margin: 0 8px;
  margin-bottom: 22px;
  transition: background .3s;
  min-width: 40px;
  max-width: 80px;
}

.step-connector.filled {
  background: #047857;
}

/* ════════════════════════════════
   SECTION PANELS
   ════════════════════════════════ */
.csa-section {
  display: none;
  animation: csaFadeIn .3s ease;
}

.csa-section.active {
  display: block;
}

@keyframes csaFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.csa-section-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid #e5e7eb;
}

.section-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid #bfdbfe;
}

.section-subtitle {
  font-size: 0.88rem;
  color: #6b7280;
  margin: 2px 0 0;
}

.product-group-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #f3f4f6;
}

.billing-heading {
  margin-top: 2rem !important;
}

.billing-subtext {
  font-size: 0.9rem;
  color: #6b7280;
  margin: 0 0 0.75rem;
}

/* ── Section Footer Nav ── */
.section-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
}

.section-footer.two-col {
  justify-content: space-between;
}

.btn-next {
  padding: 11px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  letter-spacing: 0.01em;
}

.btn-next:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-back {
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.btn-back:hover {
  background: #f9fafb;
  color: #374151;
}

/* ── Map & Address ── */
#map-container {
  margin-bottom: 1.25rem;
}

#user-address {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.12);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  margin-bottom: 10px;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#user-address:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

#map {
  height: 250px;
  margin-top: 0;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  position: relative;
  z-index: 0;
}

#map .gm-fullscreen-control,
#map .gm-bundled-control,
#map .gmnoprint {
  z-index: 1 !important;
}

/* ── Shared Select Style ── */
#csa-order-form select {
  padding: 10px 36px 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.1);
  width: 100%;
  margin-bottom: 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: #1a1a1a;
  background-color: #fff;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%231f2933" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.1rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

#csa-order-form select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Location Details Panel ── */
#location-details {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
}

#location-details:empty {
  display: none;
}

#location-details label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 500;
  padding: 4px 0;
}

#location-details input[type="radio"] {
  accent-color: #2563eb;
  width: 16px;
  height: 16px;
}

/* ── Product Grid ── */
.csa-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 1.5rem;
}

/* ── Individual Product Card ── */
.csa-product {
  background: #ffffff;
  border: 2px solid #e5e7eb !important;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  position: relative;
  cursor: default;
}

.csa-product:hover {
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  transform: translateY(-1px);
}

.csa-product.selected {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.csa-product h3 {
  font-size: 0.97rem;
  margin: 0 0 2px;
  line-height: 1.3;
}

.csa-product img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 7px;
  margin: 4px 0 6px;
  display: block;
}

.product-price {
  font-size: 1.2rem;
  font-weight: 800;
  color: #047857;
  margin: 0;
  line-height: 1.2;
}

.price-per-share {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0 0 4px;
}

.renewal-freq {
  font-size: 0.78rem;
  background: #f0fdf4;
  color: #15803d;
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-block;
  font-weight: 600;
  margin: 0;
  border: 1px solid #bbf7d0;
  text-transform: capitalize;
  text-align: center;
}

.renewal-freq::after {
  content: " Distribution";
}

.product-meta {
  font-size: 0.8rem;
  color: #374151;
  line-height: 1.55;
  display: none;
  margin-top: 4px;
  border-top: 1px solid #f3f4f6;
  padding-top: 8px;
}

.product-meta.open {
  display: block;
}

.product-meta p {
  margin: 0 0 4px;
}

.product-details-toggle {
  font-size: 0.78rem;
  color: #2563eb;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 4px;
  display: inline-block;
}

.product-details-toggle:hover {
  color: #1d4ed8;
}

.csa-product .product-actions {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.add-to-order-btn {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  background: #2563eb;
  color: #ffffff;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  font-family: inherit;
}

.add-to-order-btn:hover {
  background: #1d4ed8;
}

.add-to-order-btn.added {
  background: #047857;
}

.add-to-order-btn.added:hover {
  background: #065f46;
}

.quantity-container {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #374151;
  font-weight: 500;
}

.quantity-container.visible {
  display: flex;
}

.product-quantity {
  width: 64px;
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid #d1d5db;
  font-family: inherit;
  font-size: 0.9rem;
  text-align: center;
}

.product-quantity:focus {
  outline: none;
  border-color: #2563eb;
}

.no-csa-addons {
  color: #6b7280;
  font-style: italic;
  font-size: 0.9rem;
  padding: 10px 0;
}

/* ── Delivery Options ── */
#delivery-options {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.7;
}

#delivery-options:empty {
  display: none;
}

#delivery-options h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

#delivery-options ul {
  margin: 0;
  padding-left: 18px;
}

#delivery-options li {
  margin-bottom: 4px;
}

/* ── Order Total Banner ── */
#order-total {
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #065f46;
  margin: 0 0 1.25rem;
}

/* ── Cart Totals ── */
#cart-totals {
  background: #f9fafb;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  margin-top: 1rem;
  font-size: 0.9rem;
}

#cart-totals h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

#cart-totals table {
  width: 100%;
  border-collapse: collapse;
}

#cart-totals th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}

#cart-totals th:not(:first-child),
#cart-totals td:not(:first-child) {
  text-align: right;
}

#cart-totals td {
  padding: 7px 0;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

#cart-totals tr:last-child td {
  border-bottom: none;
}

#cart-totals p {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: #374151;
}

#cart-totals p strong {
  color: #111827;
}

/* ── Payment Options ── */
#payment-options {
  margin-top: 0;
}

#payment-options h3 {
  margin-top: 0;
}

/* ── Installment Breakdown ── */
#installment-breakdown {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: #1e40af;
  line-height: 1.6;
  margin-top: 0.5rem;
}

#installment-breakdown:empty {
  display: none;
}

#installment-breakdown ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

/* ── Billing Fields ── */
.billing-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  margin-top: 10px;
}

.billing-fields label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  display: block;
  margin-bottom: 4px;
  letter-spacing: .01em;
}

.billing-fields input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.1);
  font-family: inherit;
  font-size: 0.95rem;
  color: #111827;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

.billing-fields input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.billing-fields input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.billing-fields .full-width {
  grid-column: 1 / -1;
}

/* ── Stripe Payment Section ── */
#stripe-payment-section {
  margin-top: 1.75rem;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

#stripe-payment-section h3 {
  margin-top: 0;
}

#card-element {
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

#card-element.StripeElement--focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

#card-errors {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 20px;
}

/* ── Submit Button ── */
#submit-button {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 800;
  font-family: inherit;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 1.25rem;
  letter-spacing: .01em;
  transition: background .15s, opacity .15s, transform .1s;
}

#submit-button:hover:not(:disabled) {
  background: #15803d;
  transform: translateY(-1px);
}

#submit-button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ── Login Required Message ── */
#login-required-message {
  margin-top: 1.5rem;
  padding: 20px 24px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  text-align: center;
}

#login-required-message h3 {
  margin-top: 0;
  color: #111827;
}

#login-required-message p {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

#login-required-message a.button {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  margin: 4px;
  font-size: 0.9rem;
  transition: opacity .15s;
}

#login-required-message a.button-primary {
  background: #2563eb;
  color: #fff;
}

#login-required-message a.button-secondary {
  background: #e5e7eb;
  color: #374151;
}

#login-required-message a.button:hover {
  opacity: .8;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .billing-fields {
    grid-template-columns: 1fr;
  }

  .csa-products {
    grid-template-columns: repeat(2, 1fr);
  }

  .step-label {
    display: none;
  }

  .step-connector {
    min-width: 24px;
  }
}

@media (max-width: 400px) {
  .csa-products {
    grid-template-columns: repeat(2, 1fr);
  }
}