/* ═══════════════════════════════════════
   EARLYSONAR — HARI INTERFACE
   Glass morphism dark violet/indigo
   ═══════════════════════════════════════ */

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-gradient:     linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  --accent-indigo:   rgba(99, 102, 241, 0.85);
  --accent-violet:   rgba(139, 92, 246, 0.85);
  --accent-solid:    #6366f1;
  --glass-bg:        rgba(255, 255, 255, 0.05);
  --glass-border:    rgba(255, 255, 255, 0.10);
  --glass-blur:      blur(16px);
  --text-primary:    rgba(255, 255, 255, 0.92);
  --text-secondary:  rgba(255, 255, 255, 0.55);
  --text-muted:      rgba(255, 255, 255, 0.30);
  --hari-bubble:     rgba(99, 102, 241, 0.15);
  --sophie-bubble:   rgba(139, 92, 246, 0.20);
  --error-color:     rgba(239, 68, 68, 0.80);
  --success-color:   rgba(52, 211, 153, 0.80);
  --font:            -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-sm:       8px;
  --radius-md:       14px;
  --radius-lg:       20px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  overflow: hidden;
}

/* ── GLASS CARD ── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-md);
}

/* ══════════════════════════════
   LOGIN PAGE
   ══════════════════════════════ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 48px 36px;
  text-align: center;
}

.logo-area {
  margin-bottom: 36px;
}

.logo-icon {
  font-size: 3rem;
  color: var(--accent-solid);
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(99,102,241,0.6));
}

.logo-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 0.05em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-group input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  border-color: rgba(99,102,241,0.6);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-group input::placeholder { color: var(--text-muted); }

.error-msg {
  color: var(--error-color);
  font-size: 0.85rem;
  padding: 10px 14px;
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
}

.btn-primary {
  padding: 14px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.02em;
}

.btn-primary:hover  { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.login-footer {
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ══════════════════════════════
   MAIN APP LAYOUT
   ══════════════════════════════ */
body:has(.app-header) {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-radius: 0;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  z-index: 10;
}

.glass-header { backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }

.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.header-logo {
  font-size: 1.6rem;
  color: var(--accent-solid);
  filter: drop-shadow(0 0 12px rgba(99,102,241,0.5));
}

.header-titles  { display: flex; flex-direction: column; }
.header-brand   { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.header-agent   { font-size: 0.75rem; color: var(--text-secondary); }

.status-dot {
  width: 8px; height: 8px;
  background: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(52,211,153,0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.status-text { font-size: 0.8rem; color: var(--text-secondary); }

.btn-logout {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  transition: color 0.2s, border-color 0.2s;
}
.btn-logout:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

/* ── CHAT MAIN ── */
.chat-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  scroll-behavior: smooth;
}

.chat-main::-webkit-scrollbar { width: 4px; }
.chat-main::-webkit-scrollbar-track { background: transparent; }
.chat-main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.chat-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── MESSAGES ── */
.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.sophie-message { flex-direction: row-reverse; }

.message-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}

.hari-message .message-avatar {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  color: #fff;
  box-shadow: 0 0 16px rgba(99,102,241,0.4);
}

.sophie-message .message-avatar {
  background: rgba(139,92,246,0.30);
  color: var(--text-primary);
}

.message-bubble {
  max-width: 72%;
  padding: 14px 18px;
  line-height: 1.6;
  font-size: 0.92rem;
}

.hari-message .message-bubble   { background: var(--hari-bubble); border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px; }
.sophie-message .message-bubble { background: var(--sophie-bubble); border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md); }

/* Markdown dans les réponses Hari */
.hari-message .message-bubble p        { margin-bottom: 8px; }
.hari-message .message-bubble p:last-child { margin-bottom: 0; }
.hari-message .message-bubble strong   { color: #a5b4fc; }
.hari-message .message-bubble em       { color: var(--text-secondary); }
.hari-message .message-bubble code     { background: rgba(99,102,241,0.2); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }
.hari-message .message-bubble ul,
.hari-message .message-bubble ol       { padding-left: 20px; margin: 8px 0; }
.hari-message .message-bubble li       { margin-bottom: 4px; }
.hari-message .message-bubble table    { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.85rem; }
.hari-message .message-bubble th       { background: rgba(99,102,241,0.25); padding: 8px 12px; text-align: left; font-weight: 600; }
.hari-message .message-bubble td       { padding: 8px 12px; border-top: 1px solid var(--glass-border); }
.hari-message .message-bubble blockquote { border-left: 3px solid var(--accent-solid); padding-left: 12px; color: var(--text-secondary); margin: 8px 0; }

.message-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 10px;
  text-align: right;
}

.message-hint { font-size: 0.85rem; color: var(--text-secondary); margin-top: 8px; }

/* ── TYPING INDICATOR ── */
.typing-bubble { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }

.typing-dots { display: flex; gap: 5px; }
.typing-dots span {
  width: 7px; height: 7px;
  background: var(--accent-solid);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.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.6; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

.typing-text { font-size: 0.82rem; color: var(--text-secondary); }

/* ── INPUT FOOTER ── */
.input-footer {
  padding: 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font);
  resize: none;
  max-height: 150px;
  line-height: 1.5;
}
textarea::placeholder { color: var(--text-muted); }

.btn-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 0 16px rgba(99,102,241,0.4);
}
.btn-send:hover      { opacity: 0.9; transform: scale(1.05); }
.btn-send:active     { transform: scale(0.96); }
.btn-send:disabled   { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-send svg        { width: 16px; height: 16px; color: #fff; }

.input-disclaimer {
  max-width: 800px;
  margin: 8px auto 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .message-bubble    { max-width: 88%; }
  .app-header        { padding: 12px 16px; }
  .btn-logout        { display: none; }
}
