/* ============================================
   Mnémo — chat workspace (paper + ink + accent)
   Inspiré de Linear / Things / Jarvisagence
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --paper:        #FAF8F3;
  --paper-2:      #F1EEE6;
  --paper-3:      #E8E4D9;
  --ink:          #1A1A1A;
  --ink-soft:     #4A4A44;
  --ink-dim:      #8A8680;
  --accent:       #C0684D;    /* terracotta chaleureux */
  --accent-soft:  #A85A41;
  --accent-tint:  rgba(192, 104, 77, 0.08);
  --border:       rgba(26, 26, 26, 0.08);
  --border-strong: rgba(26, 26, 26, 0.14);
  --shadow-sm:    0 1px 2px rgba(26, 26, 26, 0.04);
  --shadow:       0 2px 12px rgba(26, 26, 26, 0.06);
  --shadow-lg:    0 12px 48px rgba(26, 26, 26, 0.12);
  --radius:       10px;
  --radius-sm:    6px;
  --recording:    #C83E4D;

  --font:         'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.55;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- LOGIN ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, rgba(192, 104, 77, 0.06), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(107, 91, 149, 0.05), transparent 45%),
    var(--paper);
}
.login-card {
  background: #fff;
  padding: 44px 40px;
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.login-card p {
  color: var(--ink-dim);
  font-size: 14px;
  margin-bottom: 24px;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.login-card button:hover { background: var(--accent); }
.login-card .err {
  color: var(--recording);
  font-size: 13px;
  margin-top: 10px;
}

/* ---------- APP LAYOUT ---------- */

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

/* ---------- SIDEBAR ---------- */

.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 6px 4px;
}
.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand .tenant {
  font-size: 12px;
  color: var(--ink-dim);
  font-weight: 500;
}
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 18px 0 20px;
}
.btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.12s;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:hover { background: var(--paper-3); }
.btn.primary {
  background: var(--ink);
  color: var(--paper);
  justify-content: center;
  padding: 10px 12px;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent); }

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  padding: 0 8px;
  margin-bottom: 6px;
  font-weight: 600;
}

.recent-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
}
.recent-list li {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-list li:hover { background: var(--paper-3); color: var(--ink); }

.sidebar-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .btn { font-size: 12.5px; color: var(--ink-dim); }

/* ---------- MAIN ---------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  overflow: hidden;
}

.chat {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 32px 32px 8px;
}
.chat-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Custom scrollbar */
.chat::-webkit-scrollbar,
.recent-list::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-track,
.recent-list::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb,
.recent-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.chat::-webkit-scrollbar-thumb:hover,
.recent-list::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }

.welcome {
  text-align: center;
  color: var(--ink-soft);
  margin: 12vh auto 0;
  max-width: 520px;
}
.welcome h2 {
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.welcome p { font-size: 15px; line-height: 1.6; }
.welcome-hints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 28px;
  text-align: left;
}
.welcome-hint {
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.welcome-hint b { color: var(--ink); display: block; margin-bottom: 4px; font-weight: 600; }

/* Messages */

.msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: msg-in 0.22s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg .who {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.msg.user .who { text-align: right; color: var(--accent); }
.msg .bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 85%;
}
.msg.assistant .bubble {
  background: #fff;
  color: var(--ink);
  align-self: flex-start;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.msg.user .bubble {
  background: var(--ink);
  color: var(--paper);
  align-self: flex-end;
  border: 1px solid var(--ink);
}
.msg .bubble .typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}
.msg .bubble .typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-dim);
  animation: dotBounce 1.2s infinite;
}
.msg .bubble .typing-dots span:nth-child(2) { animation-delay: .15s; }
.msg .bubble .typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dotBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

/* Attachments inline dans le message user */
.attachments-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.attachment-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--paper);
  font-size: 12.5px;
  max-width: 240px;
}
.attachment-tile img {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}
.attachment-tile .icon {
  width: 36px; height: 36px;
  border-radius: 5px;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.attachment-tile .icon svg { width: 18px; height: 18px; }
.attachment-tile .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.msg .tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--ink-dim);
}
.msg .tools .pill {
  background: var(--paper-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
}

/* Markdown dans les bulles */
.msg .bubble h1, .msg .bubble h2, .msg .bubble h3 {
  font-weight: 600; letter-spacing: -0.01em;
  margin: 12px 0 4px;
}
.msg .bubble h1 { font-size: 18px; }
.msg .bubble h2 { font-size: 16px; }
.msg .bubble h3 { font-size: 14.5px; }
.msg .bubble p { margin: 4px 0; }
.msg .bubble code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--paper-2);
  padding: 1px 5px;
  border-radius: 3px;
}
.msg.user .bubble code { background: rgba(255,255,255,0.12); }
.msg .bubble ul, .msg .bubble ol {
  padding-left: 22px;
  margin: 4px 0;
}
.msg .bubble li { margin: 2px 0; }
.msg .bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--ink-soft);
  margin: 6px 0;
  font-style: italic;
}

/* ---------- COMPOSER ---------- */

.composer-wrap {
  padding: 12px 32px 20px;
  background: linear-gradient(to bottom, rgba(250,248,243,0) 0%, var(--paper) 30%);
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 6px 8px;
}
.attachments-preview .chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  box-shadow: var(--shadow-sm);
}
.attachments-preview .chip img {
  width: 28px; height: 28px;
  object-fit: cover;
  border-radius: 999px;
}
.attachments-preview .chip .icon {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--paper-2);
  display: flex; align-items: center; justify-content: center;
}
.attachments-preview .chip .icon svg { width: 14px; height: 14px; color: var(--ink-soft); }
.attachments-preview .chip .remove {
  color: var(--ink-dim);
  font-size: 15px;
  padding: 0 4px;
  line-height: 1;
}
.attachments-preview .chip .remove:hover { color: var(--recording); }

