:root {
  --sidebar-bg: #3f0e40;
  --sidebar-hover: #350d36;
  --sidebar-active: #1164a3;
  --sidebar-text: #cfc3cf;
  --sidebar-text-strong: #ffffff;
  --bg: #ffffff;
  --text: #1d1c1d;
  --text-muted: #616061;
  --border: #dddddd;
  --hover: #f8f8f8;
  --send: #007a5a;
  --online: #2bac76;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

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

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.workspace {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 50px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  flex-shrink: 0;
}

.workspace-name {
  color: var(--sidebar-text-strong);
  font-weight: 900;
  font-size: 18px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 18px;
}

.compose {
  background: #fff;
  color: var(--sidebar-bg);
  border-radius: 50%;
}

.sidebar-nav, .sidebar-section { padding: 10px 0; }

.section-title {
  font-size: 15px;
  font-weight: 400;
  margin: 8px 0 4px;
  padding: 0 16px;
  color: var(--sidebar-text);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 16px;
  margin: 0 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover { background: var(--sidebar-hover); }

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-strong);
  font-weight: 700;
}

.nav-item.muted { opacity: .75; cursor: default; }

.nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.presence {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.presence.online { background: var(--online); }

/* Ne pas déranger : pictogramme sens interdit */
.presence.dnd {
  position: relative;
  width: 12px;
  height: 12px;
  background: #e01e5a;
}

.presence.dnd::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: #fff;
  border-radius: 1px;
}

/* ---------- Avatars ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  font-weight: 900;
  flex-shrink: 0;
  user-select: none;
}

.avatar-xs { width: 20px; height: 20px; font-size: 11px; border-radius: 4px; }
.avatar-sm { width: 24px; height: 24px; font-size: 12px; }
.avatar-md { width: 36px; height: 36px; font-size: 16px; }
.avatar-lg { width: 72px; height: 72px; font-size: 32px; border-radius: 10px; }

/* ---------- Chat ---------- */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-title {
  font-size: 18px;
  font-weight: 900;
  margin: 0;
}

.menu-toggle { display: none; color: var(--text); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 8px;
}

.conversation-intro {
  padding: 24px 20px 20px;
}

.conversation-intro h2 {
  font-size: 22px;
  font-weight: 900;
  margin: 12px 0 6px;
}

.conversation-intro p {
  margin: 0;
  color: var(--text-muted);
}

.day-divider {
  display: flex;
  align-items: center;
  margin: 12px 0;
  font-size: 13px;
  font-weight: 700;
}

.day-divider::before, .day-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.day-divider span {
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 14px;
}

.message {
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 8px;
  padding: 6px 20px;
}

.message:hover { background: var(--hover); }

.message.continued { padding-top: 2px; padding-bottom: 2px; }

.message.continued .avatar { visibility: hidden; height: 0; }

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.message-author { font-weight: 900; }

.message-time {
  font-size: 12px;
  color: var(--text-muted);
}

.message-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.46;
}

.message.system .message-body { color: #b3261e; font-style: italic; }

/* ---------- Typing indicator ---------- */

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 4px;
  font-size: 12px;
  color: var(--text-muted);
  height: 20px;
}

.typing[hidden] { display: flex; visibility: hidden; }

.dots { display: inline-flex; gap: 3px; }

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}

.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Composer ---------- */

.composer { padding: 0 20px 20px; flex-shrink: 0; }

.composer-box {
  border: 1px solid #b0b0b0;
  border-radius: 8px;
  background: #fff;
}

.composer-box:focus-within {
  border-color: #868686;
  box-shadow: 0 0 0 1px #868686;
}

#input {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  padding: 12px 12px 4px;
  max-height: 40vh;
  background: transparent;
  color: inherit;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 8px 12px;
}

.hint { font-size: 12px; color: var(--text-muted); }

.send-btn {
  border: none;
  border-radius: 4px;
  width: 32px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--send);
  color: #fff;
  cursor: pointer;
}

.send-btn:disabled {
  background: transparent;
  color: #c0c0c0;
  cursor: default;
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  .sidebar.open {
    transform: none;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4);
  }

  .menu-toggle { display: grid; }
  .chat-header { padding: 0 12px; }
  .message { padding-left: 16px; padding-right: 16px; }
  .composer { padding: 0 16px 16px; }
  .hint { display: none; }
}
