/* ============ GLOBAL RESET ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Light theme: white background, black text */
  --bg-dark: #ffffff;
  --bg-darker: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border: #e5e7eb;
  --text-primary: #000000;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  /* Primary color kept for buttons etc., clickable links use #214c77 */
  --primary: #214c77;
  --primary-dark: #1a3b5d;
  --accent: #214c77;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 25px rgba(15, 23, 42, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.3);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ffffff;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============ MAIN HEADER - After Left Sidebar ============ */
.main-header {
  flex-shrink: 0;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  grid-row: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.login-btn, .logout-btn {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.login-btn:hover {
  background: var(--primary);
  color: white;
}

.logout-btn {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.product-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Header search / command palette trigger */
.header-search {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}

.command-palette-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.command-palette-trigger-icon {
  font-size: 1rem;
}

.command-palette-trigger-label {
  font-weight: 500;
}

.command-palette-trigger-hint {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-muted);
}

.command-palette-trigger:hover {
  background: #ffffff;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.product-tab {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.product-tab:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
}

.product-tab.active {
  background: linear-gradient(to right, var(--primary), var(--primary-dark));
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* ============ MAIN LAYOUT (3 COLUMNS) ============ */
.main-layout {
  display: grid;
  grid-template-columns: 90px 1fr 280px;
  grid-template-rows: auto 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  height: 100vh;
}

/* ============ LEFT SIDEBAR - Perplexity Style (Full Height from Top) ============ */
.left-sidebar.perplexity-style {
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.5rem;
  min-height: 0;
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  height: 100vh;
  width: 90px;
  grid-row: 1 / -1;
  align-self: start;
  z-index: 100; /* Above sidebar-content panel */
}

/* Company Logo at Top */
.sidebar-logo {
  margin-bottom: 1rem;
  padding: 0.5rem 0;
}

.company-logo-circle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: radial-gradient(circle at 20% 20%, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.3rem;
  color: #ecfdf5;
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.2s;
  pointer-events: auto;
  border: 2px solid rgba(34, 197, 94, 0.3);
}

.company-logo-circle:hover {
  transform: scale(1.05);
}

/* Icon Buttons - Vertical Layout */
.sidebar-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0.4rem 0;
  position: relative;
  transition: all 0.2s ease;
}

.sidebar-icon-btn:hover {
  background: #f3f4f6;
  color: var(--text-primary);
  transform: scale(1.05);
}

.sidebar-icon-btn.active {
  background: rgba(34, 197, 94, 0.3);
  color: var(--primary);
}

.sidebar-icon-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.5;
  stroke: currentColor;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7)); /* Stronger shadow for dark bg */
}

/* Icon Label Below */
.icon-label {
  font-size: 0.7rem;
  margin-top: 0.3rem;
  text-align: center;
  color: var(--text-primary);
  font-weight: 400;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none; /* Allow clicks on button */
  white-space: nowrap;
}

/* Tooltip on Hover - Disabled CSS tooltips, using JS instead */
.sidebar-icon-btn[data-tooltip] {
  position: relative;
}

/* Disable CSS tooltips to prevent sidebar hiding - using JS tooltips instead */
.sidebar-icon-btn[data-tooltip]:hover::before {
  display: none; /* Disabled */
}

.sidebar-icon-btn[data-tooltip]:hover::after {
  display: none; /* Disabled */
}

@keyframes fadeInTooltip {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

/* Dynamic tooltip styles */
.dynamic-tooltip {
  background: rgba(15, 23, 42, 0.98);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  pointer-events: none;
  z-index: 2000;
  animation: fadeInTooltip 0.2s ease;
}

/* Navigation Icons Container */
.sidebar-nav-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin: 0.5rem 0 0.25rem 0;
  z-index: 10;
}

.sidebar-nav-icons .sidebar-icon-btn {
  position: relative;
  z-index: 10;
}

/* Secondary / optional icons label */
.sidebar-more-label {
  margin: 0.75rem 0 0.25rem 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Secondary icons slightly de‑emphasized */
.sidebar-icon-secondary {
  opacity: 0.85;
}

.sidebar-icon-secondary:hover {
  opacity: 1;
}

/* New Chat Button */
.new-chat-btn {
  background: rgba(148, 163, 184, 0.1) !important;
}

.new-chat-btn:hover {
  background: rgba(148, 163, 184, 0.2) !important;
}

/* Notifications Button */
.notifications-btn {
  margin-top: 0.5rem;
}

/* Account Section */
.sidebar-account {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.sidebar-account .account-btn {
  position: relative;
  z-index: 10;
}

.account-btn {
  width: 44px;
  height: auto;
  flex-direction: column;
  position: relative;
}

.account-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white !important;
  font-weight: 600;
  font-size: 1.2rem;
  position: relative;
  margin-bottom: 0.3rem;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  pointer-events: none; /* Let parent button handle clicks */
}

.status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--bg-sidebar);
}

