/* 
DASSI TENE Roméo-Ledoux
*/


/* Basic */









/* ------------------------------------------------------------------
   tom-select : alignement sur les champs de l'application (clair / sombre)
   ------------------------------------------------------------------ */
.ts-wrapper .ts-control, .ts-wrapper .ts-control input { background-color: rgb(var(--ml-surface)); color: rgb(var(--ml-texte)); }
.ts-wrapper .ts-control { border-radius: 0.5rem; border-color: rgb(var(--ml-bord)); min-height: 2.25rem; }
.ts-wrapper .ts-control input::placeholder { color: rgb(var(--ml-texte-pale)); }
.ts-wrapper.focus .ts-control { border-color: rgb(var(--ml-primary-500)); box-shadow: 0 0 0 3px var(--ml-anneau); }
.ts-dropdown { border-radius: 0.5rem; overflow: hidden; z-index: 60; background-color: rgb(var(--ml-surface));
  color: rgb(var(--ml-texte)); border-color: rgb(var(--ml-bord)); }
.ts-dropdown .active { background-color: rgb(var(--ml-primary-50)); color: rgb(var(--ml-primary-900)); }
.dark .ts-dropdown { background-color: rgb(var(--ml-surface-2)); }
.dark .ts-dropdown .active { background-color: rgb(var(--ml-primary-500) / 0.15); color: rgb(var(--ml-primary-100)); }
.dark .ts-wrapper.multi .ts-control > div { background-color: rgb(var(--ml-surface-3)); color: rgb(var(--ml-texte)); }

