/* ═══════════════════════════════════════════════════════════════════════════
 * CHAMPAGNE GARDET — Your Private Concierge (concierge.php)
 *
 * Plan :
 *   1. Base body + tokens locaux
 *   2. Layout split 50/50
 *   3. Colonne gauche (image cave + logo)
 *   4. Colonne droite (typo + body container)
 *   5. Carte concierge — plaque or avec photo
 *   6. Trois actions rapides — plaques or mini
 *   7. Panneau messagerie — header + status + liste + typing + input
 *   8. Animation d'apparition des messages
 *   9. Responsive
 *  10. Reduced motion + utils
 * ════════════════════════════════════════════════════════════════════════ */


/* ═══ 1. BASE BODY + TOKENS LOCAUX ═══ */

body.page-concierge {
  background:
    radial-gradient(ellipse at 50% 0%, #2c2c2c 0%, #1f1f1f 50%, #181818 100%);
  min-height: 100vh;
  min-height: 100svh;
  display: block;
  overflow-x: hidden;
}

body.page-concierge .top-nav,
body.page-concierge .site-footer { display: none; }

body.page-concierge {
  /* Variantes locales du dégradé or pour les plaques métalliques */
  --plate-hi:    #f5d98a;
  --plate-mid:   #d4ad53;
  --plate-low:   #b8923c;
  --plate-deep:  #8a6a28;
  --plate-engr:  #3a280f;
}


/* ═══ 2. LAYOUT SPLIT 50/50 ═══ */

.cc-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  min-height: 100svh;
}


/* ═══ 3. COLONNE GAUCHE — image cave + logo ═══ */

.cc-left {
  position: relative;
  overflow: hidden;
  background: #0a0a0a;
}

.cc-left-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: saturate(1.08) contrast(1.04);
}

.cc-left-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      rgba(0,0,0,0.40) 0%,
      rgba(0,0,0,0.0)  20%,
      rgba(0,0,0,0.0)  80%,
      rgba(0,0,0,0.45) 100%
    ),
    linear-gradient(90deg,
      rgba(0,0,0,0.0)  0%,
      rgba(0,0,0,0.0)  60%,
      rgba(0,0,0,0.20) 100%
    );
}

.cc-logo {
  position: absolute;
  top: clamp(24px, 3vw, 36px);
  left: clamp(28px, 3.5vw, 56px);
  z-index: 2;
  display: inline-flex;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,0.6));
}
.cc-logo .logo-svg {
  width: clamp(120px, 12vw, 160px);
  height: auto;
  color: var(--gold);
  display: block;
}


/* ═══ 4. COLONNE DROITE — body + typo ═══ */

.cc-right {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(36px, 4vw, 60px) clamp(28px, 5vw, 70px) 0;   /* pas de padding-bas → footer collé tout en bas */
  min-height: 100vh;
  min-height: 100svh;
}

.cc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.cc-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(1.9rem, 3.2vw, 2.6rem);
  letter-spacing: 0.01em;
  color: var(--gold);
  text-align: center;
  margin: 0 0 clamp(24px, 4vw, 38px);
  opacity: 0;
  transform: translateY(-10px);
  animation: ccFadeDown 0.9s cubic-bezier(.2,.6,.2,1) 0.1s forwards;
}

@keyframes ccFadeDown {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ccFadeUp {
  to { opacity: 1; transform: translateY(0); }
}


/* ═══ 5. CARTE CONCIERGE — plaque or avec photo ═══ */

.cm-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 14px 24px 14px 14px;
  border-radius: 12px;
  /* Plaque or massive (mêmes principes que les autres plaques du site) */
  background:
    radial-gradient(ellipse 90% 60% at 50% 35%, rgba(255,240,180,0.22) 0%, transparent 60%),
    linear-gradient(180deg,
      var(--plate-low) 0%,
      var(--plate-mid) 22%,
      var(--plate-hi)  45%,
      var(--plate-mid) 70%,
      var(--plate-low) 100%
    );
  box-shadow:
    inset 0  2px 0 rgba(255,245,200,0.55),
    inset 0 -2px 0 rgba(60,40,10,0.45),
    inset 2px 0 0 rgba(255,240,200,0.20),
    inset -2px 0 0 rgba(60,40,10,0.20),
    inset 0 0 0 5px rgba(255,235,170,0.06),
    inset 0 0 0 6px rgba(60,40,10,0.18),
    0 14px 30px -10px rgba(0,0,0,0.5),
    0 4px 10px rgba(0,0,0,0.3);
  margin-bottom: clamp(22px, 3vw, 32px);
  opacity: 0;
  transform: translateY(8px);
  animation: ccFadeUp 0.9s cubic-bezier(.2,.6,.2,1) 0.25s forwards;
}

