/* Checkout Page Styles */

.checkout-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(127, 168, 122, 0.15), transparent 28%),
    linear-gradient(180deg, #f7f7f3 0%, #fffaf5 100%);
  display: flex;
  flex-direction: column;
}

/* Header */
.checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-4) var(--ds-space-5);
  background: white;
  border-bottom: 1px solid var(--ds-color-border);
}

.checkout-logo img {
  display: block;
}

.checkout-secure {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ds-color-support-success-fg);
}

/* Shell */
.checkout-shell {
  flex: 1;
  width: min(calc(100% - 2rem), 80rem);
  margin: 0 auto;
  padding: var(--ds-space-6) 0;
}

/* Hidden attribute support - CSS display overrides hidden, so we need this */
.checkout-loading[hidden],
.checkout-error[hidden],
.checkout-empty[hidden],
.checkout-modal[hidden],
.checkout-content[hidden] {
  display: none !important;
}

/* Loading State */
.checkout-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-4);
  padding: var(--ds-space-8);
  text-align: center;
}

.checkout-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--ds-color-border);
  border-top-color: var(--ds-color-accent-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error State */
.checkout-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-4);
  padding: var(--ds-space-8);
  text-align: center;
}

.checkout-error__icon {
  color: var(--ds-color-support-danger-fg);
}

/* Empty State */
.checkout-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-4);
  padding: var(--ds-space-8);
  text-align: center;
}

.checkout-empty__icon {
  color: var(--ds-color-text-muted);
}

/* Modal */
.checkout-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-4);
}

.checkout-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.checkout-modal__content {
  position: relative;
  z-index: 2;
  width: min(100%, 28rem);
  padding: var(--ds-space-6);
  display: grid;
  gap: var(--ds-space-4);
  text-align: center;
}

.checkout-modal__actions {
  display: flex;
  gap: var(--ds-space-3);
  justify-content: center;
}

/* Main Content Grid */
.checkout-content {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--ds-space-6);
  align-items: start;
}

.checkout-main {
  display: grid;
  gap: var(--ds-space-5);
}

/* Sections */
.checkout-section {
  background: white;
  border-radius: var(--ds-radius-lg);
  padding: var(--ds-space-5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.checkout-section__title {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-green-dark);
  margin-bottom: var(--ds-space-4);
}

.checkout-section__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--ds-color-accent-500);
  color: white;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: 50%;
}

/* Address Section */
.checkout-addresses {
  display: grid;
  gap: var(--ds-space-3);
  margin-bottom: var(--ds-space-4);
}

.checkout-address-card {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  background: var(--ds-color-surface-muted);
  border: 2px solid transparent;
  border-radius: var(--ds-radius-md);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.checkout-address-card:hover {
  background: var(--ds-color-surface-subtle);
}

.checkout-address-card--selected {
  border-color: var(--ds-color-accent-500);
  background: rgba(127, 168, 122, 0.08);
}

.checkout-address-card input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--ds-color-accent-500);
}

.checkout-address-card__content {
  flex: 1;
  min-width: 0;
}

.checkout-address-card__label {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-weight: 700;
  color: var(--brand-green-dark);
  margin-bottom: var(--ds-space-1);
}

.checkout-address-card__default {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--ds-color-support-success-bg);
  color: var(--ds-color-support-success-fg);
  border-radius: var(--ds-radius-pill);
  font-weight: 600;
}

.checkout-address-card__details {
  font-size: 0.9rem;
  color: var(--ds-color-text-muted);
  line-height: 1.5;
}

.checkout-add-address-btn {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-3) var(--ds-space-4);
  background: transparent;
  border: 2px dashed var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-accent-500);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  width: 100%;
  justify-content: center;
}

.checkout-add-address-btn:hover {
  background: var(--ds-color-surface-muted);
  border-color: var(--ds-color-accent-500);
}

/* Address Form */
.checkout-address-form {
  margin-top: var(--ds-space-4);
  padding: var(--ds-space-5);
}

