/* Console page — XPCHAT (premium re-skin) */

body.consoleBody{
  background: radial-gradient(1200px 800px at 20% 10%, rgba(100,210,255,0.16), transparent 60%),
              radial-gradient(900px 600px at 85% 20%, rgba(167,139,250,0.12), transparent 55%),
              linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

/* Utility overrides */
.theme-dark{ color-scheme: dark; }
.theme-light{ color-scheme: light; }

\.layout{
  height: calc(var(--app-vh, 100dvh) - var(--header-total-h));
  min-height: calc(var(--app-vh, 100dvh) - var(--header-total-h));
  overflow: hidden;
  display:grid;
  grid-template-columns: 360px 1fr;
}

.sidebar{
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  padding: 18px;
  overflow:auto;
}

.logo{
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  margin: 8px 0 18px;
}

.logo span{
  color: var(--text);
}

.panel{
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  margin-bottom: 14px;
  overflow:hidden;
}

.panel-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.panel-header h2{
  font-size: 0.95rem;
  margin:0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-body{ padding: 14px; }

.label{ font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.value{ margin-top: 6px; font-weight: 650; color: var(--text); }

.mt8{ margin-top: 8px; }

.input{
  width:100%;
  padding: 12px 14px;
  border-radius: 16px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
}
.input::placeholder{ color: var(--muted-2); }

.btn.full{ width:100%; }
.btn.small{ padding: 9px 12px; border-radius: 14px; font-size: 0.95rem; }
.btn.ghost{ background: transparent; }

/* HUD */
.hud{ display:flex; flex-direction:column; gap: 8px; }
.hud-row{ display:flex; justify-content:space-between; gap: 10px; font-size: 0.92rem; color: var(--muted); }
.hud-row span:last-child{ color: var(--text); font-weight: 650; }

.hud-bar{ height: 10px; border-radius: 999px; background: var(--surface-2); overflow:hidden; }
.hud-xp-fill{ height:100%; width:0%; background: linear-gradient(90deg, rgba(100,210,255,0.7), rgba(167,139,250,0.65)); }

.hud-mission{ margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.hud-mission-text{ font-weight: 650; color: var(--text); }
.hud-mission-meta{ margin-top: 6px; color: var(--muted); font-size: 0.92rem; }

/* Chat pane */
.chatPane{
  position:relative;
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:0;
}

.chatHeader{
  display:flex;
  gap: 14px;
  align-items:flex-start;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 78%, transparent), transparent);
}

.chatHeader h2{ font-size: 1.15rem; margin:0; }
.subtitle{ margin-top: 4px; color: var(--muted); }

.offline{
  position:absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.15);
  border:1px solid rgba(255, 107, 107, 0.25);
  color: var(--text);
  z-index: 5;
}

#offlineBanner[aria-hidden="true"]{ display:none; }
#offlineBanner[aria-hidden="false"]{ display:block; }

/* DEBUG OVERLAY */
.debugOverlay{
  position: fixed;
  z-index: 99999;
  right: 10px;
  bottom: 10px;
  width: min(520px, calc(100vw - 20px));
  max-height: min(64vh, 520px);
  background: rgba(10,10,14,.92);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  color: rgba(255,255,255,.92);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.debugOverlay--hidden{
  height: 44px;
  max-height: 44px;
  overflow: hidden;
}

.dbgTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
}

.dbgTitle{
  font-weight: 800;
  letter-spacing: .06em;
  font-size: 12px;
  opacity: .95;
}

.dbgBtns{ display:flex; gap: 8px; }

.dbgBtn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.92);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.dbgBtn:hover{ background: rgba(255,255,255,.10); }

.dbgBtn--danger{
  border-color: rgba(255,70,70,.35);
  background: rgba(255,70,70,.12);
}

.dbgGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dbgCard{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  border-radius: 12px;
  padding: 10px;
}

.dbgCardTitle{
  font-size: 12px;
  font-weight: 800;
  opacity: .9;
  margin-bottom: 8px;
}

.dbgKVs{ display:flex; flex-direction:column; gap: 6px; }

.dbgKV{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
  font-size: 12px;
}

.dbgKV span{ opacity: .75; }
.dbgKV b{ font-weight: 800; }

