/* ============================================================
   Académie Victor Hugo — Panel — Thème "Liquid Glass"
   ============================================================ */

:root {
  --accent: #6d5bff;
  --accent-2: #8f7bff;
  --accent-soft: rgba(109, 91, 255, 0.14);
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;

  --bg-1: #eef0fb;
  --bg-2: #f7f5ff;
  --text-1: #1c1d2b;
  --text-2: #5b5d72;
  --text-3: #8b8da3;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(80, 70, 160, 0.12);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-1);
  background:
    radial-gradient(circle at 15% 20%, #e6e9ff 0%, transparent 45%),
    radial-gradient(circle at 85% 15%, #ffe9f6 0%, transparent 40%),
    radial-gradient(circle at 50% 90%, #e3f6ff 0%, transparent 45%),
    var(--bg-1);
  overflow: hidden;
}

.bg-orb, .login-bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}
.orb1 { width: 420px; height: 420px; top: -120px; left: -100px; background: #c7c1ff; }
.orb2 { width: 340px; height: 340px; bottom: -80px; right: -60px; background: #ffd0ea; }
.orb3 { width: 300px; height: 300px; bottom: 10%; left: 35%; background: #c9f3ff; }

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ---------------- App layout ---------------- */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 300px 1fr 260px;
  height: 100vh;
  gap: 14px;
  padding: 14px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 260px 1fr; }
  .members-panel { display: none; }
}

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

.sidebar {
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.guild-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid rgba(120, 110, 200, 0.12);
}

.guild-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.guild-icon img { width: 100%; height: 100%; object-fit: cover; }

.guild-info { flex: 1; min-width: 0; }
.guild-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guild-meta { font-size: 12px; color: var(--text-3); }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(109,91,255,0.25); border-radius: 10px; }

.sidebar-section-header {
  padding: 10px 16px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-transform: uppercase;
}

.dm-list { max-height: 220px; }

.cat-block { margin-bottom: 4px; }
.cat-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-3);
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 8px;
}
.cat-row:hover { background: rgba(120,110,200,0.08); }
.cat-row .cat-arrow { transition: transform 0.15s; font-size: 9px; }
.cat-row.collapsed .cat-arrow { transform: rotate(-90deg); }
.cat-row .cat-name-edit {
  flex: 1;
  background: var(--glass-bg-strong);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-1);
  padding: 2px 6px;
  width: 100%;
}
.cat-row .cat-name { flex: 1; }
.cat-add-btn { opacity: 0; font-size: 13px; color: var(--text-2); }
.cat-row:hover .cat-add-btn { opacity: 1; }

.channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  margin: 1px 0;
}
.channel-row:hover { background: rgba(120,110,200,0.10); color: var(--text-1); }
.channel-row.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.channel-row .ch-icon { opacity: 0.7; width: 16px; text-align: center; }
.channel-row .ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row .ch-name-edit {
  flex: 1;
  background: var(--glass-bg-strong);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 14px;
  color: var(--text-1);
  width: 100%;
}

.dm-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 10px; cursor: pointer;
  font-size: 14px; color: var(--text-2);
}
.dm-row:hover, .dm-row.active { background: var(--accent-soft); color: var(--accent); }
.dm-row img { width: 24px; height: 24px; border-radius: 50%; }

.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(120,110,200,0.12);
}
.me-badge { display: flex; align-items: center; gap: 8px; flex: 1; }
.me-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center;
}
.me-name { font-size: 13px; font-weight: 600; }

/* ---------------- Main column ---------------- */

.main-col {
  display: flex; flex-direction: column;
  min-width: 0;
  gap: 10px;
}

.channel-header {
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  flex-shrink: 0;
}
.channel-header-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.channel-hash { color: var(--text-3); font-weight: 400; }

