/* ==========================================================
   public/css/components.css
   Composants réutilisables : boutons, formulaires, modales, etc.
   ========================================================== */

/* ===== Boutons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--r-md);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--sh-glow); }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--teal-700);
  color: white;
  border-color: var(--teal-700);
}
.btn-primary:hover { background: var(--teal-600); border-color: var(--teal-600); color: white; }
.btn-primary:active { transform: translateY(1px); }

.btn-accent {
  background: var(--rose-500);
  color: white;
  border-color: var(--rose-500);
}
.btn-accent:hover { background: var(--rose-600); border-color: var(--rose-600); color: white; }

.btn-outline {
  background: transparent;
  color: var(--teal-700);
  border-color: var(--teal-700);
}
.btn-outline:hover { background: var(--teal-700); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--c-text);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(13, 87, 97, 0.08); }

.btn-danger {
  background: var(--c-danger);
  color: white;
  border-color: var(--c-danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: white; }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--r-pill);
}

.btn-sm  { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.btn-lg  { padding: 0.75rem 1.5rem; font-size: 1rem; }

.btn .material-symbols-rounded { font-size: 1.15rem; line-height: 1; }
.btn-sm .material-symbols-rounded { font-size: 1rem; }

/* Floating Action Button (mobile) */
.fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 56px; height: 56px;
  border-radius: var(--r-pill);
  background: var(--rose-500);
  color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-lg);
  z-index: var(--z-nav);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.fab:hover { transform: scale(1.06); box-shadow: var(--sh-xl); color: white; }
.fab .material-symbols-rounded { font-size: 1.5rem; }

/* ===== Champs de formulaire ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: 0.01em;
}
.field label .req { color: var(--rose-500); }

.input,
input[type="text"], input[type="email"], input[type="tel"],
input[type="password"], input[type="date"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input:hover, input:hover, select:hover, textarea:hover {
  border-color: var(--c-border-strong);
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--teal-500);
  box-shadow: var(--sh-glow);
}

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

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
}

/* Choix radio "pill" */
.radio-pills {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.radio-pills label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-pill);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  background: white;
  transition: all var(--t-fast);
}
.radio-pills label input { position: absolute; opacity: 0; pointer-events: none; }
.radio-pills label:hover { border-color: var(--teal-500); background: var(--teal-50); }
.radio-pills label:has(input:checked) {
  background: var(--teal-700);
  border-color: var(--teal-700);
  color: white;
}
.radio-pills label.female:has(input:checked) {
  background: var(--rose-500);
  border-color: var(--rose-500);
}

/* Photo upload zone */
.photo-drop {
  width: 120px; height: 120px;
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-pill);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  margin: 0 auto var(--s-3);
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}
.photo-drop:hover {
  border-color: var(--teal-500);
  background: var(--teal-50);
}
.photo-drop.dragging {
  border-color: var(--rose-500);
  background: var(--rose-50);
  transform: scale(1.04);
}
.photo-drop.has-image {
  border-style: solid;
  border-color: var(--teal-500);
}
.photo-drop img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.photo-drop input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.photo-drop .icon-stack {
  display: flex; flex-direction: column; align-items: center;
  font-size: 0.75rem;
}
.photo-drop .icon-stack .material-symbols-rounded {
  font-size: 1.75rem; opacity: 0.6;
}

/* ===== Avatar ===== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  overflow: hidden;
  flex-shrink: 0;
  font-weight: 600;
  color: white;
  font-size: 0.85em;
  background: var(--c-text-muted);
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.male,   .avatar.gender-homme { background: var(--c-male); }
.avatar.female, .avatar.gender-femme { background: var(--c-female); }
.avatar.deceased::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.avatar-xs { width: 24px; height: 24px; font-size: 0.65rem; }
.avatar-sm { width: 36px; height: 36px; font-size: 0.8rem; }
.avatar-md { width: 48px; height: 48px; font-size: 0.95rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar-xl { width: 110px; height: 110px; font-size: 2.2rem; }
.avatar-2xl { width: 160px; height: 160px; font-size: 3rem; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--teal-100);
  color: var(--teal-800);
}
.badge.deceased { background: #efebe5; color: var(--c-text-muted); }
.badge.alive    { background: var(--c-success-bg); color: var(--c-success); }
.badge.male     { background: rgba(0, 139, 139, 0.15); color: var(--cyan-600); }
.badge.female   { background: rgba(220, 20, 60, 0.13); color: var(--rose-700); }
.badge .material-symbols-rounded { font-size: 0.95rem; }

/* ===== Cartes ===== */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  overflow: hidden;
}
.card-pad { padding: var(--s-4); }
.card-pad-lg { padding: var(--s-6); }
.card-translucent {
  background: var(--c-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ===== Modales / Drawers ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 25, 30, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-xl);
  margin: var(--s-4);
  transform: scale(0.96) translateY(8px);
  transition: transform var(--t-spring);
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 720px; }

