:root {
  --bg-dark: #121212;
  --bg-panel: #1e1e1e;
  --user-msg: #056162; 
  --bot-msg: #2d2d2d;
  --text-main: #f1f1f1;
  --text-muted: #a0a0a0;
  --accent: #00a884; 
  --accent-disabled: #005a46;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --border: rgba(255, 255, 255, 0.08);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.chat-container {
  width: 100%;
  max-width: 600px;
  height: 100%;
  display: flex;
  flex-direction: column;
  /* background-color: var(--bg-panel); */
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden; /* Added to keep drawer inside and hide it when closed */
}

.chat-container.hidden {
  display: none !important;
}

/* Onboarding Modal System */
.onboarding-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: var(--bg-dark);
  z-index: 1000;
  display: flex; justify-content: center; align-items: center;
  transition: opacity 0.5s ease-out;
}
.onboarding-overlay.hidden {
  opacity: 0; pointer-events: none;
}
.onboarding-card {
  background: var(--bg-panel);
  padding: 30px;
  border-radius: 16px;
  width: 90%; max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  animation: slideUp 0.4s ease-out;
}
@keyframes slideUp { from {opacity: 0; transform: translateY(20px);} to {opacity: 1; transform: translateY(0);}}
.onboarding-card.hidden { display: none; }
.onboarding-card h2 { font-weight: 600; margin-bottom: 10px; color: #fff; }
.onboarding-card p { color: var(--text-muted); margin-bottom: 20px; font-size: 0.95rem; }
.onboarding-card input {
  width: 100%; padding: 14px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(0,0,0,0.2); color: white; display: block; margin-bottom: 16px; font-size: 1rem;
  outline: none; transition: border-color 0.2s;
}
.onboarding-card input:focus { border-color: var(--accent); }
.mood-options { display: flex; flex-direction: column; gap: 10px; }
.mood-btn {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  padding: 14px; border-radius: 8px; color: white;
  cursor: pointer; font-size: 1rem; transition: 0.2s;
  font-family: inherit; font-weight: 500;
}
.mood-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); }

.hobby-btn {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 20px; color: white;
  cursor: pointer; font-size: 0.95rem; transition: 0.2s;
  font-family: inherit; font-weight: 500;
}
.hobby-btn:hover { background: rgba(255,255,255,0.1); }
.hobby-btn.selected {
  background: var(--accent); border-color: var(--accent); color: white;
}

/* Start Over Button */
#reset-onboard-btn {
   background: transparent; color: var(--text-muted);
   border: 1px solid var(--border);
   padding: 6px 12px; border-radius: 6px; font-size: 0.8rem;
   cursor: pointer; transition: 0.2s; font-family: inherit;
}
#reset-onboard-btn:hover { color: white; border-color: var(--accent); }

@media (min-width: 600px) {
  .chat-container { 
      border-radius: 12px; 
      height: 95vh; 
      border: 1px solid var(--border);
  }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  padding: 16px;
  background-color: #202020;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  position: relative;
  z-index: 10;
}
.profile-pic {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.header-info h1 { font-size: 1.1rem; font-weight: 500; }
.status { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; margin-top: 2px;}
.status-dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; display: inline-block; }

/* Chat Space */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: #0b141a; 
  background-image: linear-gradient(rgba(11, 20, 26, 0.95), rgba(11, 20, 26, 0.95)), url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
  background-size: contain;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* Messages */
.message { display: flex; flex-direction: column; max-width: 85%; animation: slideIn 0.3s ease-out; }
.message.user { align-self: flex-end; }
.message.bot { align-self: flex-start; }

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