.checkout-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--ds-space-4);
  margin-bottom: var(--ds-space-4);
}

.checkout-field {
  display: grid;
  gap: var(--ds-space-2);
}

.checkout-field--full {
  grid-column: 1 / -1;
}

.checkout-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brand-green-dark);
}

.checkout-checkbox {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-weight: 600;
  cursor: pointer;
}

.checkout-checkbox input {
  accent-color: var(--ds-color-accent-500);
}

.checkout-form-status {
  padding: var(--ds-space-3);
  border-radius: var(--ds-radius-md);
  margin-bottom: var(--ds-space-4);
  font-weight: 600;
}

.checkout-form-status--error {
  background: var(--ds-color-support-danger-bg);
  color: var(--ds-color-support-danger-fg);
}

.checkout-form-status--success {
  background: var(--ds-color-support-success-bg);
  color: var(--ds-color-support-success-fg);
}

.checkout-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--ds-space-3);
}

/* Payment Methods */
.checkout-payment-methods {
  display: grid;
  gap: var(--ds-space-3);
}

.checkout-payment-option {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  background: var(--ds-color-surface-muted);
  border: 2px solid transparent;
  border-radius: var(--ds-radius-md);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.checkout-payment-option:hover:not(.checkout-payment-option--disabled) {
  background: var(--ds-color-surface-subtle);
}

.checkout-payment-option--selected {
  border-color: var(--ds-color-accent-500);
  background: rgba(127, 168, 122, 0.08);
}

.checkout-payment-option--disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.checkout-payment-option input[type="radio"] {
  display: none;
}

.checkout-payment-option__content {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  flex: 1;
}

.checkout-payment-option__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--ds-color-accent-100);
  color: var(--ds-color-accent-600);
  border-radius: var(--ds-radius-md);
}

.checkout-payment-option__icon--stepup {
  background: #e8f4ea;
  color: #2d7a45;
}

.checkout-payment-option__text {
  display: grid;
  gap: 2px;
}

.checkout-payment-option__name {
  font-weight: 700;
  color: var(--brand-green-dark);
}

.checkout-payment-option__desc {
  font-size: 0.875rem;
  color: var(--ds-color-text-muted);
}

.checkout-payment-option__check {
  color: var(--ds-color-accent-500);
  display: none;
}

.checkout-payment-option--selected .checkout-payment-option__check {
  display: block;
}

.checkout-payment-option__badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text-muted);
  border-radius: var(--ds-radius-pill);
  font-weight: 600;
}

/* Shipping Methods */
.checkout-shipping-methods {
  display: grid;
  gap: var(--ds-space-3);
}

.checkout-shipping-option {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  background: var(--ds-color-surface-muted);
  border: 2px solid transparent;
  border-radius: var(--ds-radius-md);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.checkout-shipping-option:hover {
  background: var(--ds-color-surface-subtle);
}

.checkout-shipping-option--selected {
  border-color: var(--ds-color-accent-500);
  background: rgba(127, 168, 122, 0.08);
}

.checkout-shipping-option input[type="radio"] {
  display: none;
}

.checkout-shipping-option__content {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  flex: 1;
}

.checkout-shipping-option__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--ds-color-accent-100);
  color: var(--ds-color-accent-600);
  border-radius: var(--ds-radius-md);
}

.checkout-shipping-option__text {
  display: grid;
  gap: 2px;
}

.checkout-shipping-option__name {
  font-weight: 700;
  color: var(--brand-green-dark);
}

.checkout-shipping-option__desc {
  font-size: 0.875rem;
  color: var(--ds-color-text-muted);
}

.checkout-shipping-option__price {
  font-weight: 700;
  color: var(--ds-color-support-success-fg);
}

/* Cart Items */
.checkout-items {
  display: grid;
  gap: var(--ds-space-4);
}

.checkout-item {
  display: flex;
  gap: var(--ds-space-4);
  padding-bottom: var(--ds-space-4);
  border-bottom: 1px solid var(--ds-color-border);
}

