/* ===========================
   HARMONISATION AVEC DETAILVIEW
   =========================== */

:root {
  /* Couleurs ESTAIR */
  --estair-blue: #4AA8DC;
  --estair-blue-dark: #3B82F6;
  --estair-blue-light: #E3F2FD;
  --estair-green: #8DA969;
  --estair-green-light: #E8F5E8;

  /* Couleurs Tabler */
  --tblr-primary: #206bc4;
  --tblr-secondary: #6c757d;
  --tblr-success: #2fb344;
  --tblr-warning: #f76707;
  --tblr-danger: #d63384;
  --tblr-info: #4299e1;

  /* Backgrounds */
  --tblr-bg: #f8fafc;
  --tblr-surface: #ffffff;
  --tblr-surface-secondary: #fafbfc;
  --tblr-surface-tertiary: #f1f5f9;

  /* Borders */
  --tblr-border-color: #e6e7e9;
  --tblr-border-color-light: #f1f5f9;

  /* Text */
  --tblr-body-color: #1e293b;
  --tblr-muted: #64748b;
  --tblr-light: #94a3b8;
}

/* ===========================
   LAYOUT HARMONISÉ (identique à detailview)
   =========================== */

.harmonized-create-view {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tblr-bg);
  color: var(--tblr-body-color);
  line-height: 1.5;
  font-size: 0.875rem;
}

.page-wrapper {
  min-height: 100vh;
  background: var(--tblr-bg);
}

.page-header {
  background: var(--tblr-surface);
  border-bottom: 1px solid var(--tblr-border-color);
  padding: 1.5rem 0;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--estair-blue) 0%, var(--estair-green) 100%);
  opacity: 0.05;
}

.container-xl {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-body {
  padding: 0;
}

/* ===========================
   ENTITY HEADER (identique à detailview)
   =========================== */

.entity-header {
  background: white;
  color: #182433;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative;
  border: 1px solid #dadfe7;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.entity-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.entity-avatar {
  width: 5rem;
  height: 5rem;
  background: #206bc4;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 8px rgba(32, 107, 196, 0.2);
  flex-shrink: 0;
}

.entity-info {
  flex: 1;
  min-width: 0;
}

.entity-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.2;
  color: #182433;
}

.entity-subtitle {
  font-size: 1rem;
  color: #667382;
  margin-bottom: 1.5rem;
}

.entity-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.entity-badge {
  background: #f8fafc;
  color: #667382;
  border: 1px solid #dadfe7;
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.entity-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.entity-action {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  border: none;
}

.entity-action:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.entity-action.primary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--estair-blue);
}

.entity-action.danger {
  background: rgba(220, 53, 69, 0.8);
  border-color: rgba(220, 53, 69, 0.9);
}

.entity-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===========================
   CARDS HARMONISÉES (identiques à detailview)
   =========================== */

.card {
  background: var(--tblr-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  margin-bottom: 1.5rem;
  transition: box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-surface-secondary);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tblr-body-color);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

/* ===========================
   FORMULAIRE GRID HARMONISÉ
   =========================== */

.harmonized-form-container {
  animation: fadeIn 0.3s ease-out;
}

/* ===========================
   ACCORDION HARMONIZED (identique à detailview)
   =========================== */

.accordion-harmonized {
  .expansion-panel-harmonized {
    background: var(--tblr-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.15s ease;

    &:hover {
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }

    .expansion-header-harmonized {
      padding: 1rem 1.25rem;
      border-bottom: 1px solid var(--tblr-border-color);
      background: var(--tblr-surface-secondary);
      border-radius: 8px 8px 0 0;

      .panel-title-harmonized {
        font-size: 1rem;
        font-weight: 600;
        color: var(--tblr-body-color);
        margin: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;

        .panel-icon {
          color: var(--estair-blue);
          font-size: 20px;
          width: 20px;
          height: 20px;
        }
      }

      .panel-description-harmonized {
        font-size: 0.875rem;
        color: var(--tblr-muted);
        margin: 0;
      }
    }

    .panel-content-harmonized {
      padding: 1.25rem;
    }
  }
}

.section-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr); /* Max 2 colonnes par ligne */
  max-width: 100%;
}

.form-grid-auto {
  grid-template-columns: repeat(2, 1fr); /* Max 2 colonnes par ligne */
}