.cm-photo-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(40,25,5,0.55);
  background: linear-gradient(180deg, #2a1a05, #1a0e02);
  box-shadow:
    inset 0 1px 0 rgba(255,240,200,0.25),
    0 2px 6px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.cm-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Fallback initiales — masqué par défaut, montré par onerror dans le PHP */
.cm-photo-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 400;
  color: var(--plate-mid);
  background:
    linear-gradient(135deg, rgba(60,40,10,0.85), rgba(30,20,5,0.95));
  text-shadow:
    0  1px 0 rgba(255,240,200,0.25),
    0 -1px 0 rgba(40,25,5,0.35);
}

.cm-info {
  min-width: 0;        /* permet à text-overflow de fonctionner si trop long */
}

.cm-name {
  font-family: 'Jost', sans-serif;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  font-weight: 600;
  color: var(--plate-engr);
  letter-spacing: 0.005em;
  text-shadow: 0 1px 0 rgba(255,240,200,0.4);
  line-height: 1.2;
}

.cm-role {
  font-family: 'Jost', sans-serif;
  font-size: clamp(0.85rem, 1.2vw, 0.95rem);
  font-weight: 400;
  color: rgba(58,40,15,0.85);
  letter-spacing: 0.005em;
  margin-top: 4px;
  text-shadow: 0 1px 0 rgba(255,240,200,0.3);
}


/* ═══ 6. TROIS ACTIONS RAPIDES — mini plaques or ═══ */

.cc-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.2vw, 14px);
  margin-bottom: clamp(22px, 3vw, 32px);
}

.cc-action {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(40,25,5,0.55);
  font-family: 'Jost', sans-serif;
  cursor: pointer;
  /* Plaque or même esprit que la carte concierge, mais plus compacte */
  background:
    linear-gradient(180deg,
      var(--plate-hi)  0%,
      var(--plate-mid) 30%,
      var(--plate-mid) 60%,
      var(--plate-low) 100%
    );
  box-shadow:
    inset 0  2px 0 rgba(255,245,200,0.60),
    inset 0 -2px 0 rgba(60,40,10,0.45),
    inset 0 0 0 3px rgba(255,235,170,0.08),
    inset 0 0 0 4px rgba(60,40,10,0.15),
    0 6px 18px -8px rgba(201,168,76,0.45),
    0 2px 6px rgba(0,0,0,0.25);
  text-shadow: 0 1px 0 rgba(255,240,200,0.40);
  transition: all 0.2s ease;
  opacity: 0;
  transform: translateY(8px);
  animation: ccFadeUp 0.9s cubic-bezier(.2,.6,.2,1) 0.4s forwards;
}

/* Animation décalée pour chacune des 3 plaques */
.cc-action:nth-child(2) { animation-delay: 0.48s; }
.cc-action:nth-child(3) { animation-delay: 0.56s; }

.cc-action-icon {
  width: 26px;
  height: 26px;
  color: var(--plate-engr);
  flex-shrink: 0;
}

.cc-action-label {
  font-size: clamp(0.8rem, 1.1vw, 0.92rem);
  font-weight: 500;
  color: var(--plate-engr);
  line-height: 1.25;
  letter-spacing: 0.005em;
  text-align: center;
}

.cc-action:hover {
  transform: translateY(-2px);
  background:
    linear-gradient(180deg,
      #fae09c   0%,
      #e2c068  30%,
      #d4b25a  60%,
      #c19a4a 100%
    );
  box-shadow:
    inset 0  2px 0 rgba(255,250,215,0.70),
    inset 0 -2px 0 rgba(60,40,10,0.45),
    inset 0 0 0 3px rgba(255,240,180,0.10),
    inset 0 0 0 4px rgba(60,40,10,0.18),
    0 10px 24px -8px rgba(201,168,76,0.55),
    0 3px 8px rgba(0,0,0,0.3);
}