.checkout-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.checkout-item__image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: var(--ds-radius-md);
  overflow: hidden;
  background: var(--ds-color-surface-muted);
}

.checkout-item__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.checkout-item__details {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: var(--ds-space-2);
}

.checkout-item__title {
  font-weight: 600;
  color: var(--brand-green-dark);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.checkout-item__price {
  font-weight: 700;
  color: var(--ds-color-text);
}

.checkout-item__actions {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
}

.checkout-item__quantity {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
}

.checkout-item__qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--ds-color-surface-muted);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-green-dark);
  transition: background-color 0.15s ease;
}

.checkout-item__qty-btn:hover {
  background: var(--ds-color-surface-subtle);
}

.checkout-item__qty-value {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}

.checkout-item__remove {
  color: var(--ds-color-support-danger-fg);
  font-size: 0.875rem;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--ds-space-1) var(--ds-space-2);
  border-radius: var(--ds-radius-sm);
  transition: background-color 0.15s ease;
}

.checkout-item__remove:hover {
  background: var(--ds-color-support-danger-bg);
}

/* Sidebar / Summary */
.checkout-sidebar {
  position: sticky;
  top: var(--ds-space-5);
}

.checkout-summary {
  padding: var(--ds-space-5);
}

.checkout-summary__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-green-dark);
  margin-bottom: var(--ds-space-4);
}

.checkout-summary__rows {
  display: grid;
  gap: var(--ds-space-3);
  padding-bottom: var(--ds-space-4);
  border-bottom: 1px solid var(--ds-color-border);
  margin-bottom: var(--ds-space-4);
}

.checkout-summary__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.checkout-summary__total {
  display: flex;
  justify-content: space-between;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--brand-green-dark);
  margin-bottom: var(--ds-space-5);
}

.checkout-place-order {
  width: 100%;
  padding: var(--ds-space-4);
  font-size: 1rem;
}

.checkout-summary__disclaimer {
  margin-top: var(--ds-space-4);
  font-size: 0.8rem;
  color: var(--ds-color-text-muted);
  text-align: center;
  line-height: 1.5;
}

.checkout-summary__disclaimer a {
  color: var(--ds-color-accent-600);
  text-decoration: underline;
}

/* Mobile Sticky CTA */
.checkout-mobile-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: var(--ds-space-4);
  padding: var(--ds-space-4);
  background: white;
  border-top: 1px solid var(--ds-color-border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.checkout-mobile-cta__total {
  display: grid;
  gap: 2px;
}

.checkout-mobile-cta__total span:first-child {
  font-size: 0.8rem;
  color: var(--ds-color-text-muted);
}

.checkout-mobile-cta__total span:last-child {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--brand-green-dark);
}

.checkout-mobile-cta .ds-btn {
  flex: 1;
}

/* Footer */
.checkout-footer {
  padding: var(--ds-space-5);
  text-align: center;
  font-size: 0.8rem;
  color: var(--ds-color-text-muted);
  background: rgba(255, 255, 255, 0.5);
  margin-top: auto;
}

/* Responsive */
@media (max-width: 1024px) {
  .checkout-content {
    grid-template-columns: 1fr;
  }

  .checkout-sidebar {
    position: static;
  }

  .checkout-mobile-cta {
    display: flex;
  }

  .checkout-summary .checkout-place-order {
    display: none;
  }

  .checkout-page {
    padding-bottom: 80px;
  }
}

@media (min-width: 1025px) {
  .checkout-mobile-cta {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .checkout-form-grid {
    grid-template-columns: 1fr;
  }

  .checkout-item {
    flex-direction: column;
    gap: var(--ds-space-3);
  }

  .checkout-item__image {
    width: 100%;
    height: 120px;
  }

  .checkout-section {
    padding: var(--ds-space-4);
  }

  .checkout-address-form {
    padding: var(--ds-space-4);
  }
}
