/* ==========================================================
   Ma Blainville - Design System & Stylesheet
   Modern, Clean & Responsive UI
   ========================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-rgb: 37, 99, 235;

  --accent: #059669;
  --accent-hover: #047857;
  --accent-light: #ecfdf5;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;

  --warning: #d97706;
  --warning-light: #fffbeb;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfdfe;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border: #e2e8f0;
  --border-focus: #93c5fd;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mode Sombre */
[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #24344d;
  --bg-glass: rgba(30, 41, 59, 0.85);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --border: #334155;
  --border-focus: #3b82f6;

  --primary-light: #1e3a8a;
  --accent-light: #064e3b;
  --danger-light: #7f1d1d;
  --warning-light: #78350f;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ================= HEADER & NAVBAR ================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.35);
}

.brand-title {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ================= BOUTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text-main);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.2);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: var(--border);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

/* ================= BANNIÈRE D'ACCUEIL ================= */
.hero-section {
  padding: 2.5rem 1.25rem 1.5rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-main) 100%);
  border-bottom: 1px solid var(--border);
}

.hero-content {
  max-width: 760px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.0625rem;
  margin-bottom: 1.75rem;
}

/* ================= BARRE DE RECHERCHE GLOBALE ================= */
.search-wrapper {
  max-width: 600px;
  margin: 0 auto 1.25rem;
  position: relative;
}

.search-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.6rem 0.4rem 1.25rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.search-input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15);
}

.search-icon {
  color: var(--text-light);
  margin-right: 0.75rem;
  font-size: 1.1rem;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-main);
}
.search-input::placeholder {
  color: var(--text-light);
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.4rem;
  font-size: 0.9rem;
  display: none;
}
.search-clear-btn:hover {
  color: var(--text-main);
}

.stats-badges {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.stat-item strong {
  color: var(--primary);
  font-weight: 700;
}

/* ================= BARRE ADMIN ================= */
.admin-toolbar {
  background: #1e1e24;
  color: #fff;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  font-size: 0.875rem;
}

.admin-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-status-tag {
  background: var(--accent);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ================= FILTRES DE CATÉGORIES ================= */
.categories-nav-section {
  max-width: 1280px;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem;
}

.categories-scroll-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.cat-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.35);
}

.cat-count {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--border);
  color: var(--text-muted);
}
.cat-pill.active .cat-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ================= CONTENU PRINCIPAL ================= */
.main-container {
  max-width: 1280px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.25rem;
  flex: 1;
  width: 100%;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.results-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-toggles {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: var(--transition);
}
.view-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ================= TABLEAU DES PRESTATAIRES ================= */
.references-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.references-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.references-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

[data-theme="dark"] .references-table th {
  background: #1e293b;
  color: #94a3b8;
}

.references-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.references-table tbody tr {
  transition: background-color 0.15s ease;
}

.references-table tbody tr:hover {
  background: var(--primary-light);
}

.references-table tbody tr:last-child td {
  border-bottom: none;
}

.table-ref-name {
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-link-icon {
  color: var(--primary);
  font-size: 0.8rem;
  opacity: 0.75;
  transition: opacity 0.2s, transform 0.2s;
  display: inline-flex;
}

.table-link-icon:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.table-ref-phone {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.table-ref-phone:hover {
  text-decoration: underline;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

/* ================= GRILLE DES PRESTATAIRES ================= */
.references-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.reference-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
}

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

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  text-transform: capitalize;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.card-details {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  flex: 1;
}

.detail-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.detail-icon {
  color: var(--primary);
  margin-top: 0.15rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.card-actions .btn {
  flex: 1;
}

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

/* ================= MODALES & FORMULAIRES ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.25rem;
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

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

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  color: var(--text-main);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

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

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ================= TOAST NOTIFICATION ================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.25s ease-out;
}

.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateY(1rem); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ================= EMPTY STATE ================= */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 3rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* ================= FOOTER ================= */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  margin-top: auto;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero-title { font-size: 1.75rem; }
  .references-grid { grid-template-columns: 1fr; }
  .admin-toolbar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .stats-badges { flex-direction: column; gap: 0.5rem; }
}
