/* ============================================================
   FRIENDLY AI – Premium Dark Glassmorphism Design System
   ============================================================ */

/* ─── 1. Custom Properties ─────────────────────────────── */
:root {
  --accent-1: #7c3aed;        /* purple */
  --accent-2: #06b6d4;        /* cyan */
  --accent-3: #f472b6;        /* pink */
  --accent-4: #34d399;        /* teal */

  --bg-base:  #0a0a0f;
  --bg-card:  rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-input: rgba(255,255,255,0.06);

  --border:   rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.14);

  --text-primary:   #f1f3f9;
  --text-secondary: #8f96aa;
  --text-muted:     #545b6e;

  --bot-bubble:  rgba(124,58,237,0.15);
  --user-bubble: linear-gradient(135deg, #7c3aed, #06b6d4);

  --sidebar-w: 280px;
  --header-h:  68px;
  --input-h:   88px;

  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  32px;

  --shadow-glow: 0 0 40px rgba(124,58,237,0.25);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);

  --transition: 0.25s ease;
  --spring:     cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── 2. Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ─── 3. Animated Background Blobs ────────────────────── */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  animation: blobFloat 12s ease-in-out infinite alternate;
}
.blob-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #7c3aed, transparent);
  top: -150px; left: -150px;
  animation-delay: 0s;
}
.blob-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #06b6d4, transparent);
  bottom: -100px; right: -100px;
  animation-delay: 4s;
}
.blob-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #f472b6, transparent);
  top: 40%; left: 50%;
  animation-delay: 8s;
}
@keyframes blobFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, -40px) scale(1.1); }
}

/* ─── 4. Utility ───────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── 5. Onboarding Screen ─────────────────────────────── */
.onboarding-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.2) 0%, transparent 60%), var(--bg-base);
  animation: fadeIn 0.6s ease;
}

.onboarding-card {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  animation: slideUp 0.7s var(--spring);
}

/* Avatar Pulse */
.avatar-pulse {
  position: relative;
  width: 100px; height: 100px;
  margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center;
}
.avatar-ring {
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: conic-gradient(#7c3aed, #06b6d4, #f472b6, #7c3aed);
  animation: spin 4s linear infinite;
}
.avatar-ring::before {
  content: '';
  position: absolute; inset: 4px;
  border-radius: 50%;
  background: var(--bg-base);
}
.avatar-img {
  position: relative; z-index: 1;
  width: 80px; height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(124,58,237,0.4), rgba(6,182,212,0.4));
  display: flex; align-items: center; justify-content: center;
}
.bot-emoji { line-height: 1; }

/* ── Bot Avatar Image ── */
.bot-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.onboarding-card h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 32px;
}

.onboarding-form label {
  display: block;
  text-align: left;
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
}

.onboarding-form input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  margin-bottom: 16px;
}
.onboarding-form input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}

.btn-start {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  letter-spacing: 0.5px;
  margin-bottom: 20px;
}
.btn-start:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(124,58,237,0.4);
}
.btn-start:active { transform: translateY(0); }

.onboarding-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── 6. Chat App Layout ───────────────────────────────── */
.chat-app {
  display: flex;
  height: 100dvh;
  position: relative;
  z-index: 1;
}

/* ─── 7. Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(10,10,20,0.7);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0 0 16px 0;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform var(--transition), width var(--transition);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-avatar {
  position: relative;
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.status-dot {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 10px; height: 10px;
  background: var(--accent-4);
  border-radius: 50%;
  border: 2px solid var(--bg-base);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
}

.sidebar-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.online-tag {
  font-size: 0.72rem;
  color: var(--accent-4);
  font-weight: 500;
}

/* User Card */
.user-card {
  margin: 16px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, rgba(244,114,182,0.3), rgba(124,58,237,0.3));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.user-sub { font-size: 0.75rem; color: var(--text-muted); }

/* Sidebar Sections */
.mood-section, .quick-section, .memory-section, .lang-section {
  padding: 16px 16px 8px;
  border-top: 1px solid var(--border);
}

.mood-section h3, .quick-section h3, .memory-section h3, .lang-section h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
}

/* Mood Display */
.mood-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.mood-emoji { font-size: 1.8rem; transition: all 0.5s var(--spring); }
.mood-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.mood-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.mood-bar {
  height: 100%;
  border-radius: 2px;
  width: 50%;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  transition: width 0.6s ease, background 0.6s ease;
}

/* Quick Buttons */
.quick-btn {
  display: block;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
}
.quick-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-1);
  color: var(--text-primary);
  transform: translateX(3px);
}

