/* ═══════════════════════════════════════════════════════════════════════════
   YORUCHAT — le dashboard sous forme d'application de chat.
   Site indépendant : rail de « serveurs », liste de salons, fil de messages
   (la config se lit et s'édite en bulles), liste de membres. Deux thèmes
   (sombre/clair) propres au site.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --c-bg0: #1e1f22;   /* rail */
  --c-bg1: #2b2d31;   /* salons + membres */
  --c-bg2: #313338;   /* fil */
  --c-bg3: #383a40;   /* éléments (input, hover) */
  --c-text: #dbdee1;
  --c-strong: #f2f3f5;
  --c-muted: #949ba4;
  --c-line: #26272b;
  --c-accent: #5865f2;
  --c-ok: #23a55a;
  --c-bad: #da373c;
  --c-warn: #f0b232;
}
body[data-ctheme='light'] {
  --c-bg0: #e3e5e8; --c-bg1: #f2f3f5; --c-bg2: #ffffff; --c-bg3: #ebedef;
  --c-text: #2e3338; --c-strong: #060607; --c-muted: #6d6f78; --c-line: #dfe1e5;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'gg sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--c-bg2); color: var(--c-text); height: 100vh; overflow: hidden;
  font-size: 14.5px;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }

#chat-loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; background: var(--c-bg0); z-index: 100;
  color: var(--c-muted);
}
.cl-logo { font-size: 52px; animation: clBounce 1s ease infinite; }
@keyframes clBounce { 50% { transform: translateY(-8px); } }

#app { display: flex; height: 100vh; }

/* ── Rail ── */
#rail {
  width: 72px; background: var(--c-bg0); padding: 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0;
}
#rail-guild {
  width: 48px; height: 48px; border-radius: 16px; object-fit: cover; cursor: pointer;
  transition: border-radius .15s ease; background: var(--c-bg3);
}
#rail-guild:hover { border-radius: 12px; }
.rail-sep { width: 32px; height: 2px; border-radius: 2px; background: var(--c-bg3); }
.rail-spring { flex: 1; }
.rail-btn {
  width: 48px; height: 48px; border-radius: 50%; background: var(--c-bg1); font-size: 20px;
  transition: border-radius .15s ease, background .15s ease;
  display: flex; align-items: center; justify-content: center;
}
.rail-btn:hover { border-radius: 16px; background: var(--c-accent); }

/* ── Salons ── */
#channels {
  width: 244px; background: var(--c-bg1); display: flex; flex-direction: column; flex-shrink: 0;
}
#ch-guild {
  padding: 14px 16px; border-bottom: 1px solid var(--c-line);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
#ch-guild b { color: var(--c-strong); font-size: 15px; display: block; }
#ch-guild small { color: var(--c-muted); font-size: 12px; }
#ch-list { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.ch-cat {
  display: flex; align-items: center; gap: 4px; padding: 12px 8px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--c-muted); cursor: pointer; user-select: none;
}
.ch-cat:hover { color: var(--c-text); }
.ch-cat .arrow { font-size: 9px; transition: transform .15s; }
.ch-cat.closed .arrow { transform: rotate(-90deg); }
.ch-item {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px; margin: 1px 0;
  border-radius: 6px; color: var(--c-muted); cursor: pointer; font-size: 15px;
}
.ch-item .hash { font-weight: 400; opacity: .8; }
.ch-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.ch-item:hover { background: var(--c-bg3); color: var(--c-text); }
.ch-item.active { background: var(--c-bg3); color: var(--c-strong); font-weight: 500; }
.ch-item .st { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.st.on { background: var(--c-ok); } .st.off { background: var(--c-muted); opacity: .5; }
.ch-cat-body.hidden { display: none; }

/* ── Fil ── */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#ch-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--c-line); box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
#ch-head-name { font-weight: 700; color: var(--c-strong); }
#ch-head-topic { flex: 1; color: var(--c-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-members { font-size: 17px; opacity: .8; }
#btn-members:hover { opacity: 1; }
#messages { flex: 1; overflow-y: auto; padding: 18px 16px 8px; }

.msg { display: flex; gap: 14px; padding: 6px 4px; border-radius: 6px; margin-bottom: 4px; }
.msg:hover { background: rgba(0,0,0,.06); }
.msg-av {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--c-accent); display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; color: var(--c-strong); }
.msg-author.bot::after {
  content: 'APP'; background: var(--c-accent); color: #fff; border-radius: 4px;
  font-size: 9.5px; font-weight: 700; padding: 1px 5px; margin-left: 6px; vertical-align: 2px;
}
.msg-when { color: var(--c-muted); font-size: 11.5px; }
.msg-text { margin-top: 2px; line-height: 1.5; }
.msg-text .mut { color: var(--c-muted); font-size: 13px; }

