:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --muted: #8b98a9;
  --primary: #0F6B6B;
  --accent: #20b28a;
  --text: #1a1d20;
  --btn-bg: #0F6B6B;
  --btn-bg-hover: #0b5a5a;
  --radius: 16px;
  --shadow: 0 10px 30px -5px rgba(15, 107, 107, 0.08), 0 4px 10px -3px rgba(15, 107, 107, 0.04);
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.2);
  --mono: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 300ms cubic-bezier(0.25, 0.8, 0.25, 1);
  --border-color: rgba(0, 0, 0, 0.08);
}

/* Auto dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #16191f;
    --muted: #727b88;
    --text: #e2e8f0;
    --glass: rgba(22, 25, 31, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.8), 0 4px 10px rgba(0, 0, 0, 0.4);
    --border-color: rgba(255, 255, 255, 0.08);
    --primary: #158f8f;
    --btn-bg: #158f8f;
    --btn-bg-hover: #1cbfbf;
  }
}

.theme-dark {
  --bg: #0f1115;
  --card: #16191f;
  --muted: #727b88;
  --text: #e2e8f0;
  --glass: rgba(22, 25, 31, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.8), 0 4px 10px rgba(0, 0, 0, 0.4);
  --border-color: rgba(255, 255, 255, 0.08);
  --primary: #158f8f;
  --btn-bg: #158f8f;
  --btn-bg-hover: #1cbfbf;
}

.theme-light {
  --bg: #f4f6f8;
  --card: #ffffff;
  --muted: #8b98a9;
  --text: #1a1d20;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.2);
  --shadow: 0 10px 30px -5px rgba(15, 107, 107, 0.08), 0 4px 10px -3px rgba(15, 107, 107, 0.04);
  --border-color: rgba(0, 0, 0, 0.08);
  --primary: #0F6B6B;
  --btn-bg: #0F6B6B;
  --btn-bg-hover: #0b5a5a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* Header */
header {
  position: relative;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: var(--shadow);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 48px;
  width: auto;
  transition: transform 0.3s ease;
}

.logo-img:hover {
  transform: scale(1.05);
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.brand .title {
  font-weight: 700;
  font-size: 16px;
}

.brand .subtitle {
  font-size: 12px;
  color: var(--muted);
}

nav.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

nav.header-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 12px;
  transition: var(--transition);
  font-weight: 600;
  font-size: 14px;
}

nav.header-nav a:hover {
  background: var(--border-color);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: var(--btn-bg);
  color: white;
  font-weight: 700;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(15, 107, 107, 0.2);
  text-decoration: none;
}

/* Citations & Bibliography */
.citation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 107, 107, 0.15);
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin: 0 2px;
    vertical-align: super;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(15, 107, 107, 0.3);
    text-decoration: none !important;
}

.theme-dark .citation-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    border-color: rgba(255, 255, 255, 0.2);
}

.citation-badge:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Bibliography section tweaks */
.msg.assistant h3 {
    font-size: 1.1rem;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.msg.assistant ul, .msg.assistant ol {
    padding-left: 20px;
    margin-bottom: 16px;
}

.msg.assistant li {
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 107, 107, 0.3);
  opacity: 0.95;
}