/* Memory Tags */
.memory-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mem-tag {
  padding: 4px 10px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 20px;
  font-size: 0.72rem;
  color: #c4b5fd;
  font-weight: 500;
}

/* Language Selector */
.lang-select {
  width: 100%;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  transition: all var(--transition);
}
.lang-select:hover {
  border-color: var(--accent-1);
}
.lang-select option {
  background: var(--bg-base);
  color: var(--text-primary);
}

/* Reset Button */
.btn-reset {
  margin: 12px 16px 0;
  padding: 10px;
  width: calc(100% - 32px);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-reset:hover {
  border-color: #f87171;
  color: #f87171;
  background: rgba(248,113,113,0.07);
}

/* ─── 8. Chat Main ─────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Chat Header */
.chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: rgba(10,10,20,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.menu-btn {
  display: none;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.menu-btn:hover { color: var(--text-primary); }

.header-bot {
  display: flex; align-items: center; gap: 12px;
  flex: 1;
}
.header-avatar {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.chat-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-mood-chip {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.5s ease;
}

/* ─── 9. Messages Area ─────────────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar { width: 5px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* Message Bubbles */
.msg-row {
  display: flex;
  gap: 10px;
  animation: msgSlide 0.4s var(--spring);
  max-width: 80%;
}

@keyframes msgSlide {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-row.bot {
  align-self: flex-start;
}

.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 4px;
}
.msg-row.bot .msg-avatar {
  background: transparent;
  overflow: hidden;
}
.msg-row.user .msg-avatar {
  background: linear-gradient(135deg, rgba(244,114,182,0.3), rgba(124,58,237,0.3));
}

.msg-content { display: flex; flex-direction: column; gap: 4px; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.bot .msg-bubble {
  background: var(--bot-bubble);
  border: 1px solid rgba(124,58,237,0.2);
  border-top-left-radius: 4px;
  backdrop-filter: blur(8px);
  color: var(--text-primary);
}

.msg-row.user .msg-bubble {
  background: var(--user-bubble);
  border-top-right-radius: 4px;
  color: white;
}

.msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0 6px;
}
.msg-row.user .msg-time { text-align: right; }

/* Mood badge on bot message */
.mood-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(124,58,237,0.2);
  border-radius: 10px;
  font-size: 0.68rem;
  color: #c4b5fd;
  margin-bottom: 4px;
  width: fit-content;
}

/* ─── 10. Typing Indicator ─────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  animation: fadeIn 0.3s ease;
}
.typing-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bot-bubble);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-1);
  animation: dotBounce 1.4s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; background: var(--accent-2); }
.dot:nth-child(3) { animation-delay: 0.4s; background: var(--accent-3); }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ─── 11. Input Area ───────────────────────────────────── */
.input-area {
  padding: 12px 20px 16px;
  background: rgba(10,10,20,0.8);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap:focus-within {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.input-wrap textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
.input-wrap textarea::placeholder { color: var(--text-muted); }
.input-wrap textarea::-webkit-scrollbar { width: 3px; }
.input-wrap textarea::-webkit-scrollbar-thumb { background: var(--border-2); }

.send-btn {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border: none;
  border-radius: 50%;
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(124,58,237,0.5);
}
.send-btn:active { transform: scale(0.95); }
.send-btn svg { width: 16px; height: 16px; margin-left: 2px; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.input-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ─── 12. Date Separator ───────────────────────────────── */
.date-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-align: center;
}
.date-sep::before, .date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── 13. Welcome Message Special ─────────────────────── */
.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 10px;
  flex: 1;
  min-height: 300px;
}
.welcome-card .wc-icon { font-size: 3.5rem; }
.welcome-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; max-width: 300px; }

/* ─── 14. Keyframes ────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── 15. Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .menu-btn { display: flex; }

  .chat-app::before {
    content: '';
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    backdrop-filter: blur(2px);
  }
  .chat-app.sidebar-open::before { display: block; }

  .msg-row { max-width: 95%; }
  .header-mood-chip { display: none; }
}

/* ─── 16. Mood-based Accent Colors ────────────────────── */
body.mood-happy   .mood-bar { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
body.mood-sad     .mood-bar { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
body.mood-stress  .mood-bar { background: linear-gradient(90deg, #f97316, #ef4444); }
body.mood-angry   .mood-bar { background: linear-gradient(90deg, #ef4444, #dc2626); }
body.mood-neutral .mood-bar { background: linear-gradient(90deg, #7c3aed, #06b6d4); }
