/* ═══════════════════════════════════════════════
   ODIN — Feuille de style
   virtualcorsa.ch / pixup.ch
═══════════════════════════════════════════════ */

:root {
  --void:       #04050a;
  --abyss:      #080c14;
  --deep:       #0d1220;
  --stone:      #1a2035;
  --iron:       #2a3550;
  --ash:        #8090a8;
  --mist:       #b0bdd0;
  --light:      #dce5f0;
  --pure:       #f0f4fa;
  --gold:       #c8a84b;
  --gold-dim:   #8a6e28;
  --gold-glow:  #e8c870;
  --sidebar-w:  280px;
  --font-title: 'Cinzel', serif;
  --font-body:  'Crimson Pro', serif;
  --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { height: 100%; background: var(--void); color: var(--light); font-family: var(--font-body); font-size: 18px; line-height: 1.8; overflow-x: hidden; }

/* ─── Cosmos ──────────────────────────────────── */
#cosmos { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.star { position: absolute; background: white; border-radius: 50%; animation: twinkle var(--d,4s) var(--delay,0s) infinite alternate ease-in-out; }
@keyframes twinkle { from { opacity: var(--min-op,0.1); transform: scale(1); } to { opacity: var(--max-op,0.8); transform: scale(1.3); } }
.nebula { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.04; animation: drift 20s infinite alternate ease-in-out; }
@keyframes drift { from { transform: translate(0,0) scale(1); } to { transform: translate(30px,-20px) scale(1.1); } }

/* ─── Login ───────────────────────────────────── */
#login-screen { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, #0d1520 0%, #04050a 100%); transition: opacity 0.8s ease, visibility 0.8s ease; }
#login-screen.hidden { opacity: 0; visibility: hidden; }
.login-box { width: min(460px, 92vw); text-align: center; animation: rise 1.2s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
.login-rune { font-size: clamp(3rem,10vw,5rem); color: var(--gold); text-shadow: 0 0 40px rgba(200,168,75,0.6); animation: pulse-rune 3s infinite ease-in-out; display: block; margin-bottom: 1rem; }
@keyframes pulse-rune { 0%,100% { text-shadow: 0 0 40px rgba(200,168,75,0.6), 0 0 80px rgba(200,168,75,0.2); } 50% { text-shadow: 0 0 60px rgba(200,168,75,0.9), 0 0 120px rgba(200,168,75,0.4); } }
.login-title { font-family: var(--font-title); font-size: clamp(2.5rem,8vw,4rem); font-weight: 900; color: var(--gold-glow); letter-spacing: 0.2em; margin-bottom: 0.3rem; }
.login-sub { font-size: 1rem; color: var(--ash); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 2.5rem; font-style: italic; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.odin-input { background: rgba(255,255,255,0.04); border: 1px solid rgba(200,168,75,0.25); border-radius: 4px; padding: 0.9rem 1.2rem; color: var(--light); font-family: var(--font-body); font-size: 18px; outline: none; transition: border-color var(--transition); width: 100%; }
.odin-input::placeholder { color: var(--iron); }
.odin-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,168,75,0.1); }
.odin-btn { background: linear-gradient(135deg, var(--gold-dim), var(--gold)); border: none; border-radius: 4px; padding: 1rem 2rem; color: var(--void); font-family: var(--font-title); font-size: 0.9rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; cursor: pointer; transition: all var(--transition); position: relative; overflow: hidden; }
.odin-btn::before { content:''; position: absolute; inset: 0; background: linear-gradient(135deg, var(--gold), var(--gold-glow)); opacity: 0; transition: opacity var(--transition); }
.odin-btn:hover::before { opacity: 1; }
.odin-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(200,168,75,0.4); }
.odin-btn span { position: relative; z-index: 1; }
.login-error { color: #c87070; font-size: 1rem; min-height: 1.4rem; font-style: italic; }

/* ─── Layout principal ────────────────────────── */
#main-layout {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100dvh;
}