.dbgActions{ display:flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.dbgCard--logs{ flex: 1; }

.dbgLogs{
  max-height: 220px;
  overflow:auto;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  line-height: 1.3;
}

.dbgLine{ white-space: pre-wrap; word-break: break-word; margin-bottom: 6px; opacity: .96; }

@media (max-width: 520px){
  .dbgGrid{ grid-template-columns: 1fr; }
  .debugOverlay{ right: 8px; left: 8px; width: auto; }
}

.messages{
  flex:1;
  padding: 16px 22px 8px;
  overflow:auto;
  min-height:0;
  touch-action: pan-y;
  scroll-behavior:auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.msg.sys{
  padding: 10px 12px;
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--muted);
}

.system{ color: rgba(100,210,255,0.9); }

.msgRow{
  display:flex;
  gap: 12px;
  margin: 6px 0;
  align-items:flex-end;
}

.msgRow.meRow{ justify-content:flex-end; }
.msgRow.meRow .avatar{ display:none; }

.avatar{
  width: 36px;
  height: 36px;
  border-radius: 14px;
  border:1px solid var(--border);
  object-fit: cover;
  background: var(--surface-2);
}

.avatar.fallback{
  display:grid;
  place-items:center;
  font-weight: 700;
  color: var(--text);
}

.bubble{
  position:relative;
  max-width: min(680px, 92%);
  padding: 10px 12px 28px;
  border-radius: 18px;
  border:1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
}

.text{
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meRow .bubble{
  background: linear-gradient(135deg, rgba(100,210,255,0.16), rgba(167,139,250,0.12));
  border-color: var(--border);
}

.iaRow .bubble{
  border-color: rgba(100,210,255,0.22);
}

.keyRow .bubble{
  border-color: rgba(46,229,157,0.22);
}

.meta{
  display:flex;
  align-items:center;
  gap: 10px;
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.name{ font-weight: 700; color: var(--text); }

.badge{
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.text{ white-space:pre-wrap; word-break:break-word; color: var(--text); }

.media{ margin-top: 10px; border-radius: 16px; overflow:hidden; border: 1px solid var(--border); }
.msgImage{ width:100%; height:auto; display:block; }

.msgActions{
  position:absolute;
  top: 6px;
  right: 6px;
  opacity:0;
  transform: translateY(-2px);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}

.bubble:hover .msgActions{ opacity:1; transform:none; }
.bubble:focus-within .msgActions{ opacity:1; transform:none; }

.bubble .iconBtn{
  padding: 4px 6px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1;
}

.iconBtn.danger{ border-color: rgba(255, 107, 107, 0.25); }

.reactionBar{
  display:flex;
  gap: 8px;
  position:absolute;
  right: 8px;
  bottom: 6px;
  opacity:0;
  transform: translateY(6px);
  pointer-events:none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}

.bubble:hover .reactionBar{
  opacity:1;
  transform:none;
  pointer-events:auto;
}

.bubble:focus-within .reactionBar{
  opacity:1;
  transform:none;
  pointer-events:auto;
}

.reactBtn{
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.82rem;
  line-height: 1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.reactBtn.active{ border-color: rgba(100,210,255,0.35); }

.reactionChips{ display:none; gap: 6px; margin-top: 6px; flex-wrap:wrap; }

.chip{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
}

.chip.mine{ border-color: rgba(100,210,255,0.35); }

/* Composer */
.composer{
  display:flex;
  gap: 10px;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.msgInput{ flex:1; }

.composerMeta{ display:flex; justify-content:flex-end; padding: 0 22px 14px; color: var(--muted-2); font-family: var(--font-mono); font-size: 0.85rem; }

.newMsgBtn{
  position: sticky;
  bottom: calc(96px + env(safe-area-inset-bottom));
  margin-left: 22px;
}

/* Typing indicator */
.typingDots{ display:flex; gap: 6px; padding: 8px 0 4px; }
.typingDots i{ width: 6px; height: 6px; border-radius: 999px; background: var(--muted-2); animation: t 1.2s infinite; }
.typingDots i:nth-child(2){ animation-delay: 0.15s; }
.typingDots i:nth-child(3){ animation-delay: 0.3s; }
@keyframes t{ 0%, 100%{ transform: translateY(0); opacity:0.55; } 50%{ transform: translateY(-4px); opacity:0.95; } }

/* Sidebar mobile */
.sidebarToggle{ display:none; }
.sidebarOverlay{
  display:none;
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
}

body.sidebar-open .sidebarOverlay{ display:block; }
body.sidebar-open{ overflow:hidden; }

/* Clock + terminal in header */
.clock{
  font-family: var(--font-mono);
  color: var(--muted);
  min-width: 86px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.terminalStatus{
  font-family: var(--font-mono);
  color: var(--muted-2);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Prevent the header time/status from shrinking the nav too aggressively on desktop */
.consoleBody .nav{ flex: 1 1 520px; }
.consoleBody .headerActions{ flex: 0 0 auto; }

@media (max-width: 1180px){
  /* If space is tight, allow actions to wrap below instead of "eating" the nav */
  .consoleBody .headerRow{ flex-wrap: wrap; height: auto; padding: 10px 0; }
  .consoleBody .nav{ order: 3; width: 100%; justify-content: center; }
}

.popIn{ animation: pop 220ms var(--ease) both; }
@keyframes pop{ from{ opacity:0; transform: translateY(6px); } to{ opacity:1; transform:none; } }

/* RESPONSIVE */
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    height: calc(100svh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    width: min(360px, 92vw);
    transform: translateX(-105%);
    transition: transform var(--dur-3) var(--ease);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 45;
  }
  body.sidebar-open .sidebar{ transform: translateX(0); }
  .sidebarToggle{ display:inline-flex; }
}

@media (max-width: 760px){
  .headerActions{
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
  }
  
  .clock,
  .terminalStatus,
  .badge,
  #themeToggle,
  #soundToggle,
  #btn-login,
  #btn-logout {
    display: inline-flex !important;
    font-size: 0.85rem;
  }
  
  .clock,
  .terminalStatus {
    order: 10;
    flex-basis: auto;
  }
}

@media (max-width: 520px){
  .headerActions{
    width: 100%;
    justify-content: space-between;
  }
  
  .clock{
    font-size: 0.8rem;
  }
  
  .terminalStatus{
    font-size: 0.75rem;
  }
  
  .messages{ padding-inline: 14px; }
  .chatHeader{ padding-inline: 14px; }
  .composer{ padding-inline: 14px; }
  .composerMeta{ padding-inline: 14px; }
  .consoleBody .headerActions{ gap: 8px; }
  .consoleBody .badge{ padding: 6px 8px; font-size: 0.82rem; }
}

  /* =========================================================
   FIX CONSOLE — SUPPRIMER L’HEURE (CLOCK)
   (override desktop + mobile, même avec !important)
   ========================================================= */

/* Si l’horloge est en class */
.consoleBody .clock{
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Si l’horloge est en id */
.consoleBody #clock{
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Optionnel mais uile: évite que le header "réserve" de la place */
.consoleBody .headerActions{
  gap: 8px;
}