.btn.secondary {
  background: #6c757d;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Main Layout Split */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
  
.chat-page .main-wrapper {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar behavior */
.sidebar.collapsed {
  width: 80px !important;
}

.sidebar.collapsed ~ .main-wrapper,
html.sidebar-is-collapsed .main-wrapper {
  margin-left: 80px !important;
}

/* Hide elements when collapsed */
.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .conv-row a,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .user-dropdown .sidebar-text,
.sidebar.collapsed .btn span {
  display: none !important;
}

.sidebar.collapsed .btn {
  padding: 10px !important;
  width: 48px !important;
  margin: 0 auto 24px !important;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar.collapsed .brand-wrapper {
  justify-content: center;
  width: 100%;
}

.sidebar.collapsed .brand-wrapper .logo-full { 
  display: none !important; 
}

.sidebar.collapsed .brand-wrapper .logo-icon { 
  display: block !important; 
}

.sidebar.collapsed .sidebar-toggle {
    margin-top: 5px;
}



.brand-text-btn {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(15, 107, 107, 0.08);
  color: var(--primary);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

[data-theme="dark"] .brand-text-btn {
  background: rgba(255, 255, 255, 0.1);
}

.brand-text-btn:hover {
  background: rgba(15, 107, 107, 0.12);
  transform: translateY(-1px);
}

[data-theme="dark"] .brand-text-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}


.sidebar-btn-new {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 4px; /* Matches other items gap */
}

.sidebar-btn-new:hover {
  background: rgba(15, 107, 107, 0.08);
}

.sidebar.collapsed .sidebar-btn-new {
  justify-content: center;
  padding: 10px 0 !important;
  width: 100% !important;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 0;
  opacity: 0.5;
}

.user-plan-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  opacity: 0.9;
}




/* Global Sidebar tweaks */
.sidebar {
  width: 280px;
  background: var(--card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 20px 16px;
}

/* Header - Only for non-auth or mobile */
header.top-navbar {
    display: none; /* Hidden by default for auth users */
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 50;
    background: var(--card);
    padding: 12px 20px;
}

@media (max-width: 768px) {
    header.top-navbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
}

/* Copilot Style Home */
.copilot-container {
    max-width: 800px;
    margin: 80px auto;
    padding: 20px;
    text-align: center;
    animation: slideUpFade 0.6s ease;
}

.copilot-greeting {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.copilot-input-area {
    background: var(--card);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 40px;
    transition: all 0.3s ease;
}

.copilot-input-area:focus-within {
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(15, 107, 107, 0.1);
}

.copilot-textarea {
    width: 100%;
    border: none !important;
    background: transparent !important;
    font-size: 1.1rem;
    padding: 12px 8px;
    resize: none;
    min-height: 50px;
    outline: none !important;
    box-shadow: none !important;
}

.copilot-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.pill-group {
    display: flex;
    gap: 8px;
}

.control-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 12px;
    background: rgba(15, 107, 107, 0.05);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.control-pill:hover {
    background: rgba(15, 107, 107, 0.1);
}

.control-pill.active {
    background: var(--primary);
    color: white;
}

.btn-send {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-send:hover {
    transform: scale(1.1);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 107, 107, 0.15);
  transform: translateY(-1px);
}

/* Base keyframes for entry */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes springIn {
  0% { opacity: 0; transform: scale(0.9) translateY(10px); }
  60% { opacity: 1; transform: scale(1.02) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* =========================================
   VetiA Chat Area (Full Page)
   ========================================= */

.chat-wrap {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px; /* Standardized width */
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scroll from absolute children */
  padding: 24px 16px;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.03);
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  width: 100%;
}

.main-wrapper {
  margin-left: 280px; /* Offset for fixed sidebar */
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile keyboard compatibility */
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  min-width: 0; 
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(15, 107, 107, 0.3); /* increased visibility from 0.1 to 0.3 */
    border-radius: 10px;
    transition: background 0.3s;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 107, 107, 0.5); /* increased hover visibility from 0.4 to 0.5 */
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 107, 107, 0.3) transparent;
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: auto; /* changed from 100% to auto to allow content growth and scroll */
  position: relative;
}

@media (max-width: 1024px) {
  .main-wrapper {
    margin-left: 0;
  }
}

.conversation-item {
  display: block;
  padding: 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s;
  margin-bottom: 4px;
}

.conversation-item:hover,
.conversation-item.active {
  background: rgba(15, 107, 107, 0.08);
}

/* Copilot-style Input Area */
.copilot-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-left: 280px; /* Sidebar default width */
    background: transparent;
    z-index: 1100;
    transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    justify-content: center;
}

/* Internal wrapper to ensure true centering of its children */
.input-centered-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    pointer-events: auto; /* Re-enable clicks inside the wrapper */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Sidebar Collapsed - Reduce Offset */
.sidebar-is-collapsed .copilot-input-container {
    padding-left: 80px;
}

/* Mobile - Remove Offset Completely */
@media (max-width: 768px) {
    .copilot-input-container {
        padding-left: 0 !important;
        padding-bottom: 12px;
    }
    .input-centered-wrapper {
        padding: 0 16px;
    }
}

.sidebar.collapsed + .main-wrapper .copilot-input-container {
    padding-left: 80px;
}

@media (max-width: 1024px) {
    .copilot-input-container {
        padding-left: 15px; /* Tiny offset for mobile aesthetics */
        padding-right: 15px;
        padding-bottom: 20px;
    }
}

.copilot-input-area {
    width: 100%;
    max-width: 800px;
    background: var(--card);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
    pointer-events: auto; /* Re-enable pointer events for the form */
}

.copilot-input-area:focus-within {
    border-color: var(--primary);
    box-shadow: 0 10px 45px rgba(15, 107, 107, 0.12);
}

.animate-fade-in-up {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.copilot-textarea {
    width: 100%;
    border: none !important;
    background: transparent !important;
    font-size: 15px;
    padding: 10px 8px;
    resize: none;
    outline: none !important;
    color: var(--text);
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    box-shadow: none !important;
    transform: none !important;
}

.copilot-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.btn-send-circular {
    background: var(--primary);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
}

.btn-send-circular:hover {
    transform: scale(1.1);
    background: var(--accent);
}

.btn-send-circular:active {
    transform: scale(0.95);
}

.btn-send-circular svg {
    margin-left: 2px;
}
.conv-row.active .conversation-item {
  background: rgba(15, 107, 107, 0.06);
  font-weight: 500;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg {
  max-width: 82%;
  padding: 16px 20px;
  border-radius: 20px;
  line-height: 1.6;
  font-size: 15px;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
  animation: springIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  will-change: transform, opacity;
  overflow-wrap: break-word; /* Back to standard to prevent aggressive anywhere-splitting */
  word-break: normal !important; /* Forces words like 'en' to stay together */
}

.msg a {
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 20px -6px rgba(15, 107, 107, 0.3);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.msg.assistant a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  word-break: break-all; /* Links break anywhere if too long */
}

.msg.assistant a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* Animations */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* Dropdowns */
.dropdown-menu {
  position: absolute;
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  padding: 8px;
  min-width: 180px;
  display: none;
  z-index: 10000; /* Extremely high to ensure it stays on top */
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Sidebar Specific Dropdowns: Must open strictly LEFT to avoid any clipping */
.sidebar .dropdown-menu {
  right: 35px; /* Offset to clear the dots button */
  left: auto;
  margin-top: 10px;
  min-width: 150px; /* Compact width for 280px sidebar */
  width: max-content;
  z-index: 10001;
}

.dropdown-menu.show {
  display: block;
  animation: scaleIn 0.2s ease;
}

.dropdown-item {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile */
@media (max-width: 768px) {

  /* Mobile Menu Button */
  .mobile-menu-btn {
    background: var(--card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    display: none;
    /* Default hidden */
  }

  .mobile-menu-btn:hover {
    background: var(--primary);
    color: white;
  }

  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    z-index: 1000;
    height: 100vh;
    width: 280px !important;
    min-width: 280px !important;
    left: 0;
    top: 0;
    background: var(--card);
  }

  .sidebar.active {
    transform: translateX(0);
    box-shadow: 10px 0 50px rgba(0,0,0,0.5);
  }

  .chat-area {
    margin-left: 0 !important;
    width: 100%;
  }

  .mobile-menu-btn {
    display: flex !important;
  }
}

/* Utilities */
.text-danger {
  color: #dc3545;
}

.text-danger:hover {
  background: rgba(220, 53, 69, 0.1) !important;
}

/* User Dropdown */
.user-dropdown-btn,
.user-dropup-btn,
.user-header-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--muted);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: var(--transition);
}

.user-dropdown-btn:hover,
.user-dropup-btn:hover,
.user-header-btn:hover {
  background: rgba(15, 107, 107, 0.06);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.dropdown-arrow {
  font-size: 8px;
  opacity: 0.6;
  margin-left: 4px;
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  min-width: 200px;
  z-index: 1000;
  overflow: hidden;
  border: 1px solid var(--muted);
}

.user-dropdown-menu a,
.user-dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: background 0.2s;
}

.user-dropdown-menu a:hover,
.user-dropdown-menu button:hover {
  background: rgba(15, 107, 107, 0.08);
}

.dropdown-divider {
  border-top: 1px solid var(--muted);
  margin: 4px 0;
  opacity: 0.3;
}

.logout-btn {
  color: #ef4444 !important;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1) !important;
}

.theme-label-dropdown {
  margin-left: auto;
  opacity: 0.7;
}

/* Upload Progress Bar */
.upload-status-container {
  padding: 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.upload-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.upload-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.upload-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* =========================================
   Dynamic Animations & Micro-Interactions
   ========================================= */

/* --- Logo Pulse --- */
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 107, 107, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(15, 107, 107, 0); }
}

/* --- Logo Animation --- */
.logo-img {
  filter: drop-shadow(0 0 0 rgba(15, 107, 107, 0));
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.logo-img:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 4px 12px rgba(15, 107, 107, 0.3));
}

.logo {
  animation: logoPulse 3s ease-in-out infinite;
  transition: transform 0.3s ease;
}

/* --- Conversation Item Hover Slide --- */
.conversation-item {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  transform: translateX(0);
  position: relative;
}

.conversation-item:hover {
  transform: translateX(6px);
  background: rgba(15, 107, 107, 0.08);
}

.conv-row {
  position: relative;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
}

.conv-row.active .conversation-item {
  border-left: 3px solid var(--primary);
  padding-left: 10px;
  background: rgba(15, 107, 107, 0.08);
  font-weight: 600;
}

.trigger-menu {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.2rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}

.conv-row:hover .trigger-menu, 
.conv-row.active .trigger-menu {
  opacity: 1;
}

/* --- Button Press Effect --- */
.btn:active {
  transform: translateY(0) scale(0.97);
  transition: transform 0.1s;
}

/* --- Chat Form Focus Glow --- */
#chatForm:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 107, 0.12), var(--shadow);
}

/* --- Message Hover Lift --- */
.msg:hover {
  transform: translateY(-2px);
  transition: transform 0.25s ease;
}

.msg.user:hover {
  box-shadow: 0 12px 28px -8px rgba(15, 107, 107, 0.4);
}

.msg-wrapper.assistant {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: var(--card);
}

.msg-wrapper.assistant .msg.assistant {
  margin-bottom: 0;
  max-width: calc(100% - 48px);
}

.msg.assistant:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* --- Copy Button Animation --- */
.copy-btn {
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.copy-btn:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.copy-btn:active {
  transform: scale(0.95) !important;
}

/* --- Suggestion Button Entrance --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestion-btn {
  background: var(--card);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
  box-shadow: var(--shadow);
  opacity: 1;
  transition: all 0.3s ease;
  max-width: 100%;
  text-align: left;
  line-height: 1.4;
}

.theme-dark .suggestion-btn {
  border-color: var(--border-color);
}
@media (prefers-color-scheme: dark) {
  .suggestion-btn {
    border-color: var(--border-color);
  }
}

.suggestion-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.suggestion-btn:nth-child(1) { animation-delay: 0.05s; }
.suggestion-btn:nth-child(2) { animation-delay: 0.1s; }
.suggestion-btn:nth-child(3) { animation-delay: 0.15s; }
.suggestion-btn:nth-child(4) { animation-delay: 0.2s; }
.suggestion-btn:nth-child(5) { animation-delay: 0.25s; }

/* --- Suggestion bar: prevent flex collapse --- */
#suggestion-bar {
  min-height: 40px;
  flex: 0 0 auto;
  overflow: visible;
  display: flex;
  flex-wrap: wrap; /* Ensure buttons wrap in desktop view */
  gap: 10px;
  padding: 4px 0;
}

/* --- Suggestion buttons: stack vertically on mobile --- */
@media (max-width: 768px) {
  #suggestion-bar {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 0 4px;
    min-height: 40px !important;
    flex: 0 0 auto !important;
    overflow: visible !important;
  }
  .messages#messages-box {
    padding-bottom: 150px !important;
  }
  .suggestion-btn {
    width: 100%;
    font-size: 13px;
  }
}