.account-btn .chevron-down {
  margin-top: 0.25rem;
  opacity: 0.7;
}

.account-btn:hover .chevron-down {
  opacity: 1;
}

/* Login/Signup Buttons Below Account */
.sidebar-auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  width: 100%;
  padding: 0 0.25rem;
}

.sidebar-login-btn,
.sidebar-signup-btn {
  width: 100%;
  padding: 0.55rem 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-primary);
  font-size: 0.65rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
}

.sidebar-login-btn:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-signup-btn {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-signup-btn:hover {
  background: rgba(34, 197, 94, 0.25);
  transform: scale(1.02);
}

/* Hide auth buttons when logged in */
.sidebar-auth-buttons.hidden {
  display: none;
}

.sidebar-content {
  position: fixed;
  left: 90px; /* Start right after left sidebar (updated width) */
  top: 0; /* Start from top, will be pushed down by header */
  bottom: 0;
  width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  padding-top: calc(80px + 1.5rem); /* Add header height to padding-top */
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100vh;
  z-index: 50; /* Below left sidebar, above main content */
  opacity: 0; /* Closed: invisible */
  visibility: hidden; /* Hidden from interaction */
  transition: opacity 0.3s ease, visibility 0.3s ease;
  box-shadow: none;
  pointer-events: none; /* Don't block clicks when hidden */
}

/* Left sidebar content visible ONLY when explicitly opened via JS (.open) */
.sidebar-content.open {
  opacity: 1; /* Open: fade in */
  visibility: visible; /* Visible for interaction */
  pointer-events: auto; /* Allow clicks when visible */
}

.sidebar-panel {
  display: none;
}

.sidebar-panel.active {
  display: block;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: relative;
}

.history-item:hover {
  background: #f3f4f6;
  border-color: var(--border);
}

.history-item-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.history-item-menu {
  position: relative;
  flex-shrink: 0;
}

.history-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0;
}

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

.history-menu-btn:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-primary);
}

.history-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
  min-width: 120px;
  overflow: hidden;
}

