:root {
  --teaflex-primary: #c4a173;
  --teaflex-primary-light: #d4b185;
  --teaflex-primary-dark: #a68a5f;
  --teaflex-secondary: #f8f6f3;
  --teaflex-success: #4caf50;
  --teaflex-error: #f44336;
  --teaflex-warning: #ff9800;
  --teaflex-text: #333;
  --teaflex-text-light: #666;
  --teaflex-border: #ddd;
  --teaflex-spacing-xs: 0.25rem;
  --teaflex-spacing-sm: 0.5rem;
  --teaflex-spacing-md: 1rem;
  --teaflex-spacing-lg: 1.5rem;
  --teaflex-spacing-xl: 2rem;
  --teaflex-radius: 8px;
  --teaflex-transition: all 0.3s ease;
  --teaflex-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
}

.teaflex-form-container {
  max-width: 680px;
  margin: var(--teaflex-spacing-xl) auto;
  padding: var(--teaflex-spacing-xl);
  background: #fff;
  border-radius: var(--teaflex-radius);
  box-shadow: var(--teaflex-shadow);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--teaflex-text);
  line-height: 1.6;

  @media (max-width: 768px) {
    margin: var(--teaflex-spacing-md);
    padding: var(--teaflex-spacing-lg);
  }
}

.teaflex-form {
  display: flex;
  flex-direction: column;
  gap: var(--teaflex-spacing-xl);
}

.teaflex-form__field {
  display: flex;
  flex-direction: column;
  gap: var(--teaflex-spacing-sm);

  label {
    font-weight: 600;
    color: var(--teaflex-text);
    font-size: 0.95rem;
    margin-bottom: var(--teaflex-spacing-xs);

    .required {
      color: var(--teaflex-error);
      margin-left: 2px;
    }
  }

  :is(input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), select, textarea) {
    padding: var(--teaflex-spacing-md) var(--teaflex-spacing-sm);
    border: 2px solid var(--teaflex-border);
    border-radius: var(--teaflex-radius);
    font-size: 1rem;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background: #fff;
    transition: var(--teaflex-transition);
    min-height: 44px;

    &:focus {
      outline: none;
      border-color: var(--teaflex-primary);
      box-shadow: 0 0 0 3px rgba(196, 161, 115, 0.2);
    }

    &.error {
      border-color: var(--teaflex-error);
      background: rgba(244, 67, 54, 0.05);
    }

    @media (max-width: 768px) {
      font-size: 16px;
      padding: var(--teaflex-spacing-sm);
    }
  }

  .file-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
  }

  input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }

  .file-input-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--teaflex-spacing-sm);
    padding: var(--teaflex-spacing-md) var(--teaflex-spacing-lg);
    border: 2px dashed var(--teaflex-border);
    border-radius: var(--teaflex-radius);
    background: var(--teaflex-secondary);
    color: var(--teaflex-text-light);
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--teaflex-transition);
    min-height: 60px;
    text-align: center;

    &:hover {
      border-color: var(--teaflex-primary);
      background: rgba(196, 161, 115, 0.1);
      color: var(--teaflex-text);
    }

    &::before {
      content: "📎";
      font-size: 1.2em;
    }

    &.has-file {
      border-style: solid;
      border-color: var(--teaflex-primary);
      background: rgba(196, 161, 115, 0.1);
      color: var(--teaflex-text);

      &::before {
        content: "✓";
        color: var(--teaflex-success);
      }
    }

    &.error {
      border-color: var(--teaflex-error);
      background: rgba(244, 67, 54, 0.05);
    }
  }

  .file-input-info {
    font-size: 0.85rem;
    color: var(--teaflex-text-light);
    margin-top: var(--teaflex-spacing-xs);
    text-align: center;
  }

  textarea {
    min-height: 100px;
    resize: vertical;
  }
}

.teaflex-form__member-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--teaflex-spacing-sm);
  margin-top: var(--teaflex-spacing-sm);
  position: relative;

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

  @media (max-width: 480px) {
    grid-template-columns: 1fr;
  }
}

