/* Modern Forms Enhancement - Canvas Inspired */

/* ============================================
   FORM CONTROLS BASE
   ============================================ */

.form-control {
  height: 45px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.5;
  color: #555;
  background-color: #fff;
  border: 2px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
  box-shadow: none;
}

textarea.form-control {
  height: auto;
  min-height: 120px;
  resize: vertical;
  padding: 12px 16px;
}

/* Focus State */
.form-control:focus {
  border-color: #667eea;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
  background-color: #fafbfc;
}

/* Placeholder */
.form-control::placeholder {
  color: #999;
  opacity: 1;
}

.form-control:focus::placeholder {
  color: #bbb;
}

/* Disabled State */
.form-control:disabled,
.form-control[readonly] {
  background-color: #f5f5f5;
  opacity: 0.7;
  cursor: not-allowed;
}

/* ============================================
   VALIDATION STATES
   ============================================ */

/* Success */
.form-control.is-valid,
.was-validated .form-control:valid {
  border-color: #28a745;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2328a745'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 40px;
}

.form-control.is-valid:focus,
.was-validated .form-control:valid:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15);
}

/* Error */
.form-control.is-invalid,
.was-validated .form-control:invalid {
  border-color: #dc3545;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23dc3545'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 40px;
}

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

/* Feedback Messages */
.valid-feedback {
  display: none;
  margin-top: 6px;
  font-size: 13px;
  color: #28a745;
  font-weight: 500;
}

.invalid-feedback {
  display: none;
  margin-top: 6px;
  font-size: 13px;
  color: #dc3545;
  font-weight: 500;
}

.was-validated .form-control:valid ~ .valid-feedback,
.form-control.is-valid ~ .valid-feedback {
  display: block;
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
  display: block;
}

/* ============================================
   INPUT GROUPS
   ============================================ */

.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

.input-group-prepend,
.input-group-append {
  display: flex;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: #555;
  text-align: center;
  white-space: nowrap;
  background-color: #f8f9fa;
  border: 2px solid #ddd;
  border-radius: 4px;
}

.input-group-prepend .input-group-text {
  border-right: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-append .input-group-text {
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group > .form-control:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group > .form-control:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Icon inside input group */
.input-group-text i {
  min-width: 16px;
  text-align: center;
  color: #667eea;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-enviar,
.btn-primary,
button[type="submit"] {
  display: inline-block;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 2px solid transparent;
  padding: 12px 32px;
  font-size: 15px;
  line-height: 1.5;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
  min-width: 140px;
}

.btn-enviar:hover,
.btn-primary:hover,
button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  color: #fff;
}

.btn-enviar:active,
.btn-primary:active,
button[type="submit"]:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-enviar:focus,
.btn-primary:focus,
button[type="submit"]:focus {
  outline: 3px solid rgba(102, 126, 234, 0.3);
  outline-offset: 2px;
}

/* Button Loading State */
.btn-enviar.loading,
.btn-primary.loading,
button[type="submit"].loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn-enviar.loading::after,
.btn-primary.loading::after,
button[type="submit"].loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin: -10px 0 0 -10px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Button Disabled */
.btn-enviar:disabled,
.btn-primary:disabled,
button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================
   SELECT DROPDOWN
   ============================================ */

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23555'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

select.form-control:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23667eea'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
}

/* ============================================
   CHECKBOX & RADIO
   ============================================ */

.form-check {
  position: relative;
  display: block;
  padding-left: 28px;
  margin-bottom: 12px;
}

.form-check-input {
  position: absolute;
  margin-top: 4px;
  margin-left: -28px;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.form-check-input[type="checkbox"] {
  appearance: none;
  border: 2px solid #ddd;
  border-radius: 4px;
  background-color: #fff;
  transition: all 0.3s ease;
}

.form-check-input[type="checkbox"]:checked {
  background-color: #667eea;
  border-color: #667eea;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23fff'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}

.form-check-input[type="radio"] {
  appearance: none;
  border: 2px solid #ddd;
  border-radius: 50%;
  background-color: #fff;
  transition: all 0.3s ease;
}

.form-check-input[type="radio"]:checked {
  border-color: #667eea;
  background-color: #fff;
  box-shadow: inset 0 0 0 4px #667eea;
}

.form-check-input:focus {
  outline: 2px solid rgba(102, 126, 234, 0.3);
  outline-offset: 2px;
}

.form-check-label {
  margin-bottom: 0;
  cursor: pointer;
  font-size: 15px;
  color: #555;
}

/* ============================================
   FORM GROUPS & SPACING
   ============================================ */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.form-group label .required {
  color: #dc3545;
  margin-left: 3px;
}

/* Legend/Fieldset */
legend {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #eee;
}

legend small {
  font-size: 13px;
  font-weight: 400;
  color: #666;
  display: block;
  margin-top: 5px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 575px) {
  .form-control {
    height: 44px;
    font-size: 16px; /* Prevent iOS zoom */
  }
  
  .btn-enviar,
  .btn-primary,
  button[type="submit"] {
    width: 100%;
    padding: 14px 20px;
  }
  
  .form-group {
    margin-bottom: 16px;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .form-control {
    border-width: 3px;
  }
  
  .form-control:focus {
    border-width: 3px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .form-control,
  .btn-enviar,
  .btn-primary,
  button[type="submit"] {
    transition: none;
  }
}

/* ============================================
   RECAPTCHA STYLING
   ============================================ */

.g-recaptcha {
  margin: 15px 0;
  display: inline-block;
}

/* Center recaptcha on mobile */
@media (max-width: 575px) {
  .g-recaptcha {
    transform: scale(0.85);
    transform-origin: 0 0;
  }
}
