/*
 * =====================================================
 * FORMS MODERN - Style AdminLTE
 * Application de gestion de pressing
 * Version 2.0 - UX/UI Améliorée
 * =====================================================
 */

/* ==================== FORM CONTAINER ==================== */

.form-container {
  background: #ffffff;
  border-radius: 0.25rem;
  box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-container:hover {
  box-shadow: 0 0 1px rgba(0,0,0,.125), 0 3px 8px rgba(0,0,0,.25);
}

/* ==================== FORM HEADER ==================== */

.form-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #f4f6f9;
}

.form-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  box-shadow: 0 4px 6px rgba(0, 123, 255, 0.3);
}

.form-header-icon svg {
  width: 24px;
  height: 24px;
}

.form-header-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #343a40;
  margin: 0;
  line-height: 1.2;
}

.form-header-content p {
  font-size: 0.875rem;
  color: #6c757d;
  margin: 0.25rem 0 0 0;
}

/* ==================== FORM SECTIONS ==================== */

.form-section {
  margin-bottom: 2rem;
}

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

.form-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-left: 3px solid #007bff;
  border-radius: 0.25rem;
  margin-bottom: 1.25rem;
}

.form-section-header svg {
  width: 20px;
  height: 20px;
  color: #007bff;
  flex-shrink: 0;
}

.form-section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #343a40;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-section-subtitle {
  font-size: 0.8125rem;
  color: #6c757d;
  margin: 0.25rem 0 0 0;
}

/* ==================== FORM GROUPS ==================== */

.form-group-modern {
  margin-bottom: 1.25rem;
}

.form-row-modern {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.form-row-modern.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.form-row-modern.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.form-row-modern.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
  .form-row-modern,
  .form-row-modern.cols-2,
  .form-row-modern.cols-3,
  .form-row-modern.cols-4 {
    grid-template-columns: 1fr;
  }
}

/* ==================== LABELS ==================== */