/* --- Scrollbar Styling --- */
.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(15, 107, 107, 0.2);
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 107, 107, 0.4);
}

/* --- User Avatar Hover --- */
.user-avatar {
  transition: all 0.3s ease;
}

.user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(15, 107, 107, 0.2);
}

/* --- Dropdown Slide-In --- */
.user-dropdown-menu.show {
  display: block;
  animation: slideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Upload Progress Bar Shimmer --- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.upload-bar {
  background: linear-gradient(90deg, var(--primary) 25%, var(--accent) 50%, var(--primary) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* --- Typing Indicator Enhanced --- */
@keyframes typingPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

.dot {
  animation: typingPulse 1.4s ease-in-out infinite;
}

/* --- Mobile Sidebar Slide with Blur --- */
@media (max-width: 768px) {
  .sidebar.active {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.3);
  }
}

/* --- Send Button Icon Spin on Hover --- */
#sendBtn:hover svg {
  transform: rotate(15deg) scale(1.1);
  transition: transform 0.3s ease;
}

/* --- Delete Modal Backdrop Blur --- */
#deleteModal {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#deleteModal > div {
  animation: springIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* --- Staggered Message Animation Delays (page load) --- */
.msg:nth-child(1)  { animation-delay: 0s; }
.msg:nth-child(2)  { animation-delay: 0.05s; }
.msg:nth-child(3)  { animation-delay: 0.10s; }
.msg:nth-child(4)  { animation-delay: 0.15s; }
.msg:nth-child(5)  { animation-delay: 0.20s; }
.msg:nth-child(6)  { animation-delay: 0.25s; }
.msg:nth-child(7)  { animation-delay: 0.30s; }
.msg:nth-child(8)  { animation-delay: 0.35s; }
.msg:nth-child(9)  { animation-delay: 0.40s; }
.msg:nth-child(10) { animation-delay: 0.45s; }

/* --- Desktop Only Utility --- */
@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }
}