/* « Embed » de config dans une bulle */
.emb {
  margin-top: 6px; background: var(--c-bg1); border-left: 4px solid var(--c-accent);
  border-radius: 6px; padding: 12px 14px; max-width: 560px;
}
.emb-title { font-weight: 700; color: var(--c-strong); margin-bottom: 4px; }
.emb-desc { color: var(--c-muted); font-size: 13px; margin-bottom: 8px; line-height: 1.45; }
.emb-field { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--c-line); }
.emb-field .ef-lb { flex: 0 0 46%; font-size: 13px; }
.emb-field .ef-lb b { color: var(--c-strong); font-weight: 600; }
.emb-field .ef-lb small { display: block; color: var(--c-muted); font-size: 11.5px; margin-top: 1px; line-height: 1.35; }
.emb-field .ef-ct { flex: 1; min-width: 0; }
.emb-sec { margin-top: 10px; padding: 6px 9px; border-radius: 5px; background: var(--c-bg3); font-weight: 600; font-size: 13px; }
.emb-sec small { display: block; font-weight: 400; color: var(--c-muted); font-size: 11.5px; }
.emb-save { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.emb-save .n { color: var(--c-muted); font-size: 12px; margin-right: auto; }

.c-input, .c-select, .c-textarea {
  width: 100%; background: var(--c-bg0); border: none; border-radius: 5px;
  color: var(--c-text); padding: 7px 10px; outline: none; font-size: 13.5px;
}
body[data-ctheme='light'] .c-input, body[data-ctheme='light'] .c-select, body[data-ctheme='light'] .c-textarea { background: var(--c-bg3); }
.c-input:focus, .c-select:focus, .c-textarea:focus { box-shadow: 0 0 0 2px var(--c-accent); }
.c-textarea { min-height: 64px; resize: vertical; }
.c-btn {
  background: var(--c-accent); color: #fff; border-radius: 5px; padding: 7px 16px;
  font-weight: 500; font-size: 13.5px;
}
.c-btn:hover { filter: brightness(1.1); }
.c-btn.ghost { background: var(--c-bg3); color: var(--c-text); }
.c-btn.ok { background: var(--c-ok); }
.c-btn:disabled { opacity: .5; cursor: not-allowed; }

.c-toggle { position: relative; display: inline-block; width: 40px; height: 24px; flex-shrink: 0; }
.c-toggle input { opacity: 0; width: 0; height: 0; }
.c-slider { position: absolute; inset: 0; border-radius: 999px; background: #80848e; transition: background .15s; cursor: pointer; }
.c-slider::before {
  content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s;
}
.c-toggle input:checked + .c-slider { background: var(--c-ok); }
.c-toggle input:checked + .c-slider::before { transform: translate(16px, -50%); }

.c-multi { max-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; background: var(--c-bg0); border-radius: 5px; padding: 7px 10px; }
body[data-ctheme='light'] .c-multi { background: var(--c-bg3); }
.c-multi label { display: flex; gap: 7px; align-items: center; font-size: 12.5px; cursor: pointer; }

.obj-msg { border: 1px solid var(--c-line); border-radius: 6px; padding: 8px; margin-bottom: 6px; }
.obj-msg .om-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.obj-msg .om-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--c-muted); margin-bottom: 5px; }

/* Réactions décoratives sous les messages système */
.msg-reacts { display: flex; gap: 5px; margin-top: 6px; }
.react { background: var(--c-bg1); border: 1px solid var(--c-line); border-radius: 9px; padding: 1px 8px; font-size: 12px; cursor: default; }

/* ── Composer ── */
#composer { padding: 0 16px 20px; }
#composer-input {
  width: 100%; background: var(--c-bg3); border: none; border-radius: 9px;
  padding: 12px 14px; color: var(--c-text); outline: none;
}
#composer-pop {
  position: absolute; left: 16px; right: 16px; bottom: 70px;
  background: var(--c-bg1); border: 1px solid var(--c-line); border-radius: 9px;
  box-shadow: 0 14px 34px rgba(0,0,0,.3); max-height: 300px; overflow-y: auto; padding: 6px;
  z-index: 20;
}
.cp-row { display: flex; gap: 9px; align-items: center; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.cp-row:hover, .cp-row.sel { background: var(--c-bg3); }
.cp-row .sub { color: var(--c-muted); font-size: 12px; margin-left: auto; }

/* ── Membres ── */
#members { width: 240px; background: var(--c-bg1); padding: 14px 10px; flex-shrink: 0; overflow-y: auto; }
.mb-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--c-muted); padding: 0 6px 8px; }
#mb-search {
  width: 100%; background: var(--c-bg0); border: none; border-radius: 5px;
  padding: 7px 10px; color: var(--c-text); outline: none; margin-bottom: 8px; font-size: 13px;
}
body[data-ctheme='light'] #mb-search { background: var(--c-bg3); }
.mb-row { display: flex; gap: 9px; align-items: center; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.mb-row:hover { background: var(--c-bg3); }
.mb-row img { width: 30px; height: 30px; border-radius: 50%; }
.mb-row .nm { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-row .sub { color: var(--c-muted); font-size: 11px; display: block; }

/* Toasts */
#chat-toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.c-toast {
  background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 8px;
  padding: 9px 16px; font-size: 13.5px; box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.c-toast.ok { border-left: 3px solid var(--c-ok); }
.c-toast.err { border-left: 3px solid var(--c-bad); }

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--c-bg0); border-radius: 8px; border: 2px solid var(--c-bg1); }

@media (max-width: 880px) {
  #channels { width: 200px; }
  #members { display: none !important; }
}
@media (max-width: 640px) {
  #rail { width: 56px; }
  #channels { position: absolute; z-index: 30; height: 100%; left: 56px; box-shadow: 8px 0 24px rgba(0,0,0,.3); }
  #channels.folded { display: none; }
}