/* ─── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(8, 12, 20, 0.97);
  border-right: 1px solid rgba(200,168,75,0.12);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transform: translateX(0);
  transition: transform var(--transition);
  z-index: 10;
}

.sidebar.hidden {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(calc(-1 * var(--sidebar-w)));
    z-index: 150;
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 140;
}
.sidebar-overlay.visible { display: block; }

.sidebar-header {
  padding: 1.2rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(200,168,75,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-family: var(--font-title);
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.sidebar-new-btn {
  background: rgba(200,168,75,0.1);
  border: 1px solid rgba(200,168,75,0.25);
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s;
}
.sidebar-new-btn:hover { background: rgba(200,168,75,0.2); border-color: var(--gold); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--iron) transparent;
}

.sidebar-empty {
  padding: 1.5rem 1rem;
  color: var(--iron);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
}

.sidebar-item {
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  position: relative;
}
.sidebar-item:hover { background: rgba(255,255,255,0.04); border-left-color: rgba(200,168,75,0.3); }
.sidebar-item.active { background: rgba(200,168,75,0.07); border-left-color: var(--gold); }

.sidebar-item-title {
  font-size: 0.85rem;
  color: var(--mist);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}

.sidebar-item-meta {
  font-size: 0.72rem;
  color: var(--iron);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.sidebar-item-mode {
  background: rgba(200,168,75,0.1);
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
  color: var(--gold-dim);
  font-family: var(--font-title);
  font-size: 0.6rem;
  text-transform: uppercase;
}

.sidebar-item-delete {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--iron);
  cursor: pointer;
  padding: 0.3rem;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  font-size: 0.8rem;
}
.sidebar-item:hover .sidebar-item-delete { opacity: 1; }
.sidebar-item-delete:hover { color: #c87070; }

.sidebar-footer {
  padding: 0.8rem 1rem;
  border-top: 1px solid rgba(200,168,75,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.user-badge { font-size: 0.8rem; color: var(--ash); }
.user-badge strong { color: var(--mist); }

.logout-btn { background: none; border: 1px solid rgba(255,255,255,0.1); border-radius: 3px; padding: 0.35rem 0.7rem; color: var(--ash); font-family: var(--font-body); font-size: 0.8rem; cursor: pointer; transition: all 0.3s; }
.logout-btn:hover { border-color: var(--gold-dim); color: var(--gold); }

/* ─── App ─────────────────────────────────────── */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.2rem;
  width: 100%;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  min-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: var(--iron) transparent;
}

header { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 0 0.8rem; border-bottom: 1px solid rgba(200,168,75,0.15); gap: 1rem; flex-wrap: wrap; }
.header-left { display: flex; align-items: center; gap: 0.8rem; }

.sidebar-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  color: var(--ash);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}
.sidebar-toggle:hover { border-color: var(--gold-dim); color: var(--gold); }

.header-rune { font-size: 1.8rem; color: var(--gold); text-shadow: 0 0 20px rgba(200,168,75,0.5); }
.header-title { font-family: var(--font-title); font-size: 1.6rem; font-weight: 900; color: var(--gold-glow); letter-spacing: 0.15em; }

.header-right { display: flex; align-items: center; gap: 0.8rem; }

.new-conv-btn {
  background: none;
  border: 1px solid rgba(200,168,75,0.25);
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  color: var(--gold-dim);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}
.new-conv-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ─── Modes ───────────────────────────────────── */
.mode-selector { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; padding: 0.8rem 0 0.6rem; }
@media (max-width: 700px) { .mode-selector { grid-template-columns: repeat(5, 1fr); gap: 0.3rem; padding: 0.5rem 0 0.4rem; } }
@media (max-width: 400px) { .mode-selector { grid-template-columns: repeat(5, 1fr); gap: 0.2rem; } }

.mode-btn { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); border-radius: 6px; padding: 0.6rem 0.2rem; color: var(--ash); font-family: var(--font-title); font-size: 0.6rem; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; transition: all var(--transition); display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
@media (max-width: 700px) { .mode-btn { padding: 0.5rem 0.2rem; font-size: 0.55rem; } }
.mode-icon { font-size: 1.3rem; display: block; transition: transform 0.3s; }
@media (max-width: 700px) { .mode-icon { font-size: 1.1rem; } }
.mode-icon { font-size: 1.4rem; display: block; transition: transform 0.3s; }
.mode-btn:hover { border-color: rgba(200,168,75,0.4); color: var(--mist); background: rgba(200,168,75,0.05); }
.mode-btn:hover .mode-icon { transform: scale(1.15); }
.mode-btn.active { border-color: var(--gold); color: var(--gold-glow); background: rgba(200,168,75,0.08); box-shadow: 0 0 20px rgba(200,168,75,0.1); }
.mode-btn.active .mode-icon { filter: drop-shadow(0 0 6px rgba(200,168,75,0.8)); }