/* Sélecteurs de la saisie d'ordonnance (<select class="ts-saisie">) : plus hauts, loupe, options sur deux lignes */
.ts-wrapper.ts-saisie .ts-control { min-height: 2.75rem; border-radius: 0.75rem; padding: 0.55rem 0.85rem 0.55rem 2.4rem;
  background: rgb(var(--ml-surface-2)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' d='m21 21-4.3-4.3M17 10.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0Z'/%3E%3C/svg%3E") no-repeat 0.8rem center / 1.05rem;
  transition: border-color .15s, box-shadow .15s, background-color .15s; }
.ts-wrapper.ts-saisie:hover .ts-control { border-color: rgb(var(--ml-texte-pale)); }
/* Avant l'initialisation de tom-select (zone de saisie remplacée par HTMX) : même apparence que le contrôle final,
   pour que la zone ne « saute » pas */
select.ts-saisie:not(.tomselected) { appearance: none; -webkit-appearance: none; display: block; width: 100%; min-height: 2.75rem;
  border: 1px solid rgb(var(--ml-bord)); border-radius: 0.75rem; padding: 0.55rem 0.85rem 0.55rem 2.4rem; color: transparent;
  background: rgb(var(--ml-surface-2)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' d='m21 21-4.3-4.3M17 10.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0Z'/%3E%3C/svg%3E") no-repeat 0.8rem center / 1.05rem; }
.dark select.ts-saisie:not(.tomselected) { background-color: rgb(var(--ml-surface) / 0.6); }
.ts-wrapper.ts-saisie.focus .ts-control { background-color: rgb(var(--ml-surface)); }
.dark .ts-wrapper.ts-saisie .ts-control { background-color: rgb(var(--ml-surface) / 0.6); }
.dark .ts-wrapper.ts-saisie.focus .ts-control { background-color: rgb(var(--ml-surface)); }
.ts-wrapper.ts-saisie.single .ts-control::after { display: none; }
.ts-dropdown.ts-saisie { border-radius: 0.75rem; margin-top: 0.35rem; box-shadow: var(--ml-ombre-menu); }
.ts-dropdown.ts-saisie .option { padding: 0.5rem 0.85rem; border-radius: 0.5rem; margin: 0.15rem 0.3rem; }
.ts-option-titre { display: block; font-weight: 500; line-height: 1.25rem; }
.ts-option-detail { display: block; font-size: 0.75rem; line-height: 1rem; color: rgb(var(--ml-texte-doux)); }
.ts-dropdown .active .ts-option-detail { color: inherit; opacity: .8; }

/* Options enrichies (data-rendu de static/js/ui/behaviors.js) : comptes (avatar) et prestations (code, prix) */
.ts-dropdown .ts-dropdown-content { max-height: 22rem; }
.ts-riche { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.ts-riche-corps { min-width: 0; flex: 1 1 auto; }
.ts-riche-corps > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-option-meta { display: block; font-size: 0.7rem; line-height: 1rem; color: rgb(var(--ml-texte-pale)); }
.ts-avatar { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem;
  border-radius: 9999px; font-size: 0.75rem; font-weight: 700; letter-spacing: .02em; object-fit: cover;
  color: rgb(var(--ml-primary-800)); background-color: rgb(var(--ml-primary-100)); }
.ts-avatar-sm { width: 1.5rem; height: 1.5rem; font-size: 0.6rem; }
.ts-avatar-lg { width: 2.75rem; height: 2.75rem; font-size: 0.85rem; }
.ts-avatar[data-teinte="1"] { color: #075985; background-color: #e0f2fe; }
.ts-avatar[data-teinte="2"] { color: #6b21a8; background-color: #f3e8ff; }
.ts-avatar[data-teinte="3"] { color: #92400e; background-color: #fef3c7; }
.ts-avatar[data-teinte="4"] { color: #9f1239; background-color: #ffe4e6; }
.ts-avatar[data-teinte="5"] { color: #3730a3; background-color: #e0e7ff; }
.dark .ts-avatar { color: rgb(var(--ml-primary-200)); background-color: rgb(var(--ml-primary-500) / 0.18); }
.dark .ts-avatar[data-teinte="1"] { color: #bae6fd; background-color: rgb(14 165 233 / 0.18); }
.dark .ts-avatar[data-teinte="2"] { color: #e9d5ff; background-color: rgb(168 85 247 / 0.18); }
.dark .ts-avatar[data-teinte="3"] { color: #fde68a; background-color: rgb(245 158 11 / 0.18); }
.dark .ts-avatar[data-teinte="4"] { color: #fecdd3; background-color: rgb(244 63 94 / 0.18); }
.dark .ts-avatar[data-teinte="5"] { color: #c7d2fe; background-color: rgb(99 102 241 / 0.18); }
.ts-item-riche { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.ts-code { flex-shrink: 0; min-width: 3.25rem; max-width: 6rem; overflow: hidden; text-overflow: ellipsis; padding: 0.15rem 0.4rem;
  border-radius: 0.375rem; text-align: center; font-family: var(--ml-police-mono); font-size: 0.7rem;
  font-weight: 600; color: rgb(var(--ml-primary-700)); background-color: rgb(var(--ml-primary-50)); }
.dark .ts-code { color: rgb(var(--ml-primary-300)); background-color: rgb(var(--ml-primary-500) / 0.12); }
.ts-prix { flex-shrink: 0; margin-left: auto; padding-left: 0.5rem; font-size: 0.8rem; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap; color: rgb(var(--ml-texte)); }
.ts-badge { display: inline-block; margin-left: 0.4rem; padding: 0 0.4rem; border-radius: 9999px; font-size: 0.625rem;
  font-weight: 600; line-height: 1rem; vertical-align: middle; }
.ts-badge-frequent { color: rgb(var(--ml-primary-700)); background-color: rgb(var(--ml-primary-100)); }
.ts-badge-alerte { color: #92400e; background-color: #fef3c7; }
.dark .ts-badge-frequent { color: rgb(var(--ml-primary-300)); background-color: rgb(var(--ml-primary-500) / 0.15); }
.dark .ts-badge-alerte { color: #fcd34d; background-color: rgb(245 158 11 / 0.15); }
.ts-dropdown .active .ts-code, .ts-dropdown .active .ts-prix { color: inherit; }
.ts-vide { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0.75rem 0.85rem !important;
  font-size: 0.8rem; color: rgb(var(--ml-texte-doux)); }
.ts-vide-action { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.25rem; padding: 0.35rem 0.75rem;
  border-radius: 0.5rem; font-weight: 600; color: rgb(var(--ml-primary-700)); background-color: rgb(var(--ml-primary-50));
  transition: background-color .15s; }
.ts-vide-action:hover, .ts-vide-action:focus-visible { background-color: rgb(var(--ml-primary-100)); outline: none; }
.dark .ts-vide-action { color: rgb(var(--ml-primary-300)); background-color: rgb(var(--ml-primary-500) / 0.12); }
.dark .ts-vide-action:hover, .dark .ts-vide-action:focus-visible { background-color: rgb(var(--ml-primary-500) / 0.22); }
@media (pointer: coarse) {
  .ts-dropdown.ts-saisie .option { min-height: 2.75rem; display: flex; align-items: center; }
  .ts-dropdown.ts-saisie .option > * { flex: 1 1 auto; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .ts-wrapper.ts-saisie .ts-control, .ts-vide-action { transition: none; } }

/* Cases à cocher et boutons radio natifs : couleur de la marque */
input[type="checkbox"], input[type="radio"] { accent-color: rgb(var(--ml-primary-600)); }

/* ===== Notifications (templates/includes/messages.html) =====
   Les tags de messages gardent leur nom historique (MESSAGE_TAGS : alert-success, alert-error…) ;
   leurs couleurs ne s'appliquent qu'aux toasts. */
.ml-toast { pointer-events: auto; display: flex; align-items: center; width: auto; max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.5rem 0.5rem 0.5rem 0.75rem; border-radius: 0.875rem; color: #fff; background-color: rgb(55 65 81);
  box-shadow: 0 10px 25px -10px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(255 255 255 / 0.06) inset; }
.ml-toast.alert-success { background-color: rgb(var(--ml-primary-600)); }
.ml-toast.alert-error { background-color: #e11d48; }    /* danger-600 */
.ml-toast.alert-warning { background-color: #fbbf24; color: #111827; } /* warning-400 */
.ml-toast.alert-warning [data-toast-close] svg { color: #111827; }
.ml-toast.alert-info { background-color: #0284c7; }     /* info-600 */

/* ===== Modales <c-modal> : animations d'ouverture et de fermeture (static/js/ui/modal.js) ===== */
.ml-modal .ml-modal-fond { opacity: 0; transition: opacity .2s ease-out; }
.ml-modal .ml-modal-carte {
  opacity: 0; transform: translateY(100%);
  transition: transform .25s cubic-bezier(.22, 1, .36, 1), opacity .2s ease-out;
}
@media (min-width: 640px) {
  .ml-modal .ml-modal-carte { transform: translateY(.75rem) scale(.97); }
}
.ml-modal[data-etat="ouvert"] .ml-modal-fond { opacity: 1; }
.ml-modal[data-etat="ouvert"] .ml-modal-carte { opacity: 1; transform: none; }
.ml-modal[data-etat="ferme"] .ml-modal-carte { transition-duration: .16s; }
@media (prefers-reduced-motion: reduce) {
  .ml-modal .ml-modal-fond, .ml-modal .ml-modal-carte { transition: none; }
}
/* Formulaire en cours d'envoi dans une modale */
.ml-modal form[aria-busy="true"] { cursor: progress; }

/* ===== SweetAlert2 en thème sombre (classes posées par static/js/ui/confirm.js) ===== */
html.dark .swal2-popup { background: rgb(var(--ml-surface-2)); color: rgb(var(--ml-texte)); border: 1px solid rgb(var(--ml-surface)); }
html.dark .swal2-title, html.dark .swal2-html-container { color: rgb(var(--ml-texte)); }
html.dark .swal2-input, html.dark .swal2-textarea, html.dark .swal2-select {
  background: rgb(var(--ml-surface)); color: rgb(var(--ml-texte)); border-color: rgb(var(--ml-bord));
}
html.dark .swal2-timer-progress-bar { background: rgba(255, 255, 255, .3); }
.swal2-popup { border-radius: 1rem; }
.swal2-actions .swal2-styled { border-radius: .625rem; font-weight: 600; }

/* Chargement des listes à recherche distante (behaviors.js, render.loading) : squelettes quand la liste est vide,
   fine barre de progression au-dessus des résultats déjà affichés (plus de cercle qui tourne) */
.ts-chargement { padding: 0.25rem 0.3rem; }
.ts-squelette { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.55rem; }
.ts-squelette + .ts-squelette { opacity: .75; }
.ts-squelette + .ts-squelette + .ts-squelette { opacity: .5; }
.ts-sq-corps { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.ts-sq-barre, .ts-sq-avatar, .ts-sq-code, .ts-sq-prix { display: block; border-radius: 9999px; background-color: rgb(var(--ml-bord-doux));
  animation: ts-pulsation 1.4s ease-in-out infinite; }
.ts-sq-barre { height: 0.6rem; width: 70%; }
.ts-sq-barre.court { width: 40%; height: 0.5rem; }
.ts-sq-avatar { flex-shrink: 0; width: 2.25rem; height: 2.25rem; }
.ts-sq-code { flex-shrink: 0; width: 3.25rem; height: 1.25rem; border-radius: 0.375rem; }
.ts-sq-prix { flex-shrink: 0; width: 3.5rem; height: 0.7rem; }
@keyframes ts-pulsation { 50% { opacity: .45; } }
.ts-progression { position: sticky; top: 0; z-index: 1; height: 2px; overflow: hidden; background-color: rgb(var(--ml-primary-500) / 0.15); }
.ts-progression::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 35%; border-radius: 9999px;
  background-color: rgb(var(--ml-primary-500)); animation: ts-defilement 1s ease-in-out infinite; }
@keyframes ts-defilement { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) {
  .ts-sq-barre, .ts-sq-avatar, .ts-sq-code, .ts-sq-prix, .ts-progression::before { animation: none; }
  .ts-progression::before { width: 100%; opacity: .6; }
}