.cc-action:active {
  transform: translateY(0);
  background:
    linear-gradient(180deg,
      var(--plate-low) 0%,
      var(--plate-mid) 50%,
      var(--plate-hi)  100%
    );
  box-shadow:
    inset 0 3px 5px rgba(40,25,5,0.4),
    inset 0 -1px 0 rgba(255,240,200,0.3),
    0 1px 3px rgba(0,0,0,0.2);
}

.cc-action:focus-visible {
  outline: 2px solid rgba(255,240,180,0.75);
  outline-offset: 3px;
}


/* ═══ 7. PANNEAU MESSAGERIE ═══ */

.msg-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.20);
  padding: 18px 18px 12px;
  box-shadow:
    inset 0 1px 0 rgba(255,240,200,0.04),
    0 14px 30px -16px rgba(0,0,0,0.55);
  opacity: 0;
  transform: translateY(10px);
  animation: ccFadeUp 0.9s cubic-bezier(.2,.6,.2,1) 0.65s forwards;
}

/* Header du panneau : titre + indicateur de connexion */
.msg-header {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(201,168,76,0.12);
  margin-bottom: 12px;
}

.msg-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(1.3rem, 1.8vw, 1.5rem);
  letter-spacing: 0.005em;
  color: var(--gold);
  margin: 0;
  text-align: center;
}

.msg-status {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: rgba(232,224,208,0.45);
  letter-spacing: 0.02em;
}

.msg-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,180,40,0.7);   /* orange = connecting */
  transition: background 0.3s ease;
  box-shadow: 0 0 6px currentColor;
}

.msg-status[data-state="online"] .msg-status-dot { background: #6ed374; }
.msg-status[data-state="offline"] .msg-status-dot { background: #d36e6e; }

/* Liste des messages */
.msg-list {
  list-style: none;
  margin: 0;
  padding: 4px 4px 8px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.msg-list::-webkit-scrollbar { width: 6px; }
.msg-list::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.4);
  border-radius: 3px;
}
.msg-list::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.msg-loading {
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  font-weight: 300;
  color: rgba(232,224,208,0.4);
  text-align: center;
  padding: 16px 0;
}

/* Un message individuel */
.msg-item {
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.55;
  color: rgba(232,224,208,0.92);
  letter-spacing: 0.005em;
  animation: msgPop 0.45s cubic-bezier(.2,.6,.3,1);
}

@keyframes msgPop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-item .msg-from {
  font-weight: 500;
  color: var(--gold);
  margin-right: 4px;
}

.msg-item .msg-date {
  color: rgba(232,224,208,0.45);
  font-size: 13px;
  margin-left: 4px;
  white-space: nowrap;
}

/* Variante "client" (messages envoyés par le merchant) */
.msg-item--client .msg-from {
  color: rgba(232,224,208,0.85);
}

/* Variante "pending" (message en cours d'envoi côté client, optimistic UI) */
.msg-item--pending {
  opacity: 0.55;
  font-style: italic;
}
.msg-item--pending .msg-date::before {
  content: '· sending… ';
  color: rgba(232,224,208,0.4);
}

/* Variante "error" (envoi raté) */
.msg-item--error .msg-from { color: #d36e6e; }
.msg-item--error .msg-date {
  color: #d36e6e;
  cursor: pointer;
}
.msg-item--error .msg-date::before { content: '· failed — retry '; }

/* ─── Typing indicator ─── */
.msg-typing {
  font-family: 'Jost', sans-serif;
  font-size: 12.5px;
  font-weight: 300;
  color: rgba(232,224,208,0.55);
  padding: 4px 8px 6px;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: msgPop 0.3s ease;
}

.msg-typing-name {
  color: var(--gold);
  font-weight: 500;
}

.msg-typing-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
}
.msg-typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.msg-typing-dots i:nth-child(2) { animation-delay: 0.18s; }
.msg-typing-dots i:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ─── Form input ─── */
.msg-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 0 4px;
  border-top: 1px solid rgba(201,168,76,0.12);
  margin-top: 8px;
}

.msg-input {
  flex: 1;
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  font-weight: 300;
  padding: 10px 14px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(232,224,208,0.18);
  border-radius: 18px;
  outline: none;
  resize: none;
  max-height: 120px;       /* limite l'auto-grow */
  line-height: 1.5;
  letter-spacing: 0.005em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.msg-input::placeholder {
  color: rgba(232,224,208,0.4);
  font-weight: 300;
}

.msg-input:hover { border-color: rgba(232,224,208,0.35); }

.msg-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.15);
}