/* ─── Chat ────────────────────────────────────── */
.chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.mode-label-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0 0.6rem; }
.mode-label { font-size: 0.78rem; color: var(--gold-dim); letter-spacing: 0.15em; text-transform: uppercase; font-family: var(--font-title); font-style: italic; }
.clear-btn { background: none; border: 1px solid rgba(255,255,255,0.08); border-radius: 3px; padding: 0.3rem 0.7rem; color: var(--iron); font-family: var(--font-body); font-size: 0.8rem; cursor: pointer; transition: all 0.3s; }
.clear-btn:hover { border-color: #c87070; color: #c87070; }

#messages { flex: 1; overflow-y: auto; padding: 0.5rem 0 1rem; display: flex; flex-direction: column; gap: 1.4rem; min-height: 200px; scrollbar-width: thin; scrollbar-color: var(--iron) transparent; }
@media (min-width: 769px) { #messages { min-height: 0; } }
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb { background: var(--iron); border-radius: 2px; }

.msg { display: flex; gap: 0.8rem; animation: msg-in 0.4s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.msg.user { flex-direction: row-reverse; }

.msg-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.msg.odin .msg-avatar { background: radial-gradient(circle,#2a1a00,#0d0a00); border: 1px solid var(--gold-dim); color: var(--gold); box-shadow: 0 0 12px rgba(200,168,75,0.3); }
.msg.user .msg-avatar { background: var(--stone); border: 1px solid var(--iron); color: var(--mist); }

.msg-bubble { max-width: 78%; padding: 1rem 1.2rem; border-radius: 8px; font-size: 18px; line-height: 1.85; }
.msg.odin .msg-bubble { background: linear-gradient(135deg,rgba(200,168,75,0.06),rgba(200,168,75,0.02)); border: 1px solid rgba(200,168,75,0.2); color: var(--pure); border-top-left-radius: 2px; }
.msg.user .msg-bubble { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); color: var(--mist); border-top-right-radius: 2px; }
.msg-bubble p { margin-bottom: 0.75rem; }
.msg-bubble p:last-of-type { margin-bottom: 0; }

.export-word-btn { display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 0.9rem; padding: 0.5rem 1rem; background: rgba(200,168,75,0.12); border: 1px solid rgba(200,168,75,0.35); border-radius: 4px; color: var(--gold-glow); font-family: var(--font-title); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; transition: all 0.3s; }
.export-word-btn:hover { background: rgba(200,168,75,0.22); border-color: var(--gold); }

.typing-dots { display: flex; gap: 5px; padding: 0.3rem 0; align-items: center; }
.typing-dots span { width: 7px; height: 7px; background: var(--gold-dim); border-radius: 50%; animation: bounce 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

.input-area { padding: 0.8rem 0 1rem; border-top: 1px solid rgba(200,168,75,0.1); display: flex; gap: 0.7rem; align-items: flex-end; }

.input-wrapper { flex: 1; position: relative; display: flex; align-items: flex-end; }

#user-input { width: 100%; background: rgba(255,255,255,0.04); border: 1px solid rgba(200,168,75,0.2); border-radius: 6px; padding: 0.85rem 2.8rem 0.85rem 1rem; color: var(--light); font-family: var(--font-body); font-size: 18px; outline: none; resize: none; min-height: 52px; max-height: 160px; line-height: 1.6; transition: border-color var(--transition); }
#user-input::placeholder { color: var(--iron); }
#user-input:focus { border-color: rgba(200,168,75,0.5); box-shadow: 0 0 0 3px rgba(200,168,75,0.08); }

.send-btn { width: 52px; height: 52px; background: linear-gradient(135deg,var(--gold-dim),var(--gold)); border: none; border-radius: 6px; cursor: pointer; color: var(--void); font-size: 1.2rem; display: flex; align-items: center; justify-content: center; transition: all var(--transition); flex-shrink: 0; }
.send-btn:hover { background: linear-gradient(135deg,var(--gold),var(--gold-glow)); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(200,168,75,0.4); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ─── Bouton micro — superposé dans le textarea ── */
.mic-btn {
  position: absolute;
  right: 0.5rem;
  bottom: 0.7rem;
  width: 26px; height: 26px;
  background: none;
  border: none;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.5; z-index: 2;
  transition: opacity 0.3s;
}
.mic-btn:hover { opacity: 1; }
.mic-btn.listening { opacity: 1; animation: pulse-mic 1s infinite ease-in-out; }
@keyframes pulse-mic { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

/* ─── Actions message ─────────────────────────── */
.msg-actions { display: flex; gap: 0.5rem; margin-top: 0.7rem; flex-wrap: wrap; }

.msg-copy-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; padding: 0.3rem 0.7rem;
  color: var(--ash); font-family: var(--font-body); font-size: 0.78rem;
  cursor: pointer; transition: all 0.3s;
}
.msg-copy-btn:hover { border-color: rgba(200,168,75,0.4); color: var(--gold); }
.msg-copy-btn.copied { border-color: #6ab04c; color: #6ab04c; }

/* ─── Blocs de code ───────────────────────────── */
.code-block {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(200,168,75,0.15);
  border-radius: 6px; overflow: hidden;
  margin: 0.6rem 0; font-size: 0.85rem;
}
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.8rem;
  background: rgba(200,168,75,0.08);
  border-bottom: 1px solid rgba(200,168,75,0.1);
}
.code-lang { font-family: var(--font-title); font-size: 0.65rem; color: var(--gold-dim); letter-spacing: 0.1em; text-transform: uppercase; }
.code-copy-btn { background: none; border: 1px solid rgba(200,168,75,0.25); border-radius: 3px; padding: 0.2rem 0.6rem; color: var(--ash); font-size: 0.72rem; cursor: pointer; transition: all 0.3s; }
.code-copy-btn:hover { border-color: var(--gold); color: var(--gold); }
.code-copy-btn.copied { border-color: #6ab04c; color: #6ab04c; }
.code-block pre { margin: 0; padding: 0.8rem 1rem; overflow-x: auto; scrollbar-width: thin; }
.code-block code { font-family: 'Courier New', Courier, monospace; font-size: 0.83rem; color: #e0d7c0; line-height: 1.6; white-space: pre; }

.welcome-msg { text-align: center; padding: 2rem 1rem; color: var(--ash); font-style: italic; font-size: 1.1rem; line-height: 1.9; }
.welcome-msg .rune-deco { font-size: 2.5rem; color: var(--gold-dim); display: block; margin-bottom: 1rem; opacity: 0.5; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--stone); border-radius: 3px; }