.messages-scroll {
  flex: 1;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.empty-state {
  margin: auto; text-align: center; color: var(--text-3);
}
.empty-icon { font-size: 40px; margin-bottom: 8px; }

.msg-row {
  display: flex; gap: 12px;
  padding: 6px 8px;
  border-radius: 10px;
}
.msg-row:hover { background: rgba(120,110,200,0.06); }
.msg-row.mod-clickable .msg-author { cursor: pointer; }
.msg-row.mod-clickable .msg-avatar { cursor: pointer; }
.msg-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 700; font-size: 14px; }
.msg-time { font-size: 11px; color: var(--text-3); }
.msg-content { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-edited-tag { font-size: 10px; color: var(--text-3); margin-left: 4px; }
.msg-deleted { opacity: 0.45; text-decoration: line-through; }
.msg-attachment img { max-width: 320px; max-height: 260px; border-radius: 10px; margin-top: 6px; display: block; }
.msg-attachment-file {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 10px; margin-top: 6px;
  background: var(--accent-soft); font-size: 13px; color: var(--accent); text-decoration: none;
}

.embed-container {
  margin-top: 6px;
  border-left: 4px solid var(--accent);
  background: rgba(120,110,200,0.06);
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 480px;
}
.embed-container .e-title { font-weight: 700; margin-bottom: 4px; }
.embed-container .e-desc { font-size: 13.5px; white-space: pre-wrap; color: var(--text-2); }
.embed-container img { max-width: 100%; border-radius: 8px; margin-top: 6px; }

.typing-indicator {
  font-size: 12px; color: var(--text-3); padding: 0 8px; height: 16px;
  font-style: italic;
}

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

.composer {
  border-radius: var(--radius-md);
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  flex-shrink: 0;
}
.composer textarea {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  font-size: 14.5px; font-family: inherit; color: var(--text-1);
  max-height: 140px; padding: 8px 4px;
}
.composer-send { flex-shrink: 0; }
.composer-btn { flex-shrink: 0; }

/* ---------------- Buttons / inputs ---------------- */

.btn {
  border: none; cursor: pointer; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(109,91,255,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(109,91,255,0.45); }
.btn-ghost {
  background: rgba(120,110,200,0.10);
  color: var(--accent);
}
.btn-ghost:hover { background: rgba(120,110,200,0.18); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 16px; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(120,110,200,0.12); }

input[type="text"], input[type="password"], textarea, select {
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid rgba(120,110,200,0.2);
  background: rgba(255,255,255,0.6);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text-1);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

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

/* ---------------- Members panel ---------------- */

.members-panel { border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; }
.panel-title { padding: 16px; font-weight: 700; font-size: 13px; color: var(--text-2); }
.member-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 10px; cursor: pointer; margin: 0 6px;
}
.member-row:hover { background: rgba(120,110,200,0.1); }
.member-row img { width: 28px; height: 28px; border-radius: 50%; }
.member-row .m-name { font-size: 13.5px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .m-voice-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

/* ---------------- Overlay / Drawer / Modal ---------------- */

/* IMPORTANT : .drawer et .modal fixent "display: flex" en dur plus bas,
   ce qui annule l'attribut HTML [hidden] (une regle d'auteur passe toujours
   avant le style navigateur par defaut, meme a specificite egale). Sans
   cette regle, le tiroir de moderation et les modales restent visibles et
   bloquent tous les clics sur le reste de l'interface, meme apres avoir
   cliique sur "fermer". */
[hidden] {
  display: none !important;
}

.overlay {
  position: fixed; inset: 0; background: rgba(20, 15, 50, 0.25);
  backdrop-filter: blur(3px); z-index: 40;
}

.drawer {
  position: fixed; top: 14px; right: 14px; bottom: 14px; width: 380px;
  border-radius: var(--radius-lg); z-index: 50;
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer-header {
  display: flex; align-items: center; gap: 12px; padding: 18px;
  border-bottom: 1px solid rgba(120,110,200,0.12);
}
.drawer-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--accent-soft); background-size: cover; background-position: center; }
.drawer-name { font-weight: 700; font-size: 15px; }
.drawer-sub { font-size: 12px; color: var(--text-3); }
.drawer-header button { margin-left: auto; }

.drawer-tabs { display: flex; padding: 8px 14px 0; gap: 4px; }
.drawer-tab {
  background: transparent; border: none; cursor: pointer;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent;
}
.drawer-tab.active { color: var(--accent); border-color: var(--accent); }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-panel { display: none; }
.drawer-panel.active { display: block; }

.mod-action-group { margin-bottom: 18px; }
.mod-action-group h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.mod-action-row { display: flex; gap: 8px; margin-bottom: 8px; }
.mod-action-row input { flex: 1; }

.journal-entry, .voice-session {
  padding: 10px 12px; border-radius: 10px; background: rgba(120,110,200,0.06);
  margin-bottom: 8px; font-size: 13px;
}
.journal-entry .je-meta { color: var(--text-3); font-size: 11px; margin-bottom: 3px; }
.journal-entry.deleted { opacity: 0.5; text-decoration: line-through; }

.voice-total {
  font-size: 26px; font-weight: 700; color: var(--accent); margin-bottom: 4px;
}

/* ---------------- Modals ---------------- */

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  border-radius: var(--radius-lg); z-index: 60;
  width: min(720px, 92vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid rgba(120,110,200,0.12);
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid rgba(120,110,200,0.12);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.target-channel-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

.embed-builder-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  padding: 20px 22px; overflow-y: auto;
}
@media (max-width: 720px) { .embed-builder-grid { grid-template-columns: 1fr; } }

.embed-form { display: flex; flex-direction: column; gap: 12px; }
.embed-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.1); }