.composer-main {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 8px 8px 12px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-main:focus-within {
  border-color: var(--ink);
  box-shadow: 0 4px 20px rgba(26,26,26,0.08);
}
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  min-height: 22px;
  max-height: 200px;
  padding: 8px 4px;
  line-height: 1.55;
  font-size: 15px;
  color: var(--ink);
}
.composer textarea::placeholder { color: var(--ink-dim); }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.mic-btn.is-recording {
  background: var(--recording);
  color: #fff;
  animation: mic-pulse 1s infinite;
}
.mic-btn.is-locked { background: var(--accent); color: #fff; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 62, 77, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(200, 62, 77, 0); }
}

.send-btn {
  background: var(--ink);
  color: var(--paper);
  padding: 8px 14px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent); }
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.send-btn svg { width: 14px; height: 14px; }

/* Rec indicator */
.rec-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--recording);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  margin: 0 6px 8px;
}
.rec-indicator.visible { display: flex; }
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  animation: recBlink 0.8s infinite;
}
@keyframes recBlink { 0%,100%{opacity:1} 50%{opacity:.3} }
.rec-text { flex: 1; font-weight: 500; }
.rec-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0.85;
}
.rec-hint {
  font-size: 11.5px;
  color: var(--ink-dim);
  padding: 0 12px 4px;
  text-align: center;
}

/* ---------- F11 — Dark mode ---------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #1A1A1A;
    --paper-2: #232323;
    --paper-3: #2D2D2D;
    --ink:     #E8E4DD;
    --ink-soft: #BDB9B1;
    --ink-dim:  #8A8680;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --accent: #D4896B;
  }
}
:root[data-theme="dark"] {
  --paper:   #1A1A1A;
  --paper-2: #232323;
  --paper-3: #2D2D2D;
  --ink:     #E8E4DD;
  --ink-soft: #BDB9B1;
  --ink-dim:  #8A8680;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --accent: #D4896B;
}

/* Corrections dark mode : bulles, composer, login, scrollbar */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .msg.assistant .bubble,
  :root:not([data-theme="light"]) .composer-main,
  :root:not([data-theme="light"]) .attachments-preview .chip,
  :root:not([data-theme="light"]) .login-card { background: var(--paper-2); }

  :root:not([data-theme="light"]) .msg.user .bubble { background: var(--ink-soft); border-color: var(--ink-soft); color: var(--paper); }

  :root:not([data-theme="light"]) .composer-main { background: var(--paper-2); }

  :root:not([data-theme="light"]) .login-body { background: var(--paper); }
}
:root[data-theme="dark"] .msg.assistant .bubble,
:root[data-theme="dark"] .composer-main,
:root[data-theme="dark"] .attachments-preview .chip,
:root[data-theme="dark"] .login-card { background: var(--paper-2); }

:root[data-theme="dark"] .msg.user .bubble { background: var(--ink-soft); border-color: var(--ink-soft); color: var(--paper); }

:root[data-theme="dark"] .login-body { background: var(--paper); }

/* ---------- F12 — Bouton mic prominent ---------- */

.mic-btn-prominent {
  width: 42px;
  height: 42px;
  background: var(--paper-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: background 0.12s, color 0.12s, transform 0.12s;
}
.mic-btn-prominent svg { width: 20px; height: 20px; }
.mic-btn-prominent:hover { background: var(--paper-3); color: var(--ink); transform: scale(1.05); }
.mic-btn-prominent.is-recording {
  background: var(--recording);
  color: #fff;
  border-color: var(--recording);
  animation: mic-pulse 1s infinite;
}
.mic-btn-prominent.is-locked {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- F13 — Modal note viewer ---------- */

.note-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 0.15s ease-out;
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.note-modal-card {
  max-width: 720px;
  width: 92%;
  max-height: 82vh;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-slide-in 0.15s ease-out;
}
@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.note-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.note-modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.note-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.note-modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.note-modal-close:hover { background: var(--paper-2); color: var(--ink); }
.note-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--ink);
  color: var(--paper);
  transition: background 0.12s;
}
.note-modal-btn:hover { background: var(--accent); }
.note-modal-btn.secondary {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--border);
}
.note-modal-btn.secondary:hover { background: var(--paper-3); }

/* ---------- F14 — Obsidian loader ---------- */

.obs-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--paper-2);
  z-index: 10;
}
.obs-loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: obs-spin 0.75s linear infinite;
}
@keyframes obs-spin {
  to { transform: rotate(360deg); }
}
.obs-loader-text {
  font-size: 13px;
  color: var(--ink-dim);
  font-weight: 500;
}

/* ---------- F15 — Splitter redimensionnable ---------- */

.ws-splitter {
  width: 4px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--border);
  transition: background 0.15s;
  position: relative;
  z-index: 5;
}
.ws-splitter:hover,
.ws-splitter.dragging { background: var(--accent); }

/* ---------- Responsive ---------- */

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .chat { padding: 20px 16px 8px; }
  .composer-wrap { padding: 12px 16px 16px; }
  .welcome-hints { grid-template-columns: 1fr; }
}