/* =========================================
   Ambient Glow Orbs (Floating Lights)
   ========================================= */

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  will-change: transform;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(15, 107, 107, 0.3), transparent 70%);
  top: -100px;
  right: -100px;
  animation: orbFloat1 12s ease-in-out infinite;
}

.orb-2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(32, 178, 138, 0.25), transparent 70%);
  bottom: -80px;
  left: -80px;
  animation: orbFloat2 15s ease-in-out infinite;
}

.orb-3 {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(15, 107, 107, 0.15), transparent 70%);
  top: 40%;
  left: 50%;
  animation: orbFloat3 18s ease-in-out infinite;
}

@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-40px, 30px) scale(1.1); }
  50% { transform: translate(-20px, 60px) scale(0.95); }
  75% { transform: translate(30px, 20px) scale(1.05); }
}

@keyframes orbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(50px, -40px) scale(1.08); }
  66% { transform: translate(20px, -60px) scale(0.92); }
}

@keyframes orbFloat3 {
  0%, 100% { transform: translate(-50%, 0) scale(1); opacity: 0.3; }
  50% { transform: translate(-50%, -40px) scale(1.15); opacity: 0.5; }
}

/* Reduce orb intensity in light mode */
.theme-light .ambient-orb {
  opacity: 0.2;
}

/* --- Particle Canvas sits behind content --- */
.chat-area .messages,
.chat-area form,
.chat-area > div:not(.ambient-orb):not(#particleCanvas):not(#cursorGlow):not(#mobileOverlay) {
  position: relative;
  z-index: 1;
}

/* --- Glow line under header (Removed to prevent fixed scroll bugs) --- */

/* Typing indicator - bouncing dots */
.dot-bounce {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.6;
  animation: dotBounce 1.2s ease-in-out infinite;
}

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-10px); opacity: 1; }
}

/* Styled file input globally */
input[type="file"]::file-selector-button {
  background: var(--btn-bg);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-right: 12px;
  transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--btn-bg-hover);
}

/* Ensure all .btn links never have underline */
a.btn, a.btn:hover, a.btn:visited, a.btn:active {
  text-decoration: none;
}

/* Language Selector */
.lang-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  line-height: 1;
  transition: all 0.2s;
  opacity: 0.5;
}

.lang-btn:hover {
  opacity: 1;
  background: rgba(15, 107, 107, 0.08);
}

.lang-btn.active {
  opacity: 1;
  border-color: var(--primary);
  background: rgba(15, 107, 107, 0.1);
}

.lang-selector {
  font-size: 13px;
  color: var(--muted);
}