/* ─────────────────────────────────────────────────────────────────
   messaging.css — Smyle Play Messagerie
   ───────────────────────────────────────────────────────────────── */

#smyle-messaging {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

#smyle-messaging.msg-visible {
  display: block;
  pointer-events: auto;
}

.msg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
}

.msg-panel {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 360px;
  height: 520px;
  background: rgba(14, 7, 32, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.7);
  display: flex;
  overflow: hidden;
}

@media (max-width: 480px) {
  .msg-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 85vh;
    border-radius: 18px 18px 0 0;
  }
}

/* ── Panes ─────────────────────────────────────────────────────── */

.msg-pane {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex-shrink: 0;
}

.msg-pane.hidden { display: none; }

/* ── Header ────────────────────────────────────────────────────── */

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.msg-title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-close-btn,
.msg-back-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.70);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}

.msg-close-btn:hover,
.msg-back-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* ── Thread list ───────────────────────────────────────────────── */

.msg-thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.msg-thread-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.12s;
}

.msg-thread-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.msg-thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.4);
  border: 1px solid rgba(124, 58, 237, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.msg-thread-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.msg-thread-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread-preview {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #7C3AED;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-thread-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

/* ── Messages list ─────────────────────────────────────────────── */

.msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.msg-bubble {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.msg-bubble-me {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-bubble-other {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble-text {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble-me .msg-bubble-text {
  background: #7C3AED;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble-other .msg-bubble-text {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.88);
  border-bottom-left-radius: 4px;
}

.msg-bubble-time {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.50);
  margin-top: 3px;
  padding: 0 2px;
}

/* ── Composer ──────────────────────────────────────────────────── */

.msg-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.msg-input {
  flex: 1;
  resize: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  line-height: 1.45;
  outline: none;
  max-height: 120px;
  transition: border-color 0.15s;
}

.msg-input:focus {
  border-color: rgba(124, 58, 237, 0.5);
}

.msg-input::placeholder { color: rgba(255,255,255,0.50); }

.msg-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #7C3AED;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.msg-send-btn:hover { background: #6d28d9; }
.msg-send-btn:active { transform: scale(0.94); }

/* ── States ────────────────────────────────────────────────────── */

.msg-loading,
.msg-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.58);
  padding: 32px 16px;
  text-align: center;
}
