/* =============================================================================
   Formulaire action — modal
   ============================================================================= */

.af-modal {
  border: none;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  background: #fff;
}

/* Bootstrap modal-dialog-scrollable cible .modal-body — nos modales utilisent .af-modal__body */
.modal-dialog-scrollable .af-modal {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 3.5rem);
  max-height: calc(100dvh - 3.5rem);
}

.modal-dialog-scrollable .af-modal > .af-modal__header,
.modal-dialog-scrollable .af-modal__footer {
  flex-shrink: 0;
}

.modal-dialog-scrollable .af-modal > .af-modal__form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-dialog-scrollable .af-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.af-modal__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 16px;
  background: #fff;
  border-bottom: 1px solid #e8eaed;
  position: relative;
}

.af-modal__header-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1;
  min-width: 0;
  padding-right: 40px;
}

.af-modal__header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: #e8f0fe;
  color: #1a73e8;
}

.af-modal__header-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.af-modal__title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  color: #1f1f1f;
  line-height: 1.25;
}

.af-modal__subtitle {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #5f6368;
  line-height: 1.45;
}

.af-modal__badge {
  position: absolute;
  top: 20px;
  right: 52px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff7df;
  color: #9a6700;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.af-modal__close {
  position: absolute;
  top: 20px;
  right: 20px;
}

.af-modal__form {
  display: flex;
  flex-direction: column;
}

.af-modal__body {
  padding: 20px 24px;
}

.af-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.af-form-grid__col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.af-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.af-section--last {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.af-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5f6368;
}

.af-section__icon svg {
  width: 16px;
  height: 16px;
  stroke: #1a73e8;
}

.af-optional {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: #9aa0a6;
}

.af-fields {
  display: grid;
  gap: 14px;
}

.af-fields--2 {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.af-field label,
.af-field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #3c4043;
}

.af-required {
  color: #d93025;
}

.af-input,
.af-textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 400;
  color: #1f1f1f;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.af-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.af-input::placeholder,
.af-textarea::placeholder {
  color: #9e9e9e;
}

.af-input:focus,
.af-textarea:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.af-input--valid {
  border-color: #34a853;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2334a853' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.af-input--invalid {
  border-color: #d93025;
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.1);
}

.af-field__hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #9aa0a6;
}

.af-field__error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #d93025;
}

.af-input-wrap,
.af-combobox {
  position: relative;
}

.af-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa0a6;
  pointer-events: none;
  z-index: 1;
}

.af-input-icon svg {
  width: 16px;
  height: 16px;
}

.af-combobox .af-input,
.af-input-wrap .af-input {
  padding-left: 38px;
}

.af-combobox__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
}

.af-combobox__list li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
}

.af-combobox__list li:hover {
  background: #e8f0fe;
  color: #1a73e8;
}

.af-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.af-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #e0e0e0;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: #5f6368;
  cursor: pointer;
  transition: all 0.15s ease;
  margin: 0;
  position: relative;
}

.af-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.af-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.af-pill:has(input:checked) {
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

.af-pill--secondary:has(input:checked) { background: #f1f3f4; color: #5f6368; }
.af-pill--warning:has(input:checked) { background: #fff7df; color: #9a6700; }
.af-pill--success:has(input:checked) { background: #e6f4ea; color: #137333; }
.af-pill--priority-high:has(input:checked) { background: #fce8e6; color: #c5221f; }
.af-pill--priority-medium:has(input:checked) { background: #fff7df; color: #9a6700; }
.af-pill--priority-low:has(input:checked) { background: #e6f4ea; color: #137333; }

.af-pill svg {
  width: 14px;
  height: 14px;
}

.af-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.af-alert--warning {
  background: #fff7df;
  color: #9a6700;
  border: 1px solid #ffebb2;
}

.af-alert svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.af-modal__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid #e8eaed;
  background: #fafafa;
}

.af-modal__footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.af-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

.af-btn svg {
  width: 16px;
  height: 16px;
}

.af-btn--ghost {
  background: #f5f5f5;
  color: #3c4043;
  border: 1px solid #e0e0e0;
}

.btn.af-btn--ghost:hover,
.btn.af-btn--ghost:focus,
.btn.af-btn--ghost:active {
  background: #eee;
  color: #3c4043;
  border-color: #e0e0e0;
}

.af-btn--primary {
  background: #2196f3;
  color: #fff;
  border: 1px solid #2196f3;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.35);
}

.btn.af-btn--primary:hover,
.btn.af-btn--primary:focus,
.btn.af-btn--primary:active {
  background: #1a87e0;
  color: #fff;
  border-color: #1a87e0;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn.af-btn--primary:hover svg,
.btn.af-btn--primary:focus svg,
.btn.af-btn--primary:active svg {
  stroke: #fff;
}

.btn.af-btn--primary:disabled,
.btn.af-btn--primary[disabled] {
  background: #2196f3;
  color: #fff;
  border-color: #2196f3;
  opacity: 0.65;
}

.af-btn--danger {
  background: #fff;
  color: #d93025;
  border: 1px solid #f5c6c2;
}

.btn.af-btn--danger:hover,
.btn.af-btn--danger:focus,
.btn.af-btn--danger:active {
  background: #fce8e6;
  color: #d93025;
  border-color: #f5c6c2;
}

/* Sous-action modal */
.sa-parent-card {
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
  border: 1px solid #c5d9fb;
}

.sa-parent-card__label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1a73e8;
}

.sa-parent-card__title {
  display: block;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: #1f1f1f;
  line-height: 1.4;
}

.sa-parent-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #5f6368;
}

.sa-parent-card__meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sa-parent-card__empty {
  margin: 0;
  color: #9aa0a6;
  font-size: 14px;
}

.sa-modal__footer {
  justify-content: space-between;
}

.sa-modal__footer .af-modal__footer-actions {
  margin-left: auto;
}

@media (max-width: 767px) {
  .sa-modal__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .sa-modal__footer .af-btn--danger {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 991px) {
  .af-form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .af-form-grid__col:first-child .af-section:last-child {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
  }
}

@media (max-width: 767px) {
  .af-modal__header,
  .af-modal__body,
  .af-modal__footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .af-fields--2 {
    grid-template-columns: 1fr;
  }

  .af-modal__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .af-modal__footer-actions {
    flex-direction: column-reverse;
  }

  .af-btn {
    justify-content: center;
    width: 100%;
  }

  .af-pills {
    flex-direction: column;
  }

  .af-pill {
    justify-content: center;
  }
}
