@layer components;

@layer components {
  .section--contato {
    position: relative;
  }

  .section--contato::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(91, 111, 232, 0.06), transparent);
  }

  [data-theme="light"] .section--contato::before {
    background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(91, 111, 232, 0.03), transparent);
  }

  .contact-form {
    position: relative;
    display: grid;
    gap: var(--space-6);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-default);
    background: var(--surface-primary);
    box-shadow: var(--shadow-md);
  }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .field {
    display: grid;
    gap: 0.375rem;
  }

  .field label {
    font-size: var(--font-size-small);
    font-weight: 600;
    color: var(--text-primary);
  }

  .field input,
  .field textarea {
    width: 100%;
    min-height: var(--interactive-min);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color var(--motion-base) ease, box-shadow var(--motion-base) ease;
  }

  .field textarea {
    min-height: 140px;
    line-height: 1.6;
  }

  .field input::placeholder,
  .field textarea::placeholder {
    color: var(--text-muted);
  }

  .field input:hover,
  .field textarea:hover {
    border-color: var(--border-strong);
  }

  .field input:focus-visible,
  .field textarea:focus-visible {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(91, 111, 232, 0.15);
    outline: none;
  }

  .field:has(input:required) label::after,
  .field:has(textarea:required) label::after {
    content: " *";
    color: var(--text-accent);
    font-weight: 700;
  }

  .field input:user-invalid,
  .field textarea:user-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
  }

  .field input:user-valid,
  .field textarea:user-valid {
    border-color: #22c55e;
  }

  .field:has(input:user-invalid) label,
  .field--invalid label {
    color: #f87171;
  }

  .field--invalid input,
  .field--invalid textarea {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
  }

  .contact-form > .btn {
    justify-self: start;
    min-width: clamp(180px, 20vw, 260px);
  }

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

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

  .form-feedback--success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-4);
    padding: var(--space-7) var(--space-5);
  }

  .form-feedback__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(91, 111, 232, 0.1);
    border: 1px solid rgba(91, 111, 232, 0.25);
    color: var(--brand-primary);
    flex-shrink: 0;
  }

  .form-feedback--success h3 {
    font-size: var(--font-size-h3);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
  }

  .form-feedback--success p {
    color: var(--text-secondary);
    line-height: var(--line-height-body);
    margin: 0;
    max-width: 38ch;
  }

  .form-feedback--error {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.07);
    grid-column: 1 / -1;
  }

  .form-feedback--error ul {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    list-style: none;
  }

  .form-feedback--error li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--font-size-small);
    color: #f87171;
    line-height: 1.5;
  }

  .form-feedback--error li::before {
    content: "";
    flex-shrink: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f87171;
  }

  @media (max-width: 767px) {
    .contact-form {
      padding: 1.25rem;
    }

    .field input,
    .field textarea,
    .contact-form > .btn {
      font-size: 16px;
    }

    .contact-form > .btn {
      width: 100%;
      justify-self: stretch;
    }
  }
}
