/* ==========================================================================
   NutriBot - AI Diet Assistant Design System & Stylesheet
   Modern, Clean, Health-Themed, Responsive, Accessible
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens (Light & Dark Theme)
   -------------------------------------------------------------------------- */
:root {
  /* Primary Health Green Palette */
  --primary-50: #f0fdf4;
  --primary-100: #dcfce7;
  --primary-200: #bbf7d0;
  --primary-300: #86efac;
  --primary-400: #4ade80;
  --primary-500: #22c55e;
  --primary-600: #16a34a; /* Main Primary */
  --primary-700: #15803d;
  --primary-800: #166534;
  --primary-900: #14532d;
  --primary-rgb: 22, 163, 74;

  /* Accent Colors */
  --accent-blue: #0284c7;
  --accent-amber: #d97706;
  --accent-purple: #9333ea;
  --accent-rose: #e11d48;

  /* Macro Colors */
  --color-protein: #3b82f6;
  --color-carbs: #10b981;
  --color-fats: #f59e0b;

  /* Neutral Surface Palette - Light Mode */
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-secondary: #f1f5f9;
  --bg-input: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: var(--primary-600);

  /* Chat Specific */
  --chat-user-bg: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  --chat-user-text: #ffffff;
  --chat-bot-bg: #ffffff;
  --chat-bot-border: #e2e8f0;
  --chat-bot-text: #0f172a;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(22, 163, 74, 0.25);

  /* Dimensions & Transitions */
  --sidebar-width: 280px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --------------------------------------------------------------------------
   Dark Theme Overrides
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-secondary: #0f172a;
  --bg-input: #1e293b;
  --bg-hover: #334155;
  --bg-active: #475569;

  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --border-color: #334155;
  --border-subtle: #1e293b;

  --chat-user-bg: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  --chat-user-text: #ffffff;
  --chat-bot-bg: #1e293b;
  --chat-bot-border: #334155;
  --chat-bot-text: #f8fafc;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(34, 197, 94, 0.2);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  transition: all var(--transition-fast);
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   3. App Layout Architecture
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   4. Sidebar Styles
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.1;
}

.brand-title span {
  color: var(--primary-600);
}

.brand-badge {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-close-sidebar {
  display: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
}

.btn-close-sidebar:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

/* Sidebar Action (New Chat) */
.sidebar-action {
  padding: 14px 14px 8px;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
  transition: all var(--transition-fast);
}

.btn-new-chat:hover {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.shortcut-key {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
}

/* Sidebar Navigation Items */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.btn-clear-history {
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear-history:hover {
  color: var(--accent-rose);
  background-color: var(--bg-hover);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link svg {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.nav-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-link:hover svg {
  color: var(--primary-600);
}

.nav-link.active {
  background-color: var(--primary-50);
  color: var(--primary-700);
  font-weight: 600;
}

[data-theme="dark"] .nav-link.active {
  background-color: rgba(22, 163, 74, 0.15);
  color: var(--primary-400);
}

.nav-link.active svg {
  color: var(--primary-600);
}

.nav-badge, .nav-badge-ai {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.nav-badge {
  background-color: var(--bg-active);
  color: var(--text-muted);
}

.nav-badge-ai {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #ffffff;
}

/* Chat History List */
.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  max-height: 240px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.history-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.history-item.active {
  background-color: var(--bg-hover);
  color: var(--primary-600);
  font-weight: 600;
}

.history-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding-right: 6px;
}

.btn-delete-session {
  opacity: 0;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.history-item:hover .btn-delete-session {
  opacity: 1;
}

.btn-delete-session:hover {
  color: var(--accent-rose);
  background-color: rgba(225, 29, 72, 0.1);
}

.empty-history-msg {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 10px 8px;
  text-align: center;
  font-style: italic;
}

/* Sidebar Footer / User Profile Card */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
}

.user-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background-color: var(--bg-card-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-color);
}

.user-mini-card:hover {
  border-color: var(--primary-400);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-800));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-edit-icon {
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   5. Main Viewport & Header Bar
   -------------------------------------------------------------------------- */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-app);
  overflow: hidden;
}

.main-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-card);
  backdrop-filter: blur(8px);
  z-index: 20;
  flex-shrink: 0;
}

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

.btn-toggle-sidebar {
  display: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.btn-toggle-sidebar:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.bot-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.bot-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.bot-status-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

.btn-header-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-header-tool:hover {
  background-color: var(--bg-hover);
  color: var(--primary-600);
  border-color: var(--primary-300);
}

.btn-api-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background-color: var(--primary-50);
  border: 1px solid var(--primary-200);
  color: var(--primary-700);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .btn-api-badge {
  background-color: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.3);
  color: var(--primary-300);
}