.member-selection-status {
  background: var(--teaflex-secondary);
  padding: var(--teaflex-spacing-md);
  border-radius: var(--teaflex-radius);
  text-align: center;
  color: var(--teaflex-text-light);
  font-size: 0.9rem;
  margin-bottom: var(--teaflex-spacing-md);
  border: 1px solid var(--teaflex-border);
}

.member-selection-disabled {
  opacity: 0.5;
  pointer-events: none;

  &::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--teaflex-radius);
    pointer-events: none;
  }
}

.member-checkbox {
  display: flex;
  align-items: center;
  gap: var(--teaflex-spacing-sm);
  padding: var(--teaflex-spacing-md);
  border: 2px solid var(--teaflex-border);
  border-radius: var(--teaflex-radius);
  cursor: pointer;
  transition: var(--teaflex-transition);
  background: #fff;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.95rem;
  min-height: 44px;

  &:hover {
    background-color: var(--teaflex-secondary);
    border-color: var(--teaflex-primary-light);
  }

  &:has(input:checked) {
    background-color: var(--teaflex-primary);
    color: white;
    border-color: var(--teaflex-primary);
    font-weight: 600;
  }

  &:has(input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
  }

  input {
    margin: 0;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  @media (max-width: 480px) {
    padding: var(--teaflex-spacing-sm) var(--teaflex-spacing-md);
  }
}

.teaflex-form__help {
  font-size: 0.85rem;
  color: var(--teaflex-text-light);
  margin-top: var(--teaflex-spacing-xs);
  line-height: 1.4;
}

.teaflex-form__submit-wrapper {
  display: flex;
  justify-content: center;
  margin-top: var(--teaflex-spacing-xl);
}

.teaflex-form__submit {
  background-color: var(--teaflex-primary);
  color: white;
  padding: var(--teaflex-spacing-md) var(--teaflex-spacing-xl);
  border: none;
  border-radius: var(--teaflex-radius);
  font-size: 1.1rem;
  font-weight: 600;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  cursor: pointer;
  transition: var(--teaflex-transition);
  min-width: 200px;
  min-height: 48px;
  box-shadow: 0 2px 8px rgba(196, 161, 115, 0.3);

  &:hover:not(:disabled) {
    background-color: var(--teaflex-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196, 161, 115, 0.4);
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
  }

  &.loading {
    position: relative;
    color: transparent;

    &::after {
      content: "";
      position: absolute;
      width: 20px;
      height: 20px;
      top: 50%;
      left: 50%;
      margin: -10px 0 0 -10px;
      border: 2px solid white;
      border-radius: 50%;
      border-top-color: transparent;
      animation: spinner 0.6s linear infinite;
    }
  }
}

:is(h3, h4) {
  color: var(--teaflex-text);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600;
}

h3 {
  font-size: 1.3rem;
  margin: var(--teaflex-spacing-lg) 0 var(--teaflex-spacing-sm);
}

h4 {
  font-size: 1.1rem;
  margin: var(--teaflex-spacing-lg) 0 var(--teaflex-spacing-sm);
}

#shipping-fields {
  display: none;
  flex-direction: column;
  gap: var(--teaflex-spacing-xl);
}

#shipping-fields.show {
  display: flex;
}

#shipping-fields .teaflex-form__field {
  margin-bottom: 0;
}

.radio-group {
  display: flex;
  gap: var(--teaflex-spacing-lg);
  margin-top: var(--teaflex-spacing-sm);

  label {
    display: flex;
    align-items: center;
    gap: var(--teaflex-spacing-sm);
    font-weight: normal;
    cursor: pointer;
    font-family: 'Helvetica Neue', Arial, sans-serif;
  }

  input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
  }
}

.terms-box {
  background: var(--teaflex-secondary);
  padding: var(--teaflex-spacing-lg);
  border-radius: var(--teaflex-radius);
  max-height: 250px;
  overflow-y: auto;
  font-size: 0.85rem;
  border: 1px solid var(--teaflex-border);
  margin: var(--teaflex-spacing-md) 0;
  line-height: 1.5;

  h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--teaflex-text);
    margin: 0 0 var(--teaflex-spacing-sm);
  }

  h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--teaflex-text);
    margin: var(--teaflex-spacing-md) 0 var(--teaflex-spacing-xs);
  }

  p {
    margin: 0 0 var(--teaflex-spacing-sm);
    color: var(--teaflex-text-light);
  }
}

