/* public/css/liquidglass.css
   ─────────────────────────────────────────────────────────────────────────────
   Sign'Allo — Design System LiquidGlass
   Partagé par toutes les interfaces : centrale, client, partenaire
   ─────────────────────────────────────────────────────────────────────────────*/

/* ── LiquidGlass tokens ───────────────────────────────────────────────────── */
:root {
  --lg-blur:        blur(20px) saturate(180%);
  --lg-blur-sm:     blur(10px) saturate(150%);
  --lg-bg:          rgba(255,255,255,.07);
  --lg-bg-deep:     rgba(10,10,30,.75);
  --lg-border:      rgba(255,255,255,.18);
  --lg-border-sm:   rgba(255,255,255,.10);
  --lg-shine:       inset 0 1px 0 rgba(255,255,255,.14);
  --lg-shadow:      0 8px 32px rgba(0,0,0,.35), var(--lg-shine);
  --lg-shadow-sm:   0 4px 16px rgba(0,0,0,.25), var(--lg-shine);
  --lg-radius:      1rem;
  --lg-radius-sm:   .65rem;
  --lg-action-h:    60px;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

/* ── LiquidGlass card ─────────────────────────────────────────────────────── */
.lg-card {
  backdrop-filter: var(--lg-blur);
  -webkit-backdrop-filter: var(--lg-blur);
  background: var(--lg-bg);
  border: 1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  box-shadow: var(--lg-shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.lg-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,.45), var(--lg-shine);
}
.lg-card-sm {
  backdrop-filter: var(--lg-blur-sm);
  -webkit-backdrop-filter: var(--lg-blur-sm);
  background: var(--lg-bg);
  border: 1px solid var(--lg-border-sm);
  border-radius: var(--lg-radius-sm);
  box-shadow: var(--lg-shadow-sm);
}

/* ── Nav card grid ────────────────────────────────────────────────────────── */
.lg-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .85rem;
  padding: 1rem;
}
@media (max-width: 480px) {
  .lg-nav-grid { grid-template-columns: repeat(2, 1fr); gap: .65rem; padding: .75rem; }
}
@media (min-width: 900px) {
  .lg-nav-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
}

.lg-nav-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: 1.25rem .75rem 1rem;
  min-height: 110px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  border: none;
  font-family: inherit;
  backdrop-filter: var(--lg-blur);
  -webkit-backdrop-filter: var(--lg-blur);
  background: var(--lg-bg);
  border-radius: var(--lg-radius);
  box-shadow: var(--lg-shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  outline: 1px solid var(--lg-border-sm);
  outline-offset: 0;
  color: var(--text-secondary, #e2e8f0);
  overflow: hidden;
}
.lg-nav-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.08) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.lg-nav-card:hover  { transform: translateY(-3px) scale(1.02); box-shadow: 0 12px 32px rgba(0,0,0,.4), var(--lg-shine); background: rgba(255,255,255,.11); }
.lg-nav-card:active { transform: translateY(0) scale(.98); }

.lg-nav-icon  { font-size: 2rem; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.lg-nav-label { font-size: .8rem; font-weight: 600; line-height: 1.25; color: var(--text-secondary, #e2e8f0); }
.lg-nav-badge {
  position: absolute;
  top: .5rem; right: .5rem;
  background: #ef4444;
  color: #fff;
  font-size: .58rem; font-weight: 800;
  padding: 2px 6px; border-radius: 9999px;
  line-height: 1.3;
}
/* Couleurs thématiques par module */
.lg-nav-card[data-color="indigo"]  { outline-color: rgba(99,102,241,.4); }
.lg-nav-card[data-color="emerald"] { outline-color: rgba(52,211,153,.35); }
.lg-nav-card[data-color="amber"]   { outline-color: rgba(245,158,11,.35); }
.lg-nav-card[data-color="sky"]     { outline-color: rgba(14,165,233,.35); }
.lg-nav-card[data-color="rose"]    { outline-color: rgba(244,63,94,.35); }
.lg-nav-card[data-color="violet"]  { outline-color: rgba(167,139,250,.4); }
.lg-nav-card[data-color="teal"]    { outline-color: rgba(20,184,166,.35); }
.lg-nav-card[data-color="fuchsia"] { outline-color: rgba(232,121,249,.35); }

/* ── KPI row ──────────────────────────────────────────────────────────────── */
.lg-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: .5rem;
  padding: .75rem 1rem 0;
  flex-shrink: 0;
}
@media (max-width: 480px) { .lg-kpi-row { grid-template-columns: repeat(2, 1fr); } }

.lg-kpi {
  backdrop-filter: var(--lg-blur-sm);
  -webkit-backdrop-filter: var(--lg-blur-sm);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--lg-border-sm);
  border-radius: .65rem;
  padding: .7rem .65rem .6rem;
  text-align: center;
  box-shadow: var(--lg-shadow-sm);
}
.lg-kpi-val   { font-size: 1.35rem; font-weight: 800; line-height: 1; }
.lg-kpi-label { font-size: .68rem; color: var(--text-faint, #64748b); margin-top: .2rem; }

/* ── Bottom action bar ────────────────────────────────────────────────────── */
.lg-action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--lg-action-h) + var(--safe-bottom));
  padding: .5rem 1rem var(--safe-bottom);
  backdrop-filter: var(--lg-blur);
  -webkit-backdrop-filter: var(--lg-blur);
  background: rgba(6,6,20,.82);
  border-top: 1px solid var(--lg-border-sm);
  box-shadow: 0 -4px 24px rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  z-index: 900;
}
/* Décaler le contenu scrollable pour ne pas se cacher sous la barre */
.lg-has-action-bar { padding-bottom: calc(var(--lg-action-h) + var(--safe-bottom) + .5rem) !important; }

