.checkout-page {
  padding: 3rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-8);
  align-items: start;

  @media (max-width: 900px) {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-6);
  color: var(--color-heading);
}

.form-card {
  margin-bottom: var(--space-6);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;

  .card-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
    
    h3 {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--color-heading);
      margin: 0;
    }
  }

  .card-content {
    padding: var(--space-6);
  }
}

.form-row {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  
  &.three-cols {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: var(--space-4);
  }

  app-input {
    flex: 1;
    width: 100%;
  }

  @media (max-width: 600px) {
    flex-direction: column;
    &.three-cols {
      grid-template-columns: 1fr;
    }
  }
}

/* User Type Selector Styles */
.user-type-selector {
  display: flex;
  background-color: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: var(--space-4);
  gap: 4px;
  width: 100%;
}

.type-option {
  flex: 1;
  text-align: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all 0.2s ease;
  user-select: none;
  
  &:hover { color: var(--color-text); }
  
  &.selected {
    background-color: var(--color-brand);
    color: #000;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  }
}

.shipping-option {
  margin: var(--space-6) 0;
}

/* Custom Checkbox */
.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 30px;
  cursor: pointer;
  font-size: 1rem;
  user-select: none;
  color: var(--color-text);

  input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;

    &:checked ~ .checkmark {
      background-color: var(--color-brand);
      border-color: var(--color-brand);
      
      &:after {
        display: block;
      }
    }
  }

  .checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;

    &:after {
      content: "";
      position: absolute;
      display: none;
      left: 6px;
      top: 2px;
      width: 6px;
      height: 12px;
      border: solid white;
      border-width: 0 2px 2px 0;
      transform: rotate(45deg);
    }
  }

  &:hover input ~ .checkmark {
    border-color: var(--color-brand);
  }
}


.checkout-summary-section {
  position: relative;
}

.sticky-card {
  position: sticky;
  top: 0; 
  /* Inherits styles from .form-card */
}

.summary-items {
  margin-bottom: var(--space-6);
  max-height: 400px;
  overflow-y: auto;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);

  &:last-child {
    border-bottom: none;
  }

  .item-details {
    flex: 1;
    
    .item-name {
      display: block;
      font-weight: 500;
      margin-bottom: var(--space-1);
      word-break: break-all;
      color: var(--color-text);
    }

    .item-specs {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      font-size: 0.85rem;
      color: var(--color-text-muted);
      
      .color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        display: inline-block;
        border: 1px solid var(--color-border);
      }
    }
    
    .item-specs-sub {
      font-size: 0.8rem;
       color: var(--color-text-muted);
       margin-top: 2px;
    }
  }

  .item-price {
    font-weight: 600;
    margin-left: var(--space-3);
    white-space: nowrap;
    color: var(--color-heading);
  }
}

.summary-totals {
  background: var(--color-bg-subtle);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-top: var(--space-4);

  .total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    color: var(--color-text);

    &.grand-total {
      color: var(--color-heading);
      font-weight: 700;
      font-size: 1.25rem;
      margin-top: var(--space-3);
      padding-top: var(--space-3);
      border-top: 1px solid var(--color-border);
      margin-bottom: 0;
    }
  }

  .divider {
    display: none; // Handled by border-top in grand-total
  }
}

.actions {
  margin-top: var(--space-6);
  display: flex;
  justify-content: flex-end;
  
  app-button {
    width: 100%;
    
    @media (min-width: 900px) {
        width: auto;
        min-width: 200px;
    }
  }
}

.error-message {
  color: var(--color-danger);
  background: var(--color-danger-subtle);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  border: 1px solid var(--color-danger);
}