.form-label-modern {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-label-modern svg {
  width: 14px;
  height: 14px;
  color: #6c757d;
}

.form-label-modern.required::after {
  content: ' *';
  color: #dc3545;
  font-weight: 700;
}

.form-label-hint {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: #6c757d;
  margin-top: 0.25rem;
  text-transform: none;
  letter-spacing: normal;
}

/* ==================== INPUTS ==================== */

.form-control-modern,
.form-input-modern {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: #495057;
  background-color: #fff;
  background-clip: padding-box;
  border: 2px solid #ced4da;
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.form-control-modern:focus,
.form-input-modern:focus {
  color: #495057;
  background-color: #fff;
  border-color: #007bff;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.15);
}

.form-control-modern:disabled,
.form-input-modern:disabled {
  background-color: #e9ecef;
  opacity: 0.7;
  cursor: not-allowed;
}

.form-control-modern::placeholder,
.form-input-modern::placeholder {
  color: #adb5bd;
  opacity: 0.8;
}

/* Tailles des inputs */
.form-control-modern.form-control-sm {
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
}

.form-control-modern.form-control-lg {
  padding: 0.75rem 1rem;
  font-size: 1.0625rem;
}

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

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

.input-group-modern .form-control-modern {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

/* Input avec icône à gauche */
.input-group-modern.has-icon-left .form-control-modern {
  padding-left: 2.75rem;
}

.input-group-icon-left {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  pointer-events: none;
  z-index: 5;
  width: 18px;
  height: 18px;
}

/* Input avec icône à droite */
.input-group-modern.has-icon-right .form-control-modern {
  padding-right: 2.75rem;
}

.input-group-icon-right {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  pointer-events: none;
  z-index: 5;
  width: 18px;
  height: 18px;
}

/* Input group avec bouton */
.input-group-modern .btn {
  position: relative;
  z-index: 2;
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

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

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

.form-select-modern {
  display: block;
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: #495057;
  background-color: #fff;
  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='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  border: 2px solid #ced4da;
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  appearance: none;
}

.form-select-modern:focus {
  border-color: #007bff;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.15);
}

.form-select-modern:disabled {
  background-color: #e9ecef;
  opacity: 0.7;
  cursor: not-allowed;
}

/* ==================== TEXTAREA ==================== */

.form-textarea-modern {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.6;
  color: #495057;
  background-color: #fff;
  border: 2px solid #ced4da;
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  resize: vertical;
  min-height: 100px;
}

.form-textarea-modern:focus {
  color: #495057;
  background-color: #fff;
  border-color: #007bff;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.15);
}

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

.form-check-modern {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.75rem;
}

.form-check-modern:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-check-modern input[type="checkbox"],
.form-check-modern input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.form-check-modern input[type="checkbox"]:checked,
.form-check-modern input[type="radio"]:checked {
  accent-color: #007bff;
}

.form-check-modern label {
  margin: 0;
  cursor: pointer;
  font-size: 0.9375rem;
  color: #495057;
  font-weight: 500;
  user-select: none;
  flex: 1;
}

.form-check-modern.checked {
  background: rgba(0, 123, 255, 0.1);
  border-color: #007bff;
}

/* Checkboxes inline */
.form-checks-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-checks-inline .form-check-modern {
  flex: 0 1 auto;
  margin-bottom: 0;
}

/* ==================== SWITCH ==================== */

.form-switch-modern {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.form-switch-modern input[type="checkbox"] {
  width: 48px;
  height: 24px;
  appearance: none;
  background: #ced4da;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
  margin: 0;
  flex-shrink: 0;
}

.form-switch-modern input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: left 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-switch-modern input[type="checkbox"]:checked {
  background: #28a745;
}

.form-switch-modern input[type="checkbox"]:checked::before {
  left: 26px;
}

.form-switch-modern label {
  margin: 0;
  cursor: pointer;
  font-size: 0.9375rem;
  color: #495057;
  font-weight: 500;
  user-select: none;
}

/* ==================== FILE INPUT ==================== */

.form-file-modern {
  position: relative;
  display: inline-block;
  width: 100%;
}

.form-file-modern input[type="file"] {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.form-file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  border: 2px dashed #ced4da;
  border-radius: 0.375rem;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  color: #6c757d;
  font-weight: 500;
}

.form-file-label:hover {
  border-color: #007bff;
  background: rgba(0, 123, 255, 0.05);
  color: #007bff;
}

.form-file-label svg {
  width: 32px;
  height: 32px;
}

.form-file-modern input[type="file"]:focus + .form-file-label {
  border-color: #007bff;
  box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.15);
}

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

/* Valid */
.form-control-modern.is-valid,
.form-select-modern.is-valid,
.form-textarea-modern.is-valid {
  border-color: #28a745;
  padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2328a745' stroke-width='3'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 20px 20px;
}

.form-control-modern.is-valid:focus,
.form-select-modern.is-valid:focus,
.form-textarea-modern.is-valid:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.15);
}

/* Invalid */
.form-control-modern.is-invalid,
.form-select-modern.is-invalid,
.form-textarea-modern.is-invalid {
  border-color: #dc3545;
  padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc3545' stroke-width='3'%3e%3cline x1='18' y1='6' x2='6' y2='18'%3e%3c/line%3e%3cline x1='6' y1='6' x2='18' y2='18'%3e%3c/line%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 20px 20px;
}

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

/* Feedback messages */
.form-feedback-valid {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: #28a745;
  font-weight: 500;
}

.form-feedback-invalid {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: #dc3545;
  font-weight: 500;
}

.form-feedback-valid svg,
.form-feedback-invalid svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ==================== FORM TEXT / HELPER ==================== */

.form-text-modern {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: #6c757d;
  line-height: 1.4;
}

.form-text-modern svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ==================== FORM ACTIONS ==================== */

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: 2px solid #f4f6f9;
}

.form-actions.sticky {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 1.25rem;
  margin: 0 -1.5rem -1.5rem;
  border-top: 2px solid #dee2e6;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.form-actions .btn {
  min-width: 120px;
}

.form-actions .btn-primary {
  order: 1;
}

.form-actions .btn-secondary {
  order: 2;
}

@media (max-width: 576px) {
  .form-actions {
    flex-direction: column;
    width: 100%;
  }

  .form-actions .btn {
    width: 100%;
  }
}

/* ==================== FORM GRID LAYOUT ==================== */

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.form-grid.two-columns {
  grid-template-columns: 2fr 1fr;
}

@media (max-width: 992px) {
  .form-grid.two-columns {
    grid-template-columns: 1fr;
  }
}

/* ==================== FORM CARD STYLE ==================== */

.form-card {
  background: white;
  border-radius: 0.25rem;
  box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border-left: 3px solid #007bff;
}

.form-card.success {
  border-left-color: #28a745;
}

.form-card.warning {
  border-left-color: #ffc107;
}

.form-card.danger {
  border-left-color: #dc3545;
}

.form-card.info {
  border-left-color: #17a2b8;
}

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

@media (max-width: 768px) {
  .form-container {
    padding: 1rem;
  }

  .form-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-header-icon {
    width: 40px;
    height: 40px;
  }

  .form-header-content h2 {
    font-size: 1.25rem;
  }

  .form-section-header {
    padding: 0.5rem 0.75rem;
  }

  .form-section-title {
    font-size: 1rem;
  }

  .form-label-modern {
    font-size: 0.8125rem;
  }

  .form-control-modern,
  .form-select-modern,
  .form-textarea-modern {
    font-size: 0.875rem;
  }
}

/* ==================== LOADING STATE ==================== */

.form-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.form-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==================== UTILITIES ==================== */

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.form-inline .form-group-modern {
  flex: 1 1 auto;
  margin-bottom: 0;
}

.form-readonly {
  background-color: #f8f9fa;
  border-color: #e9ecef;
  cursor: not-allowed;
}

.form-hidden {
  display: none;
}