.form-grid-1 {
  grid-template-columns: repeat(2, 1fr); /* Même structure pour cohérence */
}

.form-grid-2 {
  grid-template-columns: repeat(2, 1fr); /* Max 2 colonnes par ligne */
}

.form-grid-3 {
  grid-template-columns: repeat(2, 1fr); /* Max 2 colonnes par ligne */
}

.form-grid-4 {
  grid-template-columns: repeat(2, 1fr); /* Max 2 colonnes par ligne */
}

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

  .form-grid-1 {
    max-width: 100%; /* Sur mobile, prendre toute la largeur */
  }
}

.form-grid-item {
  display: block;
  max-width: 100%; /* S'assure que les items ne dépassent pas */
}

/* Tous les champs prennent 50% de l'espace (1 colonne sur 2) */
.form-grid .form-grid-item,
.form-grid .form-group {
  max-width: 100%; /* Utilise l'espace de la colonne (50%) */
}

@media (max-width: 768px) {
  .form-grid .form-grid-item,
  .form-grid .form-group {
    max-width: 100%; /* Sur mobile, prend toute la largeur */
  }
}

/* ===========================
   CONSERVATION DU DESIGN DES CHAMPS
   =========================== */

.form-dynamic {
  font-size: 0.875rem;
}

/* Conservation exacte des styles existants Angular Material */
::ng-deep .mat-primary .mat-option.mat-selected:not(.mat-option-disabled) {
  color: unset;
}

::ng-deep .mat-option-pseudo-checkbox.mat-pseudo-checkbox-checked {
  background-color: #3ea8da;
}

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

.error {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  color: var(--tblr-danger);
}

/* ===========================
   BUTTONS HARMONISÉS
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--tblr-body-color);
  text-decoration: none;
  background: var(--tblr-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-outline-primary {
  color: var(--estair-blue);
  border-color: var(--estair-blue);
  background: transparent;
}

.btn-outline-primary:hover {
  color: white;
  background: var(--estair-blue);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* ===========================
   UTILITIES HARMONISÉES
   =========================== */

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.me-2 { margin-right: 0.5rem; }
.ms-auto { margin-left: auto; }

.icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* ===========================
   RESPONSIVE HARMONISÉ
   =========================== */

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

  .entity-header {
    padding: 1.5rem;
  }

  .entity-content {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
  }

  .entity-avatar {
    align-self: center;
  }

  .entity-actions {
    justify-content: center;
  }

  .card-body {
    padding: 1rem;
  }
}

/* ===========================
   ANIMATIONS HARMONISÉES
   =========================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-grid-item {
  animation: fadeIn 0.2s ease-out;
}

/* ===========================
   ANGULAR MATERIAL OVERRIDES
   =========================== */

::ng-deep {
  // Mat-expansion-panel overrides pour accordion-harmonized
  .accordion-harmonized {
    .mat-expansion-panel {
      box-shadow: none !important;
      border-radius: 8px !important;
      margin-bottom: 1.5rem !important;
      border: 1px solid var(--tblr-border-color) !important;
      background: var(--tblr-surface) !important;

      &:not(.mat-expanded) {
        .mat-expansion-panel-header {
          border-radius: 8px !important;
        }
      }

      &:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
      }

      .mat-expansion-panel-header {
        padding: 1rem 1.25rem !important;
        background: var(--tblr-surface-secondary) !important;
        border-radius: 8px 8px 0 0 !important;
        height: auto !important;

        .mat-expansion-panel-header-title {
          font-size: 1rem !important;
          font-weight: 600 !important;
          color: var(--tblr-body-color) !important;
          display: flex !important;
          align-items: center !important;
          gap: 0.5rem !important;

          .panel-icon {
            color: var(--estair-blue) !important;
            font-size: 20px !important;
            width: 20px !important;
            height: 20px !important;
          }
        }

        .mat-expansion-panel-header-description {
          font-size: 0.875rem !important;
          color: var(--tblr-muted) !important;
          margin: 0 !important;
        }

        .mat-expansion-indicator {
          &::after {
            color: var(--estair-blue) !important;
          }
        }
      }

      .mat-expansion-panel-body {
        padding: 0 !important;
      }

      .mat-expansion-panel-content {
        .mat-expansion-panel-body {
          padding: 0 !important;
        }

        .panel-content-harmonized {
          padding: 1.25rem !important;
        }
      }
    }
  }
}