/* Drawer (slide depuis la droite, pour les formulaires longs) */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 25, 30, 0.4);
  z-index: var(--z-drawer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--c-surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-xl);
  z-index: var(--z-drawer);
  transform: translateX(100%);
  transition: transform var(--t-slow);
}
.drawer.show { transform: translateX(0); }

.modal-header, .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--c-divider);
  background: var(--teal-700);
  color: white;
}
.modal-header h3, .drawer-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-header.light, .drawer-header.light {
  background: var(--c-surface);
  color: var(--c-text);
  border-bottom-color: var(--c-divider);
}

.modal-close, .drawer-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  color: inherit;
  transition: background var(--t-fast);
}
.modal-close:hover, .drawer-close:hover {
  background: rgba(255, 255, 255, 0.18);
}
.modal-header.light .modal-close:hover { background: rgba(0, 0, 0, 0.06); }

.modal-body, .drawer-body {
  padding: var(--s-5);
  overflow-y: auto;
  flex: 1;
}
.modal-body form, .drawer-body form {
  display: flex; flex-direction: column;
  gap: var(--s-4);
}

.modal-footer, .drawer-footer {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--c-divider);
  background: var(--c-surface-2);
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Bottom sheet sur mobile (au lieu du modal centré) */
@media (max-width: 600px) {
  .modal-backdrop { align-items: flex-end; }
  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 92vh;
    transform: translateY(100%);
  }
  .modal-backdrop.show .modal { transform: translateY(0); }

  .drawer {
    width: 100%;
    top: auto;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 92vh;
    transform: translateY(100%);
  }
  .drawer.show { transform: translateY(0); }
}

/* ===== Toasts ===== */
.toast-stack {
  position: fixed;
  top: calc(var(--navbar-h) + var(--s-3));
  right: var(--s-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 360px;
}
@media (max-width: 600px) {
  .toast-stack {
    top: auto;
    bottom: var(--s-4);
    right: var(--s-3);
    left: var(--s-3);
    max-width: none;
  }
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  border-left: 4px solid var(--teal-500);
  animation: slideUp var(--t-spring) ease;
}
.toast.success { border-left-color: var(--c-success); }
.toast.error   { border-left-color: var(--c-danger); }
.toast.warning { border-left-color: var(--c-warning); }
.toast .icon {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-pill);
  background: var(--teal-100);
  color: var(--teal-700);
}
.toast.success .icon { background: var(--c-success-bg); color: var(--c-success); }
.toast.error .icon   { background: var(--c-danger-bg);  color: var(--c-danger);  }
.toast.warning .icon { background: var(--c-warning-bg); color: var(--c-warning); }
.toast .toast-msg { flex: 1; font-size: 0.92rem; }
.toast .close {
  margin-left: auto;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--c-text-muted);
}
.toast .close:hover { background: var(--c-bg); }

/* ===== États vides / chargement ===== */
.empty {
  text-align: center;
  padding: var(--s-12) var(--s-4);
  color: var(--c-text-muted);
}
.empty .empty-icon {
  font-size: 3rem;
  opacity: 0.5;
  margin-bottom: var(--s-3);
}
.empty .empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: var(--s-2);
}

.skeleton {
  background: linear-gradient(90deg, #ecebe4, #f5f4ee, #ecebe4);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--c-border);
  border-top-color: var(--teal-500);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  display: inline-block;
}

/* ===== Liste / éléments ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
  cursor: pointer;
}
.list-item:hover { background: var(--c-bg); }
.list-item .info { flex: 1; min-width: 0; }
.list-item .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .meta {
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

/* ===== Détails (lignes clé/valeur) ===== */
.detail-row {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px dashed var(--c-divider);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label {
  font-weight: 600;
  color: var(--c-text-muted);
  min-width: 130px;
  font-size: 0.88rem;
}
.detail-row .value {
  color: var(--c-text);
  flex: 1;
}

/* ===== Search dropdown ===== */
.search-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-xl);
  max-height: 70vh;
  overflow-y: auto;
  display: none;
  z-index: 200;
  border: 1px solid var(--c-divider);
}
.search-popup.show { display: block; animation: slideUp 180ms ease; }
.search-result {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  cursor: pointer;
  transition: background var(--t-fast);
  border-bottom: 1px solid var(--c-divider);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.kbd-focus {
  background: var(--teal-50);
}
.search-result .info { flex: 1; min-width: 0; }
.search-result .name { font-weight: 600; }
.search-result .meta { font-size: 0.8rem; color: var(--c-text-muted); }
.search-empty {
  padding: var(--s-6);
  text-align: center;
  color: var(--c-text-muted);
  font-style: italic;
}