/* Bouton send (icône avion en or) */
.msg-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(40,25,5,0.55);
  background:
    linear-gradient(180deg,
      var(--plate-hi)  0%,
      var(--plate-mid) 50%,
      var(--plate-low) 100%
    );
  color: var(--plate-engr);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0  1px 0 rgba(255,245,200,0.55),
    inset 0 -1px 0 rgba(60,40,10,0.40),
    0 4px 10px -2px rgba(201,168,76,0.45),
    0 2px 4px rgba(0,0,0,0.25);
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.msg-send svg {
  width: 17px;
  height: 17px;
  /* Petite rotation pour que l'avion regarde "vers l'avant" */
  transform: rotate(-12deg);
  margin-left: -2px;
  margin-top: 1px;
}

.msg-send:hover {
  transform: translateY(-1px);
  background:
    linear-gradient(180deg,
      #fae09c   0%,
      #ddc070  50%,
      #c4a050 100%
    );
  box-shadow:
    inset 0  1px 0 rgba(255,250,215,0.70),
    inset 0 -1px 0 rgba(60,40,10,0.40),
    0 6px 12px -2px rgba(201,168,76,0.55),
    0 3px 6px rgba(0,0,0,0.3);
}

.msg-send:active {
  transform: translateY(0);
  background:
    linear-gradient(180deg,
      var(--plate-low) 0%,
      var(--plate-mid) 100%
    );
  box-shadow:
    inset 0 2px 4px rgba(40,25,5,0.4);
}

.msg-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.msg-send:focus-visible {
  outline: 2px solid rgba(255,240,180,0.7);
  outline-offset: 2px;
}


/* ═══ 8. RESPONSIVE ═══ */

@media (max-width: 1024px) {
  .cc-right { padding: 36px 28px; }
  .cc-body  { max-width: 100%; }
}

@media (max-width: 760px) {
  .cc-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 1fr;
    /* Pleine hauteur d'écran conservée sur mobile : la rangée 1fr (.cc-right)
       remplit l'espace restant → le footer (margin-top:auto) tombe en bas. */
    min-height: 100vh;
    min-height: 100svh;
  }

  .cc-left  { height: 200px; }
  .cc-logo  { top: 18px; left: 20px; }
  .cc-logo .logo-svg { width: 110px; }

  .cc-right { padding: 28px 20px 40px; min-height: auto; min-width: 0; }
  /* Anti-débordement horizontal : autorise la colonne de grille + la colonne flex
     à rétrécir sous le min-content d'un enfant, et casse les longs jetons (emails,
     URLs tapés par le prospect) au lieu de déborder .cc-right à droite. */
  .cc-body { min-width: 0; }
  .msg-item { overflow-wrap: anywhere; }

  .cm-card {
    grid-template-columns: auto 1fr;
    padding: 12px 18px 12px 12px;
    gap: 14px;
  }
  .cm-photo-wrap { width: 62px; height: 62px; }
  .cm-name { font-size: 1rem; }
  .cm-role { font-size: 0.82rem; }

  .cc-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .cc-action {
    padding: 12px 4px 10px;
    gap: 6px;
  }
  .cc-action-icon { width: 22px; height: 22px; }
  .cc-action-label { font-size: 0.72rem; }

  .msg-panel { padding: 14px 12px 10px; }
  .msg-list { max-height: 220px; }
  .msg-item { font-size: 13px; }
}

@media (max-width: 380px) {
  /* Sur ultra-petit écran, on passe les actions en 1 colonne empilée */
  .cc-actions { grid-template-columns: 1fr; }
  .cc-action {
    flex-direction: row;
    gap: 12px;
    padding: 10px 14px;
  }
  .cc-action-label {
    text-align: left;
    font-size: 0.82rem;
  }
  /* On annule le <br> dans le label */
  .cc-action-label br { display: none; }
}


/* ═══ 9. REDUCED MOTION ═══ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .cc-title, .cm-card, .cc-action, .msg-panel,
  .msg-item, .msg-typing {
    opacity: 1;
    transform: none;
  }
  .msg-typing-dots i { animation: none; }
}


/* ═══ UTILS ═══ */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }