/* ========================================
   RESPONSIVE FORM SYSTEM
   ======================================== */

/* Base form styles */
.responsive-form {
  max-width: 100%;
  margin: 0 auto;
}

.form-container {
  background: #fff;
  border-radius: 0.375rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.form-header {
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.form-header h5 {
  margin: 0;
  color: #495057;
  font-weight: 600;
}

/* Form grid system */
.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.form-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* Form groups */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
  display: block;
}

.form-group .form-label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
}

.form-group .form-text {
  font-size: 0.875rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

/* Form controls */
.form-control,
.form-select {
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.9rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #dc3545;
}

.form-control.is-valid,
.form-select.is-valid {
  border-color: #198754;
}

/* Button groups */
.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #dee2e6;
}

.form-actions .btn {
  min-width: 100px;
}

.form-actions .btn-primary {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.form-actions .btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .form-container {
    padding: 1rem;
    margin-bottom: 0.75rem;
  }
  
  .form-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
  }
  
  .form-grid,
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .form-group {
    margin-bottom: 0.75rem;
  }
  
  .form-control,
  .form-select {
    padding: 0.625rem;
    font-size: 0.875rem;
  }
  
  .form-actions {
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
  }
  
  .form-actions .btn {
    width: 100%;
    min-width: auto;
  }
}

@media (max-width: 480px) {
  .form-container {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
  }
  
  .form-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
  }
  
  .form-header h5 {
    font-size: 1.1rem;
  }
  
  .form-group {
    margin-bottom: 0.5rem;
  }
  
  .form-control,
  .form-select {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  
  .form-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
  }
}

/* Card-based form layout for mobile */
.form-card {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background: #fff;
  margin-bottom: 1rem;
  overflow: hidden;
}

.form-card-header {
  background: #f8f9fa;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  color: #495057;
}

.form-card-body {
  padding: 1rem;
}

@media (max-width: 768px) {
  .form-card {
    margin-bottom: 0.75rem;
  }
  
  .form-card-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
  
  .form-card-body {
    padding: 0.75rem;
  }
}

/* Inline forms */
.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.form-inline .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

@media (max-width: 768px) {
  .form-inline {
    flex-direction: column;
  }
  
  .form-inline .form-group {
    min-width: auto;
    width: 100%;
  }
}

/* Validation styles */
.invalid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #dc3545;
}

.valid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #198754;
}

/* Required field indicator */
.required::after {
  content: " *";
  color: #dc3545;
}

/* Loading state */
.form-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.form-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Success/error states */
.form-success {
  background-color: #d1e7dd;
  border: 1px solid #badbcc;
  color: #0f5132;
  padding: 0.75rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.form-error {
  background-color: #f8d7da;
  border: 1px solid #f5c2c7;
  color: #842029;
  padding: 0.75rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

/* Checkbox and radio groups */
.form-check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .form-check-group {
    gap: 0.75rem;
  }
  
  .form-check {
    flex: 1 1 45%;
  }
}

/* File upload styling */
.form-file {
  position: relative;
  display: inline-block;
  cursor: pointer;
  width: 100%;
}

.form-file input[type="file"] {
  position: absolute;
  left: -9999px;
}

.form-file-label {
  display: block;
  padding: 0.75rem;
  border: 1px dashed #ced4da;
  border-radius: 0.375rem;
  text-align: center;
  background: #f8f9fa;
  transition: all 0.2s ease;
}

.form-file-label:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

/* Print styles */
@media print {
  .form-actions,
  .form-loading::after {
    display: none !important;
  }
  
  .form-container {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }
}