.history-menu-item {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.history-menu-item:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

.history-menu-item svg {
  flex-shrink: 0;
}

.history-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.history-item-preview {
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-history {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Clear All button removed - now using individual thread deletion */

.setting-item {
  margin-bottom: 1.5rem;
}

.setting-item label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.setting-item select,
.setting-item input[type="checkbox"] {
  width: 100%;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
}

/* ============ CENTER CONTENT ============ */
.center-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
  grid-row: 2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.product-header {
  flex-shrink: 0;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.product-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.product-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.5rem;
}

/* Persona selector just above chat messages */
.persona-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.persona-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.persona-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.persona-pill {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.persona-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(33, 76, 119, 0.06);
}

.persona-pill.active {
  border-color: var(--primary);
  background: #214c77;
  color: #ffffff;
}

.messages {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.bot {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 75%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: var(--shadow);
}

.message-bubble.user {
  background: #ffffff; /* pure white background for user messages */
  color: #000000; /* user text in black */
  border-bottom-right-radius: 0.25rem;
}

.message-bubble.bot {
  background: #f3f4f6; /* light gray background for bot replies */
  color: #000000; /* bot text in black */
  border: none;
  border-bottom-left-radius: 0.25rem;
}

.message-meta {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.7;
  font-weight: 500;
}

.message-body {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-bubble {
  position: relative;
  transition: all 0.2s;
}

.message-bubble:hover .message-actions {
  opacity: 1 !important;
}

.message-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
  pointer-events: auto;
}

.message-action-btn {
  background: rgba(33, 76, 119, 0.06); /* soft accent tint instead of black */
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  backdrop-filter: blur(4px);
  transition: all 0.2s;
}

.message-action-btn:hover {
  background: rgba(33, 76, 119, 0.8);
  transform: scale(1.1);
}

.message-bubble.user .message-action-btn {
  background: rgba(33, 76, 119, 0.06);
}

.message-bubble.user .message-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.message-edit-input {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 0.5rem;
}

.message-edit-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.edit-save-btn,
.edit-cancel-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.edit-save-btn {
  background: var(--primary);
  color: white;
}

.edit-save-btn:hover {
  background: var(--primary-dark);
}

.edit-cancel-btn {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.edit-cancel-btn:hover {
  background: rgba(15, 23, 42, 1);
  color: var(--text-primary);
}

/* ============ GOOGLE LOGIN BUTTON ============ */
.google-login-btn {
  width: 100%;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  color: #3c4043;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.google-login-btn:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.google-login-btn svg {
  flex-shrink: 0;
}

.streaming-body.typing {
  animation: typing-pulse 1.2s ease-in-out infinite;
}
@keyframes typing-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.input-container {
  flex-shrink: 0;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.attach-pdf-btn {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.attach-pdf-btn:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
}

#chat-input {
  flex: 1;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-primary);
  outline: none;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  min-height: 48px;
  max-height: 120px;
}

#chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

#send-btn {
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  background: #214c77; /* use AIMC primary color instead of black */
  color: #ffffff;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
  transition: all 0.2s;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.5);
}

#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-pdf-status {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-height: 1.5rem;
}

.empty-state {
  text-align: center;
  margin-top: 3rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.empty-state h2 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-size: 1.5rem;
}

.empty-state ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.empty-state li {
  margin: 0.5rem 0;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

/* ============ RIGHT SIDEBAR ============ */
/* ============ RIGHT SIDEBAR - Traditional Style (Below Header) ============ */
.right-sidebar {
  background: #ffffff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  grid-row: 2;
  align-self: start;
}

/* Custom scrollbar for right sidebar */
.right-sidebar::-webkit-scrollbar {
  width: 8px;
}

.right-sidebar::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.right-sidebar::-webkit-scrollbar-thumb {
  background: #214c77;
  border-radius: 4px;
}

.right-sidebar::-webkit-scrollbar-thumb:hover {
  background: #1a3b5d;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.related-products-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.related-product {
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.related-product:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
  transform: translateX(4px);
}

.related-product-name {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.related-product-specs {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.cta-section {
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  font-size: 0.85rem;
}

.cta-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.cta-btn {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0.75rem;
}

.cta-btn.whatsapp {
  background: #25d366;
  color: white;
}

.cta-btn.whatsapp:hover {
  background: #20ba5a;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}

.cta-btn.phone {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.cta-btn.phone:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
}

/* ============ PDF UPLOAD SECTION ============ */
.pdf-upload-simple {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pdf-upload-simple input[type="file"] {
  flex: 1;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.pdf-upload-simple button {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.85rem;
}

.pdf-upload-simple button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pdf-upload-simple #upload-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

/* ============ VOICE INPUT BUTTON ============ */
.voice-btn {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.voice-btn:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
}

.voice-btn.active {
  background: var(--primary);
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* ============ MODAL ============ */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  margin: 5% auto;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.close {
  color: var(--text-secondary);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: var(--text-primary);
}

.modal-form {
  margin-top: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.generate-btn {
  width: 100%;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(to right, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
}

.generated-content {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-darker);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  line-height: 1.6;
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

.error {
  color: #fca5a5;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
}

.success {
  color: #86efac;
  padding: 1rem;
  background: rgba(34, 197, 94, 0.1);
  border-radius: var(--radius-sm);
}

.modal-content a {
  color: #214c77;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.modal-content a:hover {
  text-decoration: underline;
}

/* ============ PRODUCT SEARCH & LIST ============ */
.product-list-container {
  position: relative;
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-darker);
  z-index: 10;
}

.product-list {
  display: flex;
  flex-direction: column;
}

.product-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.product-item:hover {
  background: rgba(34, 197, 94, 0.1);
}

.product-item:last-child {
  border-bottom: none;
}

.product-item-name {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.product-item-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-products,
.no-products {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
}

/* Discover: Product Search & Details */
.discover-search-wrap {
  margin: 0.75rem 0;
}
.discover-search-wrap input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 0.95rem;
}
.discover-product-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-darker);
  margin-bottom: 1rem;
}
.discover-product-list .product-item {
  border-bottom: 1px solid var(--border);
}
.discover-product-details {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-darker);
  margin-top: 0.5rem;
}
.discover-product-details h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--text-primary);
}
.discover-detail-specs {
  font-size: 0.85rem;
  color: var(--primary);
  margin: 0.25rem 0;
}
.discover-detail-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
  line-height: 1.4;
}
.discover-detail-apps {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
}
.discover-detail-apps ul {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
}
.discover-product-details .action-btn {
  margin-top: 0.75rem;
  width: 100%;
}

.selected-product-info {
  margin: 1rem 0;
  padding: 0.75rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

#product-search {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 0.95rem;
}

#product-search:focus {
  border-color: var(--primary);
  outline: none;
}

/* ============ DASHBOARD ============ */
#dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: var(--bg-darker);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dashboard-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-btn {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.action-btn:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
}

/* ============ FEATURE BUTTONS ============ */
.feature-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  text-align: left;
}