.btn-api-badge.warning {
  background-color: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

[data-theme="dark"] .btn-api-badge.warning {
  background-color: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.3);
  color: #fcd34d;
}

.btn-theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-secondary);
}

.btn-theme-toggle:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.icon-sun {
  display: block;
}
.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: none;
}
[data-theme="dark"] .icon-moon {
  display: block;
}

/* --------------------------------------------------------------------------
   6. Chat Area & Welcome Screen
   -------------------------------------------------------------------------- */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Welcome Screen */
.welcome-screen {
  max-width: 760px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 10px;
  animation: fadeIn 0.4s ease-out;
}

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

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 16px;
}

[data-theme="dark"] .welcome-badge {
  background-color: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.3);
  color: var(--primary-300);
}

.welcome-avatar-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.welcome-bot-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(22, 163, 74, 0.35);
  position: relative;
  z-index: 2;
}

.welcome-bot-avatar svg {
  width: 34px;
  height: 34px;
}

.avatar-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(34, 197, 94, 0.4) 0%, rgba(34, 197, 94, 0) 70%);
  z-index: 1;
}

.welcome-title {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.welcome-title .highlight {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-description {
  font-size: 0.96rem;
  color: var(--text-secondary);
  max-width: 580px;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Profile Reminder Banner */
.profile-banner-reminder {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.pbr-icon {
  font-size: 1.2rem;
}

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

.btn-pbr {
  background-color: var(--primary-50);
  color: var(--primary-700);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-200);
  white-space: nowrap;
}

.btn-pbr:hover {
  background-color: var(--primary-600);
  color: #ffffff;
}

/* Quick Prompts Grid */
.quick-prompts-section {
  width: 100%;
}

.quick-prompts-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  text-align: left;
}

.quick-prompts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-prompt-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.quick-prompt-card:hover {
  border-color: var(--primary-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background-color: var(--bg-card);
}

.prompt-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.prompt-content {
  flex: 1;
  min-width: 0;
}

.prompt-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.prompt-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-arrow {
  color: var(--text-muted);
  font-size: 1rem;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.quick-prompt-card:hover .prompt-arrow {
  color: var(--primary-600);
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   7. Chat Messages Flow & Message Bubbles
   -------------------------------------------------------------------------- */
.chat-messages {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 16px;
}

.message-row {
  display: flex;
  gap: 12px;
  width: 100%;
  animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* User Message Bubble */
.message-row.user {
  justify-content: flex-end;
}

.message-row.user .message-bubble-wrapper {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-bubble.user-bubble {
  background: var(--chat-user-bg);
  color: var(--chat-user-text);
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: 0.94rem;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
  word-break: break-word;
  white-space: pre-wrap;
}

/* Bot Message Bubble */
.message-row.bot {
  justify-content: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.2);
}

.message-avatar svg {
  width: 20px;
  height: 20px;
}

.message-row.bot .message-bubble-wrapper {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-bubble.bot-bubble {
  background-color: var(--chat-bot-bg);
  border: 1px solid var(--chat-bot-border);
  color: var(--chat-bot-text);
  padding: 16px 20px;
  border-radius: 4px 20px 20px 20px;
  box-shadow: var(--shadow-sm);
  font-size: 0.94rem;
  line-height: 1.65;
  word-break: break-word;
  width: 100%;
}

.message-timestamp {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy-msg {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.7;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.btn-copy-msg:hover {
  opacity: 1;
  color: var(--primary-600);
}

/* Markdown Formatting inside Bot Bubble */
.bot-bubble h1, .bot-bubble h2, .bot-bubble h3, .bot-bubble h4 {
  margin-top: 14px;
  margin-bottom: 8px;
  color: var(--text-main);
}

.bot-bubble h2 {
  font-size: 1.2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.bot-bubble h3 {
  font-size: 1.05rem;
}

.bot-bubble h4 {
  font-size: 0.95rem;
}

.bot-bubble p {
  margin-bottom: 10px;
}

.bot-bubble p:last-child {
  margin-bottom: 0;
}

.bot-bubble ul, .bot-bubble ol {
  margin: 8px 0 12px 20px;
}

.bot-bubble li {
  margin-bottom: 5px;
}

.bot-bubble strong {
  color: var(--text-main);
  font-weight: 600;
}

.bot-bubble blockquote {
  border-left: 3px solid var(--primary-500);
  background-color: var(--bg-card-secondary);
  padding: 8px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 12px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.bot-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.bot-bubble th, .bot-bubble td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.bot-bubble th {
  background-color: var(--bg-card-secondary);
  font-weight: 600;
  color: var(--text-main);
}

.bot-bubble tr:nth-child(even) {
  background-color: var(--bg-app);
}

.bot-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  background-color: var(--bg-card-secondary);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.bot-bubble pre {
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
}

/* Typing Indicator Bubble */
.typing-indicator-container {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.2s ease;
}

.bot-avatar-bubble {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.typing-bubble {
  background-color: var(--chat-bot-bg);
  border: 1px solid var(--chat-bot-border);
  padding: 10px 16px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xs);
}

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

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary-600);
  animation: bounceDot 1.4s infinite ease-in-out both;
}

.typing-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dots .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounceDot {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --------------------------------------------------------------------------
   8. Chat Input Area (Sticky Footer)
   -------------------------------------------------------------------------- */
.chat-input-wrapper {
  padding: 12px 20px 16px;
  background: linear-gradient(to top, var(--bg-app) 80%, rgba(248, 250, 252, 0) 100%);
  flex-shrink: 0;
  z-index: 20;
}

[data-theme="dark"] .chat-input-wrapper {
  background: linear-gradient(to top, var(--bg-app) 80%, rgba(9, 13, 22, 0) 100%);
}

.chat-input-card {
  max-width: 820px;
  margin: 0 auto;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-card:focus-within {
  border-color: var(--primary-500);
  box-shadow: 0 4px 20px rgba(22, 163, 74, 0.15);
}

.textarea-container {
  width: 100%;
}

.chat-textarea {
  width: 100%;
  min-height: 24px;
  max-height: 180px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  padding: 6px 6px;
  outline: none;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.input-actions-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-input-accessory {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.btn-input-accessory:hover {
  background-color: var(--bg-hover);
  color: var(--primary-600);
}

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
  transition: all var(--transition-fast);
}

.btn-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.send-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.chat-disclaimer {
  max-width: 820px;
  margin: 6px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.chat-disclaimer svg {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   9. Modals & Dialog Windows
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-bounce);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-card.modal-lg {
  max-width: 840px;
}

.modal-header {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-card);
  flex-shrink: 0;
}

.modal-header-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.calc-icon-bg { background-color: var(--primary-100); }
.plan-icon-bg { background-color: #e0f2fe; }
.profile-icon-bg { background-color: #f3e8ff; }
.tips-icon-bg { background-color: #fef3c7; }
.api-icon-bg { background-color: #fee2e2; }

[data-theme="dark"] .calc-icon-bg { background-color: rgba(22, 163, 74, 0.2); }
[data-theme="dark"] .plan-icon-bg { background-color: rgba(2, 132, 199, 0.2); }
[data-theme="dark"] .profile-icon-bg { background-color: rgba(147, 51, 234, 0.2); }
[data-theme="dark"] .tips-icon-bg { background-color: rgba(217, 119, 6, 0.2); }
[data-theme="dark"] .api-icon-bg { background-color: rgba(225, 29, 72, 0.2); }

.modal-header-text {
  flex: 1;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.btn-close-modal:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

/* --------------------------------------------------------------------------
   10. Form Controls & Buttons
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
  outline: none;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-suffix .suffix {
  position: absolute;
  right: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-toggle-key-visibility {
  position: absolute;
  right: 8px;
  padding: 4px;
  color: var(--text-muted);
}

.form-text-muted {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

/* Gender Selector Radio Cards */
.gender-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gender-radio-card input {
  display: none;
}

.gender-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  background-color: var(--bg-card);
  transition: all var(--transition-fast);
}

.gender-radio-card input:checked + .gender-box {
  border-color: var(--primary-500);
  background-color: var(--primary-50);
  color: var(--primary-700);
  font-weight: 600;
}

[data-theme="dark"] .gender-radio-card input:checked + .gender-box {
  background-color: rgba(22, 163, 74, 0.15);
  color: var(--primary-300);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.btn-success {
  background-color: var(--primary-600);
  color: #ffffff;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-success:hover {
  background-color: var(--primary-700);
}

.btn-outline {
  border: 1px solid var(--border-color);
  background-color: transparent;
  color: var(--text-secondary);
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-outline:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   11. Calorie Calculator Modal Layout & Output
   -------------------------------------------------------------------------- */
.calc-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.calc-result-panel {
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.calc-placeholder-view {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  padding: 20px;
}

.cpv-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.result-highlight-card {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  color: #ffffff;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.rh-label {
  font-size: 0.8rem;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.rh-value {
  font-size: 2rem;
  font-weight: 800;
  margin: 4px 0;
}

.rh-value .unit {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.85;
}

.rh-badge {
  display: inline-block;
  font-size: 0.72rem;
  background-color: rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.result-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-mini-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-md);
}

.stat-mini-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-mini-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 2px 0;
}

.stat-mini-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Macronutrient Breakdown */
.macros-breakdown-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.macros-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.macros-title {
  color: var(--text-main);
}

.macros-sub {
  color: var(--text-muted);
}

.macro-bar-container {
  display: flex;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 10px;
}

.macro-bar.protein { background-color: var(--color-protein); }
.macro-bar.carbs { background-color: var(--color-carbs); }
.macro-bar.fats { background-color: var(--color-fats); }

.macro-items-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.macro-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.macro-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.protein-dot { background-color: var(--color-protein); }
.carbs-dot { background-color: var(--color-carbs); }
.fats-dot { background-color: var(--color-fats); }

.macro-info {
  display: flex;
  flex-direction: column;
}

.macro-name {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.macro-val {
  font-size: 0.82rem;
  color: var(--text-main);
}

.result-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.calc-disclaimer-note {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   12. AI Meal Planner Modal Layout & Output
   -------------------------------------------------------------------------- */
.planner-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.planner-result-panel {
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow-y: auto;
}

.plan-placeholder-view {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  padding: 20px;
}

.ppv-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.plan-loading-view {
  margin: auto;
  text-align: center;
  padding: 30px 10px;
}

.plan-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.plan-loading-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.plan-loading-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto;
}

.plan-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.poh-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.poh-actions {
  display: flex;
  gap: 6px;
}

.plan-markdown-body {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-main);
}

.plan-markdown-body h3 {
  font-size: 1rem;
  color: var(--primary-700);
  margin: 12px 0 6px;
}

[data-theme="dark"] .plan-markdown-body h3 {
  color: var(--primary-400);
}

.plan-markdown-body ul {
  padding-left: 18px;
  margin-bottom: 10px;
}

/* --------------------------------------------------------------------------
   13. User Profile & BMI Preview
   -------------------------------------------------------------------------- */
.profile-bmi-preview {
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pbp-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pbp-score {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bmi-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-active);
  color: var(--text-muted);
}

.bmi-badge.normal {
  background-color: var(--primary-100);
  color: var(--primary-800);
}

.bmi-badge.warning {
  background-color: #fef3c7;
  color: #92400e;
}

.bmi-badge.danger {
  background-color: #fee2e2;
  color: #991b1b;
}

/* --------------------------------------------------------------------------
   14. Diet Tips Hub Cards Grid
   -------------------------------------------------------------------------- */
.tips-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.tip-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-fast);
}

.tip-card:hover {
  border-color: var(--primary-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.tip-badge {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--primary-50);
  color: var(--primary-700);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

[data-theme="dark"] .tip-badge {
  background-color: rgba(22, 163, 74, 0.15);
  color: var(--primary-300);
}

.tip-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.tip-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.tip-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
  flex: 1;
}

.btn-tip-action {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-600);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.btn-tip-action:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   15. API Key Config Modal
   -------------------------------------------------------------------------- */
.api-guide-box {
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agb-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--primary-600);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.api-status-card {
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 14px 0 18px;
}

.asc-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.asc-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.asc-label { color: var(--text-muted); }
.asc-val { font-weight: 600; color: var(--text-main); }

/* --------------------------------------------------------------------------
   16. Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.toast-success { border-left: 4px solid var(--primary-600); }
.toast.toast-error { border-left: 4px solid var(--accent-rose); }
.toast.toast-info { border-left: 4px solid var(--accent-blue); }

.toast-icon { font-size: 1.1rem; }
.toast-content { flex: 1; }
.toast-title { font-size: 0.84rem; font-weight: 700; color: var(--text-main); }
.toast-message { font-size: 0.76rem; color: var(--text-muted); margin-top: 1px; }

/* --------------------------------------------------------------------------
   17. Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .calc-layout-grid, .planner-layout-grid {
    grid-template-columns: 1fr;
  }

  .tips-cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .btn-toggle-sidebar {
    display: flex;
  }

  .btn-close-sidebar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }

  .sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
  }

  .btn-text-desktop {
    display: none;
  }

  .quick-prompts-grid {
    grid-template-columns: 1fr;
  }

  .welcome-title {
    font-size: 1.5rem;
  }

  .welcome-description {
    font-size: 0.88rem;
  }

  .message-row.user .message-bubble-wrapper,
  .message-row.bot .message-bubble-wrapper {
    max-width: 92%;
  }

  .chat-container {
    padding: 16px 12px;
  }

  .chat-input-wrapper {
    padding: 8px 12px 12px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: unset;
    width: 100%;
  }
}

/* Helpers */
.hidden {
  display: none !important;
}