.buttons-editor { border-top: 1px dashed rgba(120,110,200,0.25); padding-top: 12px; }
.buttons-editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.button-edit-row {
  display: flex; gap: 6px; align-items: center; margin-bottom: 8px;
  background: rgba(120,110,200,0.06); padding: 8px; border-radius: 10px;
}
.button-edit-row select { width: 90px; flex-shrink: 0; }
.button-edit-row input { flex: 1; min-width: 0; }
.button-edit-row .remove-btn { flex-shrink: 0; cursor: pointer; color: var(--danger); background: none; border: none; font-size: 15px; }

.embed-preview-col { display: flex; flex-direction: column; }
.embed-preview {
  border-radius: 12px; background: rgba(120,110,200,0.05);
  border-left: 4px solid var(--accent);
  padding: 14px 16px; min-height: 160px;
}
.empty-preview { color: var(--text-3); font-size: 13px; text-align: center; margin-top: 40px; }
.preview-buttons { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.preview-btn {
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  background: #4752c4; color: #fff;
}

.settings-body { padding: 20px 22px; overflow-y: auto; }
.settings-body section { margin-bottom: 22px; }
.settings-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin-bottom: 10px; }
.settings-row { display: flex; gap: 8px; margin-bottom: 8px; }
.settings-row input, .settings-row select { flex: 1; }
.status-box { padding: 12px 14px; border-radius: 10px; background: rgba(120,110,200,0.08); font-size: 13px; }
.settings-msg { font-size: 12.5px; margin-top: 6px; }
.apikey-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: rgba(120,110,200,0.06); border-radius: 10px; margin-bottom: 6px; font-size: 12.5px;
}
.apikey-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Emoji picker */
.emoji-picker {
  position: absolute; bottom: 60px; right: 200px;
  width: 300px; max-height: 300px; overflow-y: auto;
  border-radius: 14px; padding: 10px; z-index: 45;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.emoji-picker img, .emoji-picker span { font-size: 22px; cursor: pointer; width: 30px; height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.emoji-picker img:hover, .emoji-picker span:hover { background: rgba(120,110,200,0.15); }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 12px; font-size: 13.5px; color: #fff;
  background: var(--text-1); box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  animation: toast-in 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px);} to { opacity:1; transform: translateY(0);} }

/* ---------------- Login page ---------------- */

.login-body {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  position: relative;
}
.login-card {
  width: 380px; border-radius: var(--radius-lg); padding: 34px 32px; position: relative; z-index: 1;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.login-brand h1 { font-size: 18px; margin: 0 0 4px; }
.login-brand p { font-size: 13px; color: var(--text-3); margin: 0; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.login-error { background: rgba(239,68,68,0.1); color: var(--danger); padding: 8px 10px; border-radius: 8px; font-size: 12.5px; }
.login-hint { text-align: center; font-size: 11.5px; color: var(--text-3); margin-top: 18px; }