.bubble {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.message.user .bubble { background-color: var(--user-msg); border-top-right-radius: 4px; color: #fff;}
.message.bot .bubble { background-color: var(--bot-msg); border-top-left-radius: 4px; color: #e9edef; box-shadow: 0 1px 2px rgba(0,0,0,0.2);}

/* Metadata Badges */
.meta-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.75rem; flex-wrap: wrap; }
.badge { padding: 4px 8px; border-radius: 6px; font-weight: 500; background: rgba(255,255,255,0.05); }
.badge.risk-low { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.badge.risk-medium { color: #facc15; background: rgba(250, 204, 21, 0.1); }
.badge.risk-high { color: #f87171; background: rgba(248, 113, 113, 0.1); }

/* Suggestions: clickable chip-style buttons below the bubble */
.suggestion-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.suggestion-btn {
  background: rgba(0, 168, 132, 0.08);
  color: var(--accent);
  border: 1px solid rgba(0, 168, 132, 0.35);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.suggestion-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 168, 132, 0.25);
}

/* Distress Alert */
.distress-alert {
  margin-top: 12px;
  background: var(--danger-bg);
  border-left: 4px solid var(--danger);
  padding: 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
}
.distress-alert strong { color: var(--danger); display: block; margin-bottom: 4px;}

/* Action Items */
.action-btn {
  margin-top: 12px;
  width: 100%;
  background: #10b981;
  border: none;
  padding: 12px;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}
.action-btn:hover { opacity: 0.9; }

/* Insight Box */
.insight-box {
  background: #1f2937;
  color: #f8fafc;
  padding: 14px 16px;
  border-radius: 12px;
  margin-top: 8px;
  font-size: 0.9rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 4px solid #3b82f6; 
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  line-height: 1.4;
  animation: slideUp 0.4s ease-out;
}

/* Interactive Timers */
.breathing-mode {
  padding: 20px;
  text-align: center;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  margin-top: 10px;
}
.timer-circle {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 3px solid #10b981;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
  font-size: 1.2rem; font-weight: 600; color: #10b981;
  animation: pulse 4s infinite ease-in-out;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); box-shadow: 0 0 15px rgba(16, 185, 129, 0.4); } }

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; padding: 14px 18px; background: var(--bot-msg); border-radius: 12px; border-top-left-radius: 4px; width: fit-content; align-self: flex-start;}
.typing-dots span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: bounce 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Input Field */
.chat-input-area {
  padding: 16px;
  background-color: #202020;
  display: flex;
  gap: 12px;
  align-items: center;
}
#message-input {
  flex: 1;
  background: #2a2f32;
  border: none;
  padding: 14px 18px;
  border-radius: 24px;
  color: white;
  font-size: 0.95rem;
  outline: none;
}
#message-input:focus { background: #33383b; }
#send-btn {
  background: var(--accent);
  border: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; cursor: pointer; transition: 0.2s;
}
#send-btn svg { width: 20px; height: 20px; transform: translateX(-1px); }
#send-btn:disabled { background: var(--accent-disabled); color: rgba(255,255,255,0.4); cursor: not-allowed; }

/* Icon Button (Hamburger/Close) */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  border-radius: 50%;
  position: relative;
  z-index: 20; /* Ensure it stays above other header elements */
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

/* Side Drawer */
.side-drawer {
  position: absolute;
  top: 0; right: 0;
  width: 280px; height: 100%;
  background: var(--bg-panel);
  z-index: 2000;
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  box-shadow: -5px 0 15px rgba(0,0,0,0.5);
  border-left: 1px solid var(--border);
  transform: translateX(100%); /* Start fully hidden to the right */
}
.side-drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.drawer-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-section { margin-bottom: 30px; }
.drawer-section h4 { 
  font-size: 0.85rem; 
  color: var(--accent); 
  text-transform: uppercase; 
  letter-spacing: 1px;
  margin-bottom: 15px;
}

.menu-quick-actions { display: flex; flex-direction: column; gap: 10px; }
.menu-action-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: white;
  padding: 12px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
}
.menu-action-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); }

.insight-content {
  background: rgba(0,0,0,0.2);
  padding: 15px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e9edef;
  border-left: 3px solid var(--accent);
}

/* Overlay for Drawer */
.drawer-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.drawer-overlay.visible { opacity: 1; pointer-events: auto; }

/* Initial Quick Actions (Big Buttons) */
.initial-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  padding: 20px;
  max-width: 450px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn 0.5s ease-out;
}
.initial-actions.hidden { display: none; }

.big-action-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.big-action-btn:hover {
  transform: translateY(-5px);
  background: #252525;
  border-color: var(--accent);
}
.big-action-btn .emoji { font-size: 2rem; }
.big-action-btn .label { font-size: 0.95rem; font-weight: 500; color: white; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Mobile-specific adjustments */
@media (max-width: 600px) {
  .chat-input-area {
    margin-bottom: 50px;
  }
}
