/* ==========================================
   1. THE FORM CONTAINER
   ========================================== */
.footer-contact.forms {
  max-width: 600px;
  margin: 0 auto;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ==========================================
   2. FORM ROW & INPUT SPACING
   ========================================== */
.form-row:not(:last-of-type) {
  margin-bottom: 5px;
}
.form-row:last-of-type {
  margin-top: 1em;
}
form p:last-child {
  margin-top: 1em;
}
.input-group {
  display: flex;
  flex-direction: column;
}

/* Labels hold the text, input, and error messages */
.input-group label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
  color: #ffffff;
  font-size: 0.95rem;
}

/* ==========================================
   3. INPUT & TEXTAREA FIELD STYLES
   ========================================== */
.input-group input.gr,
.input-group textarea.gr {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cccccc;
  border-radius: 6px;
  background-color: #ffffff;
  color: #333333;
  font-size: 1rem;
  box-sizing: border-box;
  /* Smooth transition for form states */
  transition: border-color 0.25s ease-in-out, background-color 0.25s ease-in-out, box-shadow 0.25s ease-in-out;
}

/* Textarea height and resize control */
.input-group textarea.gr {
  min-height: 120px;
  resize: vertical;
}

/* Base focus state when user is actively typing */
.input-group input.gr:focus,
.input-group textarea.gr:focus {
  border-color: #0076d2;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 118, 210, 0.15);
  outline: none;
}

/* ==========================================
   4. INTERACTIVE ACCENT STATES (VALID/INVALID)
   ========================================== */

/* Valid states (Only when filled and correct) */
.input-group input.gr:valid:not(:placeholder-shown):not(:focus),
.input-group textarea.gr:valid:not(:placeholder-shown):not(:focus) {
  border-color: #2e7d32;
  background-color: #f1f8e9;
}

/* Invalid states (Triggers cleanly on tab-out / user interaction) */
.input-group input.gr:user-invalid,
.input-group textarea.gr:user-invalid,
.input-group input.gr:invalid:not(:placeholder-shown):not(:focus),
.input-group textarea.gr:invalid:not(:placeholder-shown):not(:focus) {
  border-color: #d32f2f;
  background-color: #ffebee;
}

/* ==========================================
   5. ERROR MESSAGE ANIMATION
   ========================================== */
.error-msg {
  display: none;
  color: #d32f2f;
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 2px;
  /* Smooth fade down animation */
  animation: slideDown 0.2s ease-out forwards;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Reveal error text alongside invalid wrappers */
label:has(input:user-invalid) .error-msg,
label:has(textarea:user-invalid) .error-msg,
label:has(input:invalid:not(:placeholder-shown):not(:focus)) .error-msg,
label:has(textarea:invalid:not(:placeholder-shown):not(:focus)) .error-msg {
  display: block;
}

/* ==========================================
   6. RECAPTCHA & SUBMIT BUTTON ROW Layout
   ========================================== */
/* Wraps reCAPTCHA and Send button horizontally */
.form-row:has(.g-recaptcha) .input-group {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

/* Send Button styling */
.button.green-btn {
  background-color: var(--primary-colour);
  color: var(--secondary-background);
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.25s ease-in-out, transform 0.1s ease;
}

.button.green-btn:hover {
  background-color: #1b5e20;
}

.button.green-btn:active {
  transform: scale(0.98);
}

/* Greyed-out state if any form requirements are unfulfilled */
form:has(input:invalid),
form:has(textarea:invalid) {
  & button[type="submit"] {
    background-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
    transform: none !important;
  }
}