/* ── Module header (back + title) ─────────────────────────────────────────── */
.lg-mod-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem .6rem;
  flex-shrink: 0;
}
.lg-back-btn {
  background: var(--lg-bg);
  border: 1px solid var(--lg-border-sm);
  border-radius: .55rem;
  color: var(--text-muted, #94a3b8);
  padding: .4rem .7rem;
  font-family: inherit;
  font-size: .85rem;
  cursor: pointer;
  backdrop-filter: var(--lg-blur-sm);
  -webkit-backdrop-filter: var(--lg-blur-sm);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.lg-back-btn:hover { background: rgba(255,255,255,.12); color: var(--text-secondary, #e2e8f0); }
.lg-mod-title { font-size: 1rem; font-weight: 700; color: var(--text-primary, #f8fafc); }

/* ── Messaging responsive layout ─────────────────────────────────────────── */
.lg-msg-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 130px);
  min-height: 400px;
  gap: 0;
}
@media (max-width: 700px) {
  .lg-msg-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .lg-msg-list    { display: none; }
  .lg-msg-list.active { display: flex; flex-direction: column; }
  .lg-msg-content { display: none; }
  .lg-msg-content.active { display: flex; flex-direction: column; }
}
.lg-msg-list {
  border-right: 1px solid var(--lg-border-sm);
  overflow-y: auto;
  background: rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
}
.lg-msg-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── WebRTC overlay responsive ────────────────────────────────────────────── */
#wrtc-overlay { font-family: inherit; }
#wrtc-grid {
  flex: 1;
  display: grid;
  gap: .5rem;
  padding: .65rem;
  align-content: start;
  overflow-y: auto;
}
@media (max-width: 600px) {
  #wrtc-grid { grid-template-columns: 1fr !important; }
  #wrtc-local { width: 100px !important; height: 75px !important; bottom: calc(.5rem + 60px) !important; }
  #wrtc-overlay > div:first-child { flex-wrap: wrap; gap: .35rem; padding: .5rem .75rem; }
  #wrtc-overlay > div:first-child button { font-size: .78rem; padding: .3rem .5rem; }
}
@media (min-width: 601px) and (max-width: 900px) {
  #wrtc-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 901px) {
  #wrtc-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ── Utility classes ──────────────────────────────────────────────────────── */
.lg-btn {
  backdrop-filter: var(--lg-blur-sm);
  -webkit-backdrop-filter: var(--lg-blur-sm);
  background: rgba(255,255,255,.08);
  border: 1px solid var(--lg-border-sm);
  border-radius: .55rem;
  color: var(--text-secondary, #e2e8f0);
  padding: .5rem 1rem;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.lg-btn:hover  { background: rgba(255,255,255,.13); }
.lg-btn:active { transform: scale(.97); }
.lg-btn-primary {
  background: linear-gradient(135deg, var(--primary,#6366f1), var(--primary-dark,#4f46e5));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,.4);
}
.lg-btn-danger  {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: transparent; color: #fff;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 9999px; }

/* ── Touch targets (mobile) ───────────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .lg-nav-card   { min-height: 100px; }
  .lg-back-btn,
  .lg-btn        { min-height: 44px; }
  .lg-action-bar button { min-height: 44px; min-width: 44px; }
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes lgFadeIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes lgSlideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.lg-fade-in  { animation: lgFadeIn  .22s ease forwards; }
.lg-slide-in { animation: lgSlideIn .22s ease forwards; }

/* ── Responsive breakpoints complets ─────────────────────────────────────── */
/* Phone < 600px : 2 colonnes, nav bottom, sidebar cachée */
/* Tablet 600–1023px : 3 colonnes, nav bottom optionnel, sidebar cachée */
/* Desktop ≥ 1024px : grille libre, sidebar fixe, bar bottom si actions */

/* --- Phone --- */
@media (max-width: 599px) {
  .lg-nav-grid    { grid-template-columns: repeat(2, 1fr); gap: .55rem; padding: .6rem; }
  .lg-nav-card    { min-height: 90px; padding: 1rem .5rem .85rem; }
  .lg-nav-icon    { font-size: 1.75rem; }
  .lg-nav-label   { font-size: .72rem; }
  .lg-kpi-row     { grid-template-columns: repeat(2, 1fr); gap: .4rem; padding: .6rem; }
  .lg-kpi-val     { font-size: 1.1rem; }
  .lg-kpi-label   { font-size: .62rem; }
  #ns-bottom-bar  { padding: .5rem .65rem calc(.5rem + env(safe-area-inset-bottom,0px)); gap: .35rem; }
  #ns-bottom-bar button { font-size: .78rem; padding: .4rem .65rem; }
}

/* --- Tablet --- */
@media (min-width: 600px) and (max-width: 1023px) {
  .lg-nav-grid  { grid-template-columns: repeat(3, 1fr); gap: .75rem; padding: .85rem; }
  .lg-nav-card  { min-height: 100px; }
  .lg-kpi-row   { grid-template-columns: repeat(4, 1fr); }
}

/* --- Desktop ≥ 1024px --- */
@media (min-width: 1024px) {
  .lg-nav-grid  { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; padding: 1rem; }
  .lg-nav-card  { min-height: 115px; }
  .lg-kpi-row   { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  /* Bottom bar plus discrète sur desktop (actions uniquement si présentes) */
  #ns-bottom-bar { font-size: .88rem; padding: .5rem 1.5rem calc(.5rem + env(safe-area-inset-bottom,0px)); }
}

/* ── Module content wrapper ───────────────────────────────────────────────── */
.ns-module-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: lgFadeIn .2s ease forwards;
}
.ns-module-body {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1rem;
  /* Laisser de la place pour la barre du bas */
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
}

/* ── Tables responsive ────────────────────────────────────────────────────── */
@media (max-width: 599px) {
  /* Transformer les tables en blocs sur mobile */
  .c-table, .p-table {
    display: block;
    width: 100%;
  }
  .c-table thead, .p-table thead { display: none; }
  .c-table tbody, .c-table tr,
  .p-table tbody, .p-table tr {
    display: block;
    width: 100%;
  }
  .c-table td, .p-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .45rem .65rem;
    border-bottom: 1px solid var(--border2, rgba(255,255,255,.05));
    font-size: .82rem;
  }
  .c-table td::before, .p-table td::before {
    content: attr(data-label);
    font-size: .7rem;
    color: var(--text-faint, #64748b);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: .5rem;
    flex-shrink: 0;
  }
  .c-table tr, .p-table tr {
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border2, rgba(255,255,255,.05));
    border-radius: .65rem;
    margin-bottom: .5rem;
    overflow: hidden;
  }
}

/* ── Messaging layout responsive ─────────────────────────────────────────── */
.ns-msg-split {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 120px);
  min-height: 0;
  gap: 0;
}
@media (max-width: 1023px) {
  .ns-msg-split {
    grid-template-columns: 1fr;
    height: calc(100dvh - 60px);
  }
  .ns-msg-split-list.ns-hidden    { display: none; }
  .ns-msg-split-detail.ns-hidden  { display: none; }
  .ns-msg-split-list,
  .ns-msg-split-detail { height: 100%; }
}

/* ── Sidebar masquée sur mobile/tablette ──────────────────────────────────── */
@media (max-width: 1023px) {
  .c-sidebar, .p-sidebar { display: none !important; }
  .c-main   { margin-left: 0 !important; }
  .p-main-wrap { margin-left: 0 !important; }
}
