/* ==========================================================================
   Easy MSP - Feuilles de styles (Inspiré d'Easy NATINF)
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1e3a8a;
  --primary-hover: #172554;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Layout Container
   -------------------------------------------------------------------------- */
.app-container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem 1rem;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.app-header {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.brand-titles h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.brand-titles p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-accent {
  background-color: var(--accent);
  color: #ffffff;
}
.btn-accent:hover {
  background-color: #1d4ed8;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #f1f5f9;
}

.btn-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}
.btn-danger:hover {
  background-color: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-icon {
  padding: 8px 10px;
}

/* --------------------------------------------------------------------------
   Search & Filters Box (Easy NATINF style)
   -------------------------------------------------------------------------- */
.search-filter-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.search-wrapper {
  position: relative;
  margin-bottom: 1.2rem;
}

.search-input {
  width: 100%;
  padding: 0.85rem 2.8rem 0.85rem 2.8rem;
  font-size: 1.05rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background-color: #f8fafc;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.search-input:focus {
  border-color: var(--accent);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.search-icon-left {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: #e2e8f0;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #475569;
}
.search-clear-btn:hover {
  background: #cbd5e1;
}

/* Filters section */
.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.filters-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.filters-toggles {
  display: flex;
  gap: 8px;
}

.filter-pill-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  color: #334155;
}

.filter-pill:hover {
  background: #e2e8f0;
}

.filter-pill input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.filter-pill.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   Publics Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.badge-FIAPM { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-FCOPM { background: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }
.badge-POMPIERS { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-ACCUEIL { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-SITUATIONS_COMPLEXES, .badge-SITUATIONS-COMPLEXES { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-MANAGEMENT { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.badge-MANAGEMENT_PM, .badge-MANAGEMENT-PM { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* Styles modale gestion des publics */
.manage-publics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.manage-public-item, .public-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: background 0.15s ease;
}

.manage-public-item:hover, .public-manage-item:hover {
  background: #f1f5f9;
}

.manage-public-info, .public-manage-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.manage-public-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
}

.public-count-tag {
  font-size: 0.76rem;
  color: var(--text-muted);
  background: #e2e8f0;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 600;
}

.manage-public-del-btn {
  background: #fff;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.manage-public-del-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* --------------------------------------------------------------------------
   Results Area & MSP Cards
   -------------------------------------------------------------------------- */
.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0 4px;
}

.results-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.msp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.msp-card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  position: relative;
}

.msp-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.msp-card-header {
  margin-bottom: 0.75rem;
}

.msp-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0.6rem;
}

.msp-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

.msp-preview {
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.45;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msp-keywords {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px dashed var(--border-color);
  margin-bottom: 1rem;
  word-break: break-word;
}

.msp-keywords strong {
  color: #334155;
}

.msp-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.85rem;
  margin-top: auto;
  gap: 8px;
}

.highlight {
  background-color: #fef08a;
  color: #854d0e;
  font-weight: bold;
  padding: 0 2px;
  border-radius: 2px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: #ffffff;
  border-radius: 12px;
  border: 1px dashed var(--border-color);
  grid-column: 1 / -1;
}
.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

/* --------------------------------------------------------------------------
   Modal Window (Detailed View & Form Mask)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-backdrop.open {
  display: flex;
}

.modal-window {
  background: #ffffff;
  width: 100%;
  max-width: 850px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f8fafc;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
}
.modal-close-btn:hover {
  color: var(--text-main);
  background: #e2e8f0;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  line-height: 1.6;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  flex-wrap: wrap;
}

/* Detail View Layout (Official MSP Trame) */
.detail-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.detail-actions-top {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.section-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.section-box.highlight-box {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.section-box.alert-box {
  background: #fffbeb;
  border-color: #fde68a;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-content {
  font-size: 0.95rem;
  color: #334155;
  white-space: pre-wrap;
}

.comedien-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 680px) {
  .comedien-grid {
    grid-template-columns: 1fr;
  }
}

/* Form Styling (Masque de saisie) */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
  color: #1e293b;
}

.form-label .required {
  color: #ef4444;
}

.form-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

.publics-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.public-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Toast Notification
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn 0.25s ease-out;
}

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

/* --------------------------------------------------------------------------
   Print Stylesheet (@media print) - Pedagogical A4 Briefing Sheet
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }

  .app-header,
  .search-filter-box,
  .results-meta,
  .msp-grid,
  .modal-backdrop:not(.open),
  .modal-close-btn,
  .modal-footer,
  .detail-actions-top,
  .toast-container {
    display: none !important;
  }

  .modal-backdrop.open {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
  }

  .modal-window {
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
  }

  .modal-header {
    background: transparent !important;
    border-bottom: 2px solid #000000 !important;
    padding: 0 0 10px 0 !important;
  }

  .modal-header h2 {
    font-size: 16pt !important;
    color: #000000 !important;
  }

  .modal-body {
    padding: 15px 0 !important;
  }

  .section-box {
    border: 1px solid #475569 !important;
    page-break-inside: avoid;
    margin-bottom: 12px !important;
    padding: 8px 12px !important;
  }

  .section-title {
    color: #000000 !important;
    font-size: 10pt !important;
  }

  .comedien-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .badge {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    background: #ffffff !important;
  }
}
