/* ============================================================
   MASSAN Admin Velzon — tokens, typography, sidebar, compat
   Charte V4 : petrole #0D3A42, menthe #2EC99B, blanc casse #F4F2EE
   Polices locales : Bricolage Grotesque (titres), Outfit (corps)
   Charge en dernier dans admin_velzon.php.
   ============================================================ */

/* --- 0. Material Design Icons : seule police d'icônes Velzon requise
   (croix d'alerte, chevrons dropdown, tris, cases outline). woff2 seul. --- */
@font-face {
  font-family: "Material Design Icons";
  src: url("/theme/velzon/fonts/materialdesignicons-webfont.woff2?v=7.2.96") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

/* --- 1. Theme tokens (override Velzon defaults) ---
   Velzon pose ses variables sur [data-theme=default] et
   [data-theme=default][data-sidebar=dark] (spécificité 0,2,0) :
   html[data-theme][data-sidebar] (0,2,1) chargé en dernier l'emporte. */
html[data-theme][data-sidebar] {
  --vz-font-family-primary: 'Outfit', sans-serif;
  --vz-font-family-secondary: 'Bricolage Grotesque', sans-serif;
  --vz-headings-font-weight: 600;
  --vz-header-bg: #FFFFFF;
  --vz-footer-color: #52686B;

  /* Primary = petrole */
  --vz-primary: #0D3A42;
  --vz-primary-rgb: 13, 58, 66;
  --vz-primary-bg-subtle: #d0e0e3;
  --vz-primary-border-subtle: #a1c1c7;
  --vz-primary-text-emphasis: #07232a;

  /* Secondary = menthe douce */
  --vz-secondary: #2EC99B;
  --vz-secondary-rgb: 46, 201, 155;
  --vz-secondary-bg-subtle: #d5f5ea;
  --vz-secondary-border-subtle: #abebd5;

  /* États : teintes foncées AA (>= 4.5:1 sur blanc et sur leur fond subtle).
     Les teintes Velzon (#0ab39c, #f06548, #f7b84b, #299cdb) et la menthe
     #2EC99B échouent en texte. Menthe conservée en fond subtle positif. */
  --vz-success: #127A5C;
  --vz-success-rgb: 18, 122, 92;
  --vz-success-text-emphasis: #0E6149;
  --vz-success-bg-subtle: #D7F4EA;
  --vz-danger: #B42318;
  --vz-danger-rgb: 180, 35, 24;
  --vz-danger-text-emphasis: #912018;
  --vz-warning: #8A5A00;
  --vz-warning-rgb: 138, 90, 0;
  --vz-warning-text-emphasis: #6E4800;
  --vz-info: #0B5A7A;
  --vz-info-rgb: 11, 90, 122;
  --vz-info-text-emphasis: #08455E;

  /* Body */
  --vz-body-bg: #F4F2EE;
  --vz-body-color: #141414;
  --vz-heading-color: #0D3A42;

  /* Cards */
  --vz-card-bg: #FFFFFF;

  /* Footer */
  --vz-footer-bg: #F4F2EE;

  /* Typography */
  --vz-body-font-family: 'Outfit', sans-serif;
  --vz-body-font-weight: 400;

  /* Sidebar menu */
  --vz-vertical-menu-bg: #0D3A42;
  --vz-vertical-menu-border: #0D3A42;
  --vz-vertical-menu-item-color: rgba(255, 255, 255, 0.7);
  --vz-vertical-menu-item-hover-color: #FFFFFF;
  --vz-vertical-menu-item-active-color: #FFFFFF;
  --vz-vertical-menu-item-active-bg: rgba(46, 201, 155, 0.15);
  --vz-vertical-menu-title-color: rgba(255, 255, 255, 0.45);
  --vz-vertical-menu-item-font-size: 0.875rem;
  --vz-vertical-menu-item-font-family: 'Outfit', sans-serif;
  --vz-vertical-menu-sub-item-color: rgba(255, 255, 255, 0.55);
  --vz-vertical-menu-sub-item-hover-color: #FFFFFF;
  --vz-vertical-menu-sub-item-active-color: #FFFFFF;

  /* Topbar */
  --vz-topbar-search-bg: #F4F2EE;
}

/* --- 2. Typography --- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.page-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  color: var(--vz-heading-color);
}

body {
  font-family: 'Outfit', sans-serif;
}

/* --- 3. Sidebar logo area --- */
.navbar-brand-box {
  background: var(--vz-vertical-menu-bg);
}

.navbar-brand-box .logo-light {
  display: flex;
  align-items: center;
  height: 70px;
  padding: 0 16px;
}

.navbar-brand-box .logo-light img,
.navbar-brand-box .logo-dark img {
  height: 32px;
  width: auto;
}

/* Collapsed sidebar: show icon only */
[data-sidebar-size="sm"] .navbar-brand-box .logo-lg { display: none; }
[data-sidebar-size="sm"] .navbar-brand-box .logo-sm { display: inline-block; }
[data-sidebar-size="lg"] .navbar-brand-box .logo-sm { display: none; }

/* --- 4. Sidebar nav links — 44px touch targets --- */
.navbar-nav .nav-link,
.navbar-menu .menu-link,
#navbar-nav .nav-link,
#navbar-nav .menu-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Active item accent */
.navbar-menu .nav-link.active,
#navbar-nav .nav-link.active {
  background: var(--vz-vertical-menu-item-active-bg);
  color: var(--vz-vertical-menu-item-active-color);
  border-radius: 4px;
}

/* --- 5. Topbar buttons — 44px touch targets --- */
.topbar-head-dropdown .header-item,
.header-item {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Boutons de contenu : cible tactile 44 px (btn-sm/btn-icon Velzon = 30-38 px) */
.page-content .btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-content .btn-icon {
  min-width: 44px;
}

.massan-admin-logo-mobile {
  width: 120px; /* minimum charte */
  height: auto;
}

.massan-admin-avatar {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.massan-admin-note {
  max-width: 220px;
}

.massan-admin-chart {
  min-height: 260px;
}

.massan-admin-chart-wide,
.massan-admin-qr {
  width: 100%;
}

.massan-admin-square-48 {
  width: 48px;
  height: 48px;
}

.massan-admin-pre-wrap,
.massan-admin-code {
  white-space: pre-wrap;
}

.massan-admin-break-word,
.massan-admin-code {
  overflow-wrap: anywhere;
}

.massan-admin-code {
  font-size: 0.82rem;
}

.massan-admin-order-input {
  width: 5.5rem;
}

.massan-admin-border-top-dashed {
  border-top: 1px dashed var(--vz-border-color);
}

.massan-admin-qr {
  max-width: 240px;
  height: auto;
}

.massan-admin-monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.dark-layout {
  display: none;
}

[data-bs-theme="dark"] .light-layout {
  display: none;
}

[data-bs-theme="dark"] .dark-layout {
  display: inline-block;
}

/* --- 6. Focus visible ---
   Sélecteurs a/.btn/.form-* : battent les « outline: 0 » de Bootstrap et Velzon sur liens et champs.
   Pétrole sur fond clair (≈ 12:1), menthe opaque sur la barre latérale pétrole et en sombre (≈ 5:1).
   !important : seul moyen de battre « a,button{outline:0!important} » de velzon/app.min.css sans toucher au thème. */
*:focus-visible,
a:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
  outline: 3px solid #0D3A42 !important;
  outline-offset: 2px;
}
.navbar-menu :focus-visible,
[data-bs-theme="dark"] :focus-visible {
  outline-color: #2EC99B !important;
}
/* Lien d'évitement : visible au seul focus clavier, au-dessus de la barre du haut */
.massan-skip-link:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: 10px 16px;
  background: #FFFFFF;
  color: #0D3A42;
  border-radius: 6px;
  font-weight: 600;
}
/* Cible du lien d'évitement : focus programmatique, sans cadre autour de toute la page */
#contenu-principal:focus {
  outline: none !important;
}

/* --- 7. Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- 8. Responsive tables --- */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* --- 9. Soft-UI compat: remap accent to petrole/menthe --- */
.mssn-soft {
  --v: #0D3A42;
  --v-soft: rgba(13, 58, 66, 0.08);
  --ink: #141414;
  --line: #E2E8F0;
  --muted: #64748B;
  --bg: #FFFFFF;
}

/* Primary buttons => petrole */
.mssn-soft .soft-btn.btn-primary,
.mssn-soft .soft-btn-primary {
  background: #0D3A42;
  color: #FFFFFF;
  border-color: #0D3A42;
}
.mssn-soft .soft-btn.btn-primary:hover,
.mssn-soft .soft-btn-primary:hover {
  background: #0a2e35;
  border-color: #0a2e35;
}

/* Success/menthe buttons => dark text for contrast */
.mssn-soft .soft-btn.btn-success,
.mssn-soft .soft-btn-success {
  background: #2EC99B;
  color: #141414;
  border-color: #2EC99B;
}

/* Bouton menthe (secondary) : texte noir, blanc sur menthe = 2:1 */
.btn-secondary {
  --vz-btn-color: #141414;
  --vz-btn-hover-color: #141414;
  --vz-btn-active-color: #141414;
  --vz-btn-disabled-color: #141414;
}

/* Badge petrole */
.badge.bg-primary {
  background-color: #0D3A42 !important;
}

/* --- 10. Mobile overlay --- */
.vertical-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1002;
  display: none;
}
body.vertical-sidebar-enable .vertical-overlay {
  display: block;
}

/* --- 11. Dark theme tokens (prepared, not activated) ---
   Sélecteur aligné sur la section 1 pour rester prioritaire. */
html[data-theme][data-sidebar][data-bs-theme="dark"] {
  --vz-body-bg: #1a1d21;
  --vz-body-color: #E0E0E0;
  --vz-heading-color: #F4F2EE;
  --vz-card-bg: #242529;
  --vz-border-color: #32353a;
  --vz-footer-bg: #1a1d21;
}

[data-bs-theme="dark"] .mssn-soft {
  --bg: #242529;
  --ink: #E0E0E0;
  --line: #32353a;
  --muted: #9CA3AF;
  --v: #2EC99B;
  --v-soft: rgba(46, 201, 155, 0.12);
}

/* --- 12. KPI card counters (existing compat) --- */
.kpi-card {
  cursor: default;
}

/* --- 13. Page title breadcrumb area --- */
.page-title-box {
  /* Garder la gouttière Velzon : sans elle, la marge négative collait le titre au menu. */
  padding: 16px var(--vz-grid-gutter-width);
}

