/* ============================================================
   LIAISON — Interface SMS
   Palette : sombre / chaud / intime
   ============================================================ */

:root {
  --bg:           #0f0f14;
  --surface:      #1a1a24;
  --surface-2:    #23232f;
  --border:       #2a2a38;
  --accent:       #c2185b;
  --accent-light: #e91e63;
  --bubble-sent:  #7b1fa2;
  --bubble-recv:  #23232f;
  --text:         #f0eef6;
  --text-muted:   #8880a0;
  --avatar-hue:   320;
  --radius:       18px;
  --transition:   200ms ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}

/* ============================================================
   ÉCRANS
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 320ms cubic-bezier(.4,0,.2,1);
  will-change: transform;
}

.screen.active      { transform: translateX(0); }
.screen.slide-out   { transform: translateX(-30%); }

/* ============================================================
   HEADER GÉNÉRAL
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  letter-spacing: -1px;
}

.logo-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--text);
  opacity: .9;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ============================================================
   LISTE DES CONTACTS
   ============================================================ */
#contact-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.contact-card:active { background: var(--surface-2); }

.contact-card .avatar {
  flex-shrink: 0;
}

.contact-card-info {
  flex: 1;
  min-width: 0;
}

.contact-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}

.contact-name {
  font-weight: 600;
  font-size: 15px;
}

.contact-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}

.contact-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  flex-shrink: 0;
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: hsl(var(--avatar-hue), 50%, 28%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: hsl(var(--avatar-hue), 60%, 85%);
  flex-shrink: 0;
}

/* ============================================================
   HEADER CHAT
   ============================================================ */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header .avatar {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

.chat-header .contact-name {
  font-size: 15px;
}

.contact-status {
  font-size: 12px;
  color: #7dc97d;
}

/* ============================================================
   ZONE DE MESSAGES
   ============================================================ */
#messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

#messages-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
}

/* ---- Bulle ---- */
.bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  animation: pop-in 180ms cubic-bezier(.4,0,.2,1);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(.94) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.bubble-wrap.sent  { align-self: flex-end; align-items: flex-end; }
.bubble-wrap.recv  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-wrap.sent .bubble {
  background: var(--bubble-sent);
  color: #f0e8ff;
  border-bottom-right-radius: 5px;
}

.bubble-wrap.recv .bubble {
  background: var(--bubble-recv);
  color: var(--text);
  border-bottom-left-radius: 5px;
}

.bubble-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* ---- Indicateur "en train d'écrire" ---- */
.typing {
  align-self: flex-start;
  background: var(--bubble-recv);
  border-radius: var(--radius);
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 6px;
}

.typing.hidden { display: none; }

.typing span {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* ============================================================
   ZONE DE SAISIE
   ============================================================ */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#msg-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color var(--transition);
}
#msg-input:focus { border-color: var(--accent); }
#msg-input::placeholder { color: var(--text-muted); }

#btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
#btn-send:hover  { background: var(--accent-light); }
#btn-send:active { transform: scale(.92); }
#btn-send svg    { width: 20px; height: 20px; }
#btn-send:disabled { background: var(--border); cursor: not-allowed; }

/* ============================================================
   SCROLLBAR discrète
   ============================================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
