/**
 * Quokka - Forms Stylesheet
 * 
 * This file contains enhanced form styling for Drupal forms
 * using Bootstrap 5 components and custom enhancements.
 */

/* ==========================================================================
   Base Form Styling
   ========================================================================== */

.form-wrapper {
  background-color: #fff;
  border-radius: 0.5rem;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.form-wrapper h2,
.form-wrapper h3 {
  color: #495057;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

/* ==========================================================================
   Form Controls
   ========================================================================== */

.form-control,
.form-select {
  border: 2px solid #e9ecef;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: all 0.3s ease;
  background-color: #fff;
}

.form-control:focus,
.form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
  background-color: #fff;
}

.form-control:hover:not(:focus),
.form-select:hover:not(:focus) {
  border-color: #ced4da;
}

/* Textarea specific styling */
textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

/* Select styling */
.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 16px 12px;
  padding-right: 3rem;
}

/* ==========================================================================
   Form Labels and Help Text
   ========================================================================== */

.form-label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
  display: block;
}

.form-label.required::after {
  content: " *";
  color: #dc3545;
  font-weight: bold;
}

.form-text {
  font-size: 0.875rem;
  color: #6c757d;
  margin-top: 0.25rem;
  line-height: 1.4;
}

.form-text.help-text {
  background-color: #f8f9fa;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border-left: 3px solid #0d6efd;
}

/* ==========================================================================
   Checkboxes and Radios
   ========================================================================== */

.form-check {
  padding-left: 1.75em;
  margin-bottom: 1rem;
}

.form-check-input {
  width: 1.25em;
  height: 1.25em;
  margin-top: 0.125em;
  margin-left: -1.75em;
  border: 2px solid #dee2e6;
  transition: all 0.3s ease;
}

.form-check-input:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.form-check-input:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.form-check-label {
  font-weight: 500;
  color: #495057;
  cursor: pointer;
  line-height: 1.5;
}

/* Checkbox groups */
.form-check-group {
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.form-check-group .form-check {
  margin-bottom: 0.5rem;
}

.form-check-group .form-check:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Input Groups
   ========================================================================== */

.input-group {
  margin-bottom: 1rem;
}

.input-group .form-control {
  border-radius: 0;
}

.input-group .form-control:first-child {
  border-top-left-radius: 0.5rem;
  border-bottom-left-radius: 0.5rem;
}

.input-group .form-control:last-child {
  border-top-right-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.input-group-text {
  background-color: #f8f9fa;
  border: 2px solid #e9ecef;
  color: #495057;
  font-weight: 500;
  padding: 0.75rem 1rem;
}

.input-group:focus-within .input-group-text {
  border-color: #0d6efd;
  background-color: #e7f1ff;
}

/* ==========================================================================
   File Upload
   ========================================================================== */

.form-control[type="file"] {
  padding: 0.5rem;
  cursor: pointer;
}

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

.file-upload-custom {
  position: relative;
  overflow: hidden;
  display: inline-block;
  width: 100%;
  background-color: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.file-upload-custom:hover {
  border-color: #0d6efd;
  background-color: #e7f1ff;
}

.file-upload-custom input[type="file"] {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.file-upload-custom .upload-icon {
  font-size: 2rem;
  color: #6c757d;
  margin-bottom: 0.5rem;
}

.file-upload-custom .upload-text {
  color: #495057;
  font-weight: 500;
}

.file-upload-custom .upload-hint {
  color: #6c757d;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   Form Validation
   ========================================================================== */

.was-validated .form-control:valid,
.form-control.is-valid {
  border-color: #198754;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='m2.3 6.73.94-.94 1.44 1.44L7.5 4.41l.94.94L4.69 9.19z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:valid:focus,
.form-control.is-valid:focus {
  border-color: #198754;
  box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

.was-validated .form-control:invalid,
.form-control.is-invalid {
  border-color: #dc3545;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 1.4 1.4M7.2 4.6l-1.4 1.4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:invalid:focus,
.form-control.is-invalid:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.valid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: #198754;
  font-weight: 500;
}

.invalid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: #dc3545;
  font-weight: 500;
}

/* ==========================================================================
   Form Buttons
   ========================================================================== */

.form-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-actions .btn {
  min-width: 120px;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
}

.form-actions .btn-primary {
  background: linear-gradient(45deg, #0d6efd, #6610f2);
  border: none;
  box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.form-actions .btn-primary:hover {
  background: linear-gradient(45deg, #0b5ed7, #5a0fc8);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(13, 110, 253, 0.4);
}

.form-actions .btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
}

.form-actions .btn-secondary:hover {
  background-color: #5c636a;
  border-color: #565e64;
  transform: translateY(-1px);
}

/* ==========================================================================
   Fieldsets and Form Groups
   ========================================================================== */

fieldset {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  background-color: #f8f9fa;
}

fieldset legend {
  font-weight: 600;
  color: #495057;
  padding: 0 0.5rem;
  margin-bottom: 0;
  font-size: 1.1rem;
  background-color: #fff;
  border-radius: 0.25rem;
  padding: 0.25rem 0.75rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Responsive Form Design
   ========================================================================== */

@media (max-width: 767.98px) {
  .form-wrapper {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .input-group .form-control,
  .input-group .input-group-text {
    border-radius: 0.5rem !important;
    margin-bottom: 0.5rem;
  }
  
  .input-group .input-group-text {
    margin-bottom: 0;
  }
}

/* ==========================================================================
   Special Form Types
   ========================================================================== */

/* Search forms */
.search-form {
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  padding: 1rem;
}

.search-form .input-group {
  margin-bottom: 0;
}

.search-form .form-control {
  border-right: none;
}

.search-form .btn {
  border-left: none;
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: white;
}

.search-form .btn:hover {
  background-color: #0b5ed7;
  border-color: #0a58ca;
}

/* Contact forms */
.contact-form {
  max-width: 600px;
  margin: 0 auto;
}

.contact-form .form-floating {
  margin-bottom: 1rem;
}

/* Login forms */
.login-form {
  max-width: 400px;
  margin: 2rem auto;
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.login-form .form-control {
  padding: 1rem;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.login-form .btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1rem;
}

/* Ensure form actions are properly styled */
.login-form .form-actions {
  margin-top: 1.5rem;
}

.login-form .form-actions .btn {
  margin-top: 0;
}

/* Error messages in login form */
.login-form .form-item--error-message {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Success messages in login form */
.login-form .messages--status {
  background-color: #d1edff;
  border: 1px solid #bee5eb;
  color: #0c5460;
  padding: 0.75rem 1.25rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