/* --- 14. Authentification admin (auth_velzon.php, lot 4c) --- */
.massan-auth-body {
  background: #F4F2EE;
}
.massan-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 32px 16px;
}
.massan-auth-logo {
  width: 180px; /* charte : horizontal >= 120 px, proportions conservées */
  height: auto;
}
.massan-auth-page .form-control,
.massan-auth-page .btn {
  min-height: 44px;
}
/* Bouton afficher/masquer : cible tactile 44 x 44 px */
.massan-auth-eye {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

/* --- 15. Vues de gestion (lot 3b : marchands, forfaits, catégories, attributs) --- */
.massan-admin-chart-240 {
  min-height: 240px;
}
.massan-admin-col-42 {
  width: 42%;
}
/* Cartes-filtres des marchands : état actif et focus visibles */
.massan-admin-kpi-filter {
  cursor: pointer;
}
.massan-admin-kpi-filter.active {
  box-shadow: 0 0 0 2px var(--vz-primary);
}
.massan-admin-kpi-filter:focus-visible {
  outline: 3px solid rgba(46, 201, 155, 0.5);
  outline-offset: 2px;
}

/* --- 16. Espace vendeur (marchand_velzon.php, lot 1 vendeur) --- */
.massan-vendeur-recherche {
  width: 100%;
  max-width: 360px;
}
.massan-vendeur-recherche .form-control,
.massan-vendeur-recherche .input-group-text {
  min-height: 44px;
}
/* Point d'état de l'agent WhatsApp (couleur portée par bg-success|warning|info|danger|secondary) */
.massan-vendeur-point {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Place réservée aux graphiques ApexCharts : pas de saut de mise en page au chargement */
.massan-vendeur-graphique {
  min-height: 280px;
}
/* Cartes entières cliquables : survol et focus visibles */
.massan-vendeur-carte-lien {
  transition: box-shadow .15s ease, transform .15s ease;
}
.massan-vendeur-carte-lien:hover {
  box-shadow: 0 4px 14px rgba(13, 58, 66, 0.12);
  transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
  .massan-vendeur-carte-lien:hover { transform: none; }
}
.massan-vendeur-menu-commandes {
  min-width: 240px;
}
/* Tableaux défilants (admin et vendeur) : un .visually-hidden (position absolue) dans un en-tête
   échappait à la zone de défilement et élargissait toute la page sur mobile. */
.table-responsive {
  position: relative;
}
/* Calendrier des livraisons (PR #5/#6) : bande de jours en onglets */
.massan-vendeur-ancre {
  scroll-margin-top: 90px;
}
.massan-vendeur-cal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}
.massan-vendeur-cal-jour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 8px 4px;
  border: 1px solid var(--vz-border-color);
  border-radius: 10px;
  background: #FFFFFF;
  color: var(--vz-body-color);
  font-size: 12px;
}
.massan-vendeur-cal-jour:hover {
  background: var(--vz-light);
}
.massan-vendeur-cal-jour.active {
  border-color: var(--vz-primary);
  background: rgba(13, 58, 66, 0.06);
}
.massan-vendeur-cal-jour.retard {
  border-color: #F5B5B7;
}
.massan-vendeur-cal-dow {
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  color: var(--vz-secondary-color);
}
.massan-vendeur-cal-num {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}
.massan-vendeur-cal-ligne:last-child,
.massan-vendeur-insight:last-child {
  border-bottom: 0 !important;
}
.massan-vendeur-cal-ligne:hover .fw-semibold {
  color: var(--vz-primary);
}
.massan-vendeur-min0 {
  min-width: 0;
}
.massan-vendeur-notifs {
  max-height: 360px;
  overflow-y: auto;
}
/* Lot 2 vendeur : produits et commandes */
.massan-vendeur-produit-couverture {
  max-height: 220px;
}
.massan-vendeur-produit-vignette {
  height: 80px;
}
.massan-vendeur-lightbox-img {
  max-height: 85vh;
}
.massan-vendeur-image-actuelle {
  max-height: 120px;
}
.massan-vendeur-galerie-actuelle {
  height: 60px;
  width: auto;
}
.massan-vendeur-graphique-260 {
  min-height: 260px;
}
/* Zone de dépôt d'images : <label> cliquable, champ fichier masqué mais focusable */
.massan-vendeur-depot {
  display: block;
  min-height: 100px;
  padding: 24px 16px;
  border: 2px dashed var(--vz-border-color);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.massan-vendeur-depot:hover,
.massan-vendeur-depot.dragover {
  border-color: var(--vz-primary);
  background: rgba(13, 58, 66, 0.04);
}
.massan-vendeur-depot:focus-within {
  outline: 3px solid #0D3A42;
  outline-offset: 2px;
}
.massan-vendeur-depot-apercus {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.massan-vendeur-depot-vignette {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 88px;
}
.massan-vendeur-depot-vignette img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--vz-border-color);
}
.massan-vendeur-depot-nom {
  display: block;
  max-width: 80px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--vz-secondary-color);
}
.massan-vendeur-filtre-actif {
  border-width: 2px !important;
  border-style: solid !important;
}
.massan-vendeur-ligne-nouvelle > td {
  background: rgba(245, 165, 36, 0.06);
}
/* Select2 (feuille Vuexy, variables --bs-* absentes sous Velzon) : aligné sur les champs Velzon, admin et vendeur */
.select2-container--default .select2-selection--single {
  height: 44px;
  border: 1px solid var(--vz-border-color);
  border-radius: var(--vz-border-radius);
  background-color: var(--vz-secondary-bg, #FFFFFF);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 42px;
  color: var(--vz-body-color);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px;
  top: 1px;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  outline: 3px solid #0D3A42;
  outline-offset: 2px;
}

/* --- 17. Authentification vendeur (auth_vendeur_velzon.php, modèles auth-signin/signup-basic) --- */
/* Voile du bandeau aux couleurs MASSAN (le modèle dépend de --vz-primary-text-emphasis) */
.massan-auth-vendeur-bandeau .bg-overlay {
  background: linear-gradient(to right, #08282E, #0D3A42);
  opacity: .92;
}
/* Accroche sous le logo : blanc atténué, contraste ≥ 7:1 sur le voile pétrole */
.massan-auth-vendeur-accroche {
  color: rgba(255, 255, 255, 0.85);
}
.auth-page-content .form-control,
.auth-page-content .btn {
  min-height: 44px;
}
/* Critères du mot de passe : toujours visibles (le modèle les masque jusqu'au focus) */
#password-contain {
  display: block;
}
/* Lot 3 vendeur : paramètres */
.massan-vendeur-logo-apercu {
  max-width: 160px;
  max-height: 100px;
  object-fit: contain;
}
.massan-vendeur-couleur {
  width: 48px;
  min-height: 44px;
  padding: 2px;
  border-radius: 8px;
  cursor: pointer;
}
.massan-vendeur-num-apercu {
  display: block;
  padding: 10px 14px;
  border: 1px dashed var(--vz-border-color);
  border-radius: 8px;
  background: var(--vz-light);
  font-family: var(--vz-font-monospace, monospace);
  font-weight: 600;
  color: var(--vz-primary);
}

/* --- 18. Lot 4 vendeur : WhatsApp et démarrage --- */
.massan-vendeur-qr {
  max-width: 260px;
}
.massan-vendeur-code {
  letter-spacing: 3px;
  font-family: var(--vz-font-monospace, monospace);
}
/* Étapes : libellés lisibles à 375 px (4 étapes sur une ligne) */
@media (max-width: 575.98px) {
  .massan-vendeur-etapes .nav-link { padding: .75rem .25rem !important; font-size: 12px; }
}
.page-content .btn.massan-vendeur-ton {
  display: block;
  text-align: left;
  white-space: normal;
}
/* Aperçu de conversation (repris de massan-onboarding.css, sans ses règles Select2 globales) */
.massan-vendeur-tel {
  background: var(--vz-secondary-bg, #FFFFFF);
  border: 1px solid var(--vz-border-color);
  border-radius: 20px;
  overflow: hidden;
  position: sticky;
  top: 90px;
}
.massan-vendeur-tel-barre {
  background: #075E54;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.massan-vendeur-tel-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #FFFFFF;
  overflow: hidden;
  flex-shrink: 0;
}
.massan-vendeur-tel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.massan-vendeur-tel-nom {
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}
.massan-vendeur-tel-statut {
  color: rgba(255, 255, 255, .85);
  font-size: 11px;
  margin: 0;
}
.massan-vendeur-tel-corps {
  background: #E5DDD5;
  padding: 16px 14px;
  min-height: 340px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.massan-vendeur-tel-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #111B21;
  animation: massanTelMsg .3s ease both;
}
.massan-vendeur-tel-msg-recu {
  align-self: flex-start;
  background: #FFFFFF;
  border-top-left-radius: 2px;
}
.massan-vendeur-tel-msg-envoye {
  align-self: flex-end;
  background: #D9FDD3;
  border-top-right-radius: 2px;
}
.massan-vendeur-tel-heure {
  display: block;
  text-align: right;
  font-size: 10px;
  color: rgba(0, 0, 0, .55);
  margin-top: 2px;
}
.massan-vendeur-tel-saisie {
  align-self: flex-start;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 10px 14px;
  display: inline-flex;
  gap: 4px;
}
.massan-vendeur-tel-saisie span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9AA5AC;
  animation: massanTelSaisie 1.2s infinite;
}
.massan-vendeur-tel-saisie span:nth-child(2) { animation-delay: .2s; }
.massan-vendeur-tel-saisie span:nth-child(3) { animation-delay: .4s; }
.massan-vendeur-tel-note {
  text-align: center;
  font-size: 12px;
  color: var(--vz-secondary-color);
  padding: 8px;
  border-top: 1px solid var(--vz-border-color);
}
@keyframes massanTelMsg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes massanTelSaisie { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
  .massan-vendeur-tel-msg, .massan-vendeur-tel-saisie span { animation: none; }
}
@media (max-width: 991.98px) {
  .massan-vendeur-tel { position: static; }
}