.teaflex-message {
  margin-top: var(--teaflex-spacing-lg);
  padding: var(--teaflex-spacing-lg);
  border-radius: var(--teaflex-radius);
  text-align: center;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: 500;

  &.success {
    background-color: var(--teaflex-success);
    color: white;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
  }

  &.error {
    background-color: var(--teaflex-error);
    color: white;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
  }
}

.success-screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 10000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  text-align: center;
  padding: var(--teaflex-spacing-xl);

  &.show {
    display: flex;
  }

  .success-icon {
    font-size: 4rem;
    color: var(--teaflex-success);
    margin-bottom: var(--teaflex-spacing-xl);
    animation: checkmark 0.6s ease-in-out;
  }

  .success-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--teaflex-text);
    margin-bottom: var(--teaflex-spacing-lg);
    font-family: 'Helvetica Neue', Arial, sans-serif;
  }

  .success-message {
    font-size: 1.1rem;
    color: var(--teaflex-text-light);
    line-height: 1.6;
    max-width: 600px;
    margin-bottom: var(--teaflex-spacing-xl);
    font-family: 'Helvetica Neue', Arial, sans-serif;
  }

  .success-button {
    background-color: var(--teaflex-primary);
    color: white;
    padding: var(--teaflex-spacing-md) var(--teaflex-spacing-xl);
    border: none;
    border-radius: var(--teaflex-radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    cursor: pointer;
    transition: var(--teaflex-transition);
    text-decoration: none;
    display: inline-block;

    &:hover {
      background-color: var(--teaflex-primary-dark);
      transform: translateY(-2px);
    }
  }

  @media (max-width: 768px) {
    padding: var(--teaflex-spacing-lg);

    .success-icon {
      font-size: 3rem;
    }

    .success-title {
      font-size: 1.5rem;
    }

    .success-message {
      font-size: 1rem;
    }
  }
}

@keyframes checkmark {
  0% {
    transform: scale(0) rotate(45deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(45deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(45deg);
    opacity: 1;
  }
}

.error-text {
  color: var(--teaflex-error);
  font-size: 0.85rem;
  margin-top: var(--teaflex-spacing-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--teaflex-spacing-xs);

  &::before {
    content: "⚠";
    color: var(--teaflex-error);
  }
}

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

.flatpickr-calendar {
  font-family: 'Helvetica Neue', Arial, sans-serif !important;
  border: 2px solid var(--teaflex-border);
  border-radius: var(--teaflex-radius);
  box-shadow: var(--teaflex-shadow);
}

.flatpickr-months .flatpickr-month {
  background: var(--teaflex-primary);
  color: white;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: transparent;
  color: white;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}

.flatpickr-weekdays {
  background: var(--teaflex-secondary);
}

:is(.flatpickr-weekday, .flatpickr-day) {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--teaflex-text);
}

.flatpickr-day {
  &:hover {
    background: var(--teaflex-primary-light);
    color: white;
  }

  &.selected {
    background: var(--teaflex-primary);
    border-color: var(--teaflex-primary);
  }

  &.today {
    border-color: var(--teaflex-primary);
  }
}

:is(.flatpickr-prev-month, .flatpickr-next-month) {
  color: white;

  &:hover {
    color: var(--teaflex-primary-light);
  }
}

.error-summary {
  background: #fef7f7;
  border: 2px solid var(--teaflex-error);
  border-radius: var(--teaflex-radius);
  padding: var(--teaflex-spacing-lg);
  margin-bottom: var(--teaflex-spacing-xl);
}

.error-summary h3 {
  color: var(--teaflex-error);
  font-size: 1.1rem;
  margin: 0 0 var(--teaflex-spacing-md);
  font-weight: 600;
}

.error-summary ul {
  margin: 0;
  padding-left: var(--teaflex-spacing-xl);
  list-style-type: disc;
}

.error-summary li {
  color: var(--teaflex-error);
  font-size: 0.95rem;
  margin-bottom: var(--teaflex-spacing-sm);
  line-height: 1.5;
}