.feature-btn:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
  transform: translateX(4px);
}

.recommendations-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recommendation-item {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.recommendation-item:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
}

/* ============ CUSTOM SCROLLBARS ============ */
/* Global scrollbar styling for all scrollable areas */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #214c77;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #1a3b5d;
}

/* ============ SOURCES ============ */
.sources {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: #ffffff; /* white text for Sources */
  background: #214c77; /* keep AIMC blue as background */
  padding: 0.25rem 0; /* minimal padding so it stays inline with bubble */
  border-radius: 0;
  display: inline; /* inline as requested */
}

.sources a {
  color: #214c77; /* keep primary link color */
  font-weight: 600;
  text-decoration: underline; /* always underlined */
  margin-right: 0.5rem;
}

.sources a:hover {
  text-decoration: underline;
}

/* ============ INLINE PRODUCT & SUGGESTION BUTTONS ============ */
.product-suggestions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.product-suggestion-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #214c77;
  background: #214c77;
  color: #ffffff; /* suggestion chips text in white */
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}

.product-suggestion-btn:hover {
  background: #214c77;
  color: #ffffff;
  transform: translateY(-1px);
}

.inline-product-link {
  display: inline-block;
  margin: 0 2px;
  padding: 0 0.1rem;
  border-radius: 4px;
  border-bottom: 1px dashed #214c77;
  color: #ffffff; /* inline clickable product names in white */
  font-weight: 600;
  background: transparent;
  cursor: pointer;
}

.inline-product-link:hover {
  text-decoration: underline;
}

/* ============ COMMAND PALETTE (Cmd+K style) ============ */
.command-palette-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.command-palette-modal.open {
  display: flex;
  opacity: 1;
}

.command-palette-card {
  width: min(640px, 92vw);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.45);
  overflow: hidden;
  animation: commandPaletteIn 0.18s ease-out;
}

.command-palette-header {
  padding: 0.9rem 1rem 0.35rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.command-palette-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.command-palette-input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(209, 213, 219, 0.9);
  background: #f9fafb;
  color: #111827;
  font-size: 0.95rem;
  outline: none;
}

.command-palette-input::placeholder {
  color: #9ca3af;
}

.command-palette-input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(33, 76, 119, 0.35);
}

.command-palette-hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.command-palette-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 0.4rem 0.2rem 0.4rem;
}

.command-palette-section-title {
  padding: 0.4rem 1.1rem 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
}

.command-palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #111827;
  border-radius: 10px;
  margin: 0.05rem 0.7rem;
  transition: background 0.12s ease, transform 0.08s ease;
}

.command-palette-item:hover {
  background: #f3f4f6;
}

.command-palette-item.active {
  background: #111827;
  color: #f9fafb;
  transform: translateY(-1px);
}

.command-palette-item-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.command-palette-item-title {
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.command-palette-item-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.command-palette-item.active .command-palette-item-subtitle {
  color: #e5e7eb;
}

.command-palette-item-meta {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-left: 0.5rem;
}

.command-palette-item-action {
  font-size: 0.85rem;
  color: #6b7280;
}

.command-palette-item.active .command-palette-item-action {
  color: #e5e7eb;
}

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

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 90px 1fr 280px;
  }
}

@media (max-width: 968px) {
  .main-layout {
    grid-template-columns: 0 1fr 0;
  }
  
  .main-layout {
    grid-template-columns: 90px 1fr;
  }
  
  .left-sidebar.perplexity-style {
    width: 90px;
  }
  
  .sidebar-content {
    width: 300px;
    left: 90px;
  }
  
  .right-sidebar {
    width: 280px;
  }
  
  .left-sidebar,
  .right-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  
  .left-sidebar.perplexity-style {
    transform: translateX(0);
  }
  
  .left-sidebar.open {
    transform: translateX(0);
  }
  
  .right-sidebar {
    right: 0;
    left: auto;
    transform: translateX(100%);
  }
  
  .right-sidebar.open {
    transform: translateX(0);
  }
}

@media (max-width: 640px) {
  .main-header {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .product-tabs {
    width: 100%;
    overflow-x: auto;
  }
  
  .chat-container {
    padding: 1rem;
  }
  
  .message-bubble {
    max-width: 90%;
  }
}
