/* =============================================================================
   Crescent AI - styles-v2.css
   Modern dark sidebar UI based on devui mockup
   Version: 9 - Brand alignment update (CE-BRANDING.pdf)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CSS Variables
   ----------------------------------------------------------------------------- */
:root {
  /* ==========================================================================
     CRESCENT ENERGY BRAND COLORS (from CE-BRANDING.pdf)
     ========================================================================== */
  --brand-blue: #1193D4;           /* Primary brand color */
  --brand-black: #000000;          /* Primary text */
  --brand-dark-gray: #9B9B9B;      /* Secondary text */
  --brand-light-gray: #EDEDED;     /* Backgrounds */

  /* Sidebar - Dark Theme (using brand black) */
  --sidebar-bg: #0a0a0a;
  --sidebar-bg-hover: rgba(17, 147, 212, 0.1);
  --sidebar-bg-active: rgba(17, 147, 212, 0.15);
  --sidebar-text: #cbd5e1;
  --sidebar-text-muted: var(--brand-dark-gray);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-width: 288px;

  /* Bot Colors - All use brand blue per brand guidelines */
  --bot-cai: var(--brand-blue);
  --bot-hse: var(--brand-blue);
  --bot-ir: var(--brand-blue);
  --bot-itfin: var(--brand-blue);
  --bot-hr: var(--brand-blue);

  /* Main Content */
  --main-bg: #ffffff;
  --text-primary: var(--brand-black);
  --text-secondary: #636363;
  --text-muted: var(--brand-dark-gray);

  /* Accent - Brand Blue */
  --accent-primary: var(--brand-blue);
  --accent-hover: #0d7ab8;
  --accent-text: #0a6a9e;            /* Darker blue for text visibility */

  /* Input Island */
  --island-bg: #ffffff;
  --island-border: var(--brand-light-gray);
  --island-border-focus: var(--brand-blue);
  --island-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  --island-radius: 24px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

/* -----------------------------------------------------------------------------
   Base & Reset
   ----------------------------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--main-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure buttons and inputs inherit font */
button, input, textarea, select {
  font-family: inherit;
}

/* -----------------------------------------------------------------------------
   Loading Screen (keep existing)
   ----------------------------------------------------------------------------- */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-logo {
  width: 80px;
  height: auto;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

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

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

/* -----------------------------------------------------------------------------
   App Container Layout
   ----------------------------------------------------------------------------- */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* -----------------------------------------------------------------------------
   Sidebar
   ----------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform var(--transition-slow);
}

/* Brand Header */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}

.brand-text {
  color: white;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
}

/* Sidebar Actions (New Chat + Search) */
.sidebar-actions {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-new-chat:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-new-chat:active {
  transform: scale(0.98);
}

.btn-new-chat svg {
  width: 14px;
  height: 14px;
}

/* Sidebar Search */
.sidebar-search {
  position: relative;
}

.sidebar-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--sidebar-text-muted);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: white;
  font-size: 12px;
  outline: none;
  transition: all var(--transition-fast);
}

.sidebar-search input::placeholder {
  color: var(--sidebar-text-muted);
}

.sidebar-search input:focus {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-search input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chat History */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.chat-history::-webkit-scrollbar {
  width: 6px;
}

.chat-history::-webkit-scrollbar-track {
  background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* History Group */
.history-group {
  margin-bottom: 12px;
}

.history-group:last-child {
  margin-bottom: 0;
}

.group-label {
  padding: 0 12px;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-text-muted);
}

/* Chat List */
.chat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Chat Item */
.chat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.chat-item:hover {
  background: var(--sidebar-bg-hover);
}

.chat-item.active {
  background: var(--sidebar-bg-active);
}

.chat-item .chat-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.chat-item .chat-icon svg {
  width: 16px;
  height: 16px;
}

/* Bot icon colors */
.chat-icon.bot-cai { color: var(--bot-cai); }
.chat-icon.bot-hse { color: var(--bot-hse); }
.chat-icon.bot-ir { color: var(--bot-ir); }
.chat-icon.bot-itfin { color: var(--bot-itfin); }
.chat-icon.bot-hr { color: var(--bot-hr); }

.chat-item:hover .chat-icon.bot-cai,
.chat-item:hover .chat-icon.bot-hse,
.chat-item:hover .chat-icon.bot-ir,
.chat-item:hover .chat-icon.bot-itfin,
.chat-item:hover .chat-icon.bot-hr {
  color: #4db8e8; /* Lighter brand blue on hover */
}

.chat-item .chat-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast);
}

.chat-item:hover .chat-title {
  color: white;
}

.chat-item .chat-menu {
  opacity: 0;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-item:hover .chat-menu {
  opacity: 1;
}

.chat-item .chat-menu:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.chat-item .chat-menu svg {
  width: 16px;
  height: 16px;
}

/* Chat Menu Container & Dropdown */
.chat-menu-container {
  position: relative;
  flex-shrink: 0;
}

.chat-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 140px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: 100;
  animation: fadeInDown 0.15s ease;
}

.chat-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.chat-menu-item:hover {
  background: #f3f4f6;
}

.chat-menu-item svg {
  width: 14px;
  height: 14px;
  color: #9ca3af;
  flex-shrink: 0;
}

.chat-menu-item-danger {
  color: #dc2626;
}

.chat-menu-item-danger:hover {
  background: #fef2f2;
}

.chat-menu-item-danger svg {
  color: #dc2626;
}

/* Inline title input for rename */
.chat-title-input {
  flex: 1;
  min-width: 0;
  padding: 2px 6px;
  font-size: 12px;
  color: white;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--brand-blue);
  border-radius: 4px;
  outline: none;
}

/* Sidebar User Footer */
.sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  position: relative;
}

.sidebar-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.sidebar-user-btn:hover {
  background: var(--sidebar-bg-hover);
}

.sidebar-user-btn.active {
  background: var(--sidebar-bg-active);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(17, 147, 212, 0.3);
}

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

.user-info .user-name {
  font-size: 13px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .user-domain {
  font-size: 10px;
  color: var(--sidebar-text-muted);
}

.user-menu-trigger {
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.user-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.user-menu-trigger svg {
  width: 16px;
  height: 16px;
}

/* User Menu Dropdown */
.user-menu-dropdown {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  margin-bottom: 8px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: 50;
  animation: fadeInUp 0.15s ease;
}

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

.user-menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-menu-dropdown .menu-item:hover {
  background: #f9fafb;
}

.user-menu-dropdown .menu-item svg {
  width: 14px;
  height: 14px;
  color: #9ca3af;
}

.user-menu-dropdown .menu-item-danger {
  color: #dc2626;
}

.user-menu-dropdown .menu-item-danger:hover {
  background: #fef2f2;
}

.user-menu-dropdown .menu-item-danger svg {
  color: #dc2626;
}

.user-menu-dropdown .menu-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 4px 0;
}

.hidden {
  display: none !important;
}

/* -----------------------------------------------------------------------------
   Main Content Area
   ----------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--main-bg);
}

/* -----------------------------------------------------------------------------
   Floating Header
   ----------------------------------------------------------------------------- */
.floating-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(to bottom, #ffffff 0%, #ffffff 70%, rgba(255,255,255,0) 100%);
  z-index: 30;
}

.floating-header .header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.floating-header .header-right {
  display: flex;
  align-items: center;
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

/* Bot Selector Dropdown */
.bot-selector {
  position: relative;
}

.bot-selector-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bot-selector-trigger:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.bot-selector-trigger .bot-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.bot-selector-trigger .bot-icon svg {
  width: 20px;
  height: 20px;
}

/* Bot icon colors in trigger */
.bot-selector-trigger .bot-icon.bot-cai { color: var(--bot-cai); }
.bot-selector-trigger .bot-icon.bot-hse { color: var(--bot-hse); }
.bot-selector-trigger .bot-icon.bot-ir { color: var(--bot-ir); }
.bot-selector-trigger .bot-icon.bot-itfin { color: var(--bot-itfin); }
.bot-selector-trigger .bot-icon.bot-hr { color: var(--bot-hr); }

.bot-selector-trigger .bot-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.bot-selector-trigger .chevron {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: transform var(--transition-fast);
}

.bot-selector-trigger .chevron svg {
  width: 16px;
  height: 16px;
}

.bot-selector.open .bot-selector-trigger .chevron {
  transform: rotate(180deg);
}

/* Bot Dropdown */
.bot-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  z-index: 50;
  animation: fadeInDown 0.15s ease;
}

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

.bot-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.bot-option:hover {
  background: #f8fafc;
}

.bot-option.active {
  background: #f1f5f9;
}

.bot-option-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

/* All bot icons use brand blue with light blue background */
.bot-option-icon.bot-cai,
.bot-option-icon.bot-hse,
.bot-option-icon.bot-ir,
.bot-option-icon.bot-itfin,
.bot-option-icon.bot-hr {
  background: rgba(17, 147, 212, 0.1);
  color: var(--brand-blue);
}

.bot-option-info {
  flex: 1;
  text-align: left;
}

.bot-option-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.bot-option-desc {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Header User Avatar */
.user-avatar-header {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* -----------------------------------------------------------------------------
   Chat Container
   ----------------------------------------------------------------------------- */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 64px;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------------------------------------
   Welcome Screen
   ----------------------------------------------------------------------------- */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

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

.welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--brand-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(17, 147, 212, 0.3);
}

.welcome-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

.welcome-title {
  font-size: 30px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.welcome-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* Suggestions Grid */
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 512px;
  width: 100%;
}

.suggestion-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: white;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-normal);
}

.suggestion-card:hover {
  border-color: rgba(17, 147, 212, 0.4);
  box-shadow: 0 4px 12px rgba(17, 147, 212, 0.15);
}

.suggestion-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: all var(--transition-normal);
}

.suggestion-icon svg {
  width: 16px;
  height: 16px;
}

.suggestion-card:hover .suggestion-icon {
  background: rgba(17, 147, 212, 0.1);
  color: var(--brand-blue);
}

.suggestion-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

/* -----------------------------------------------------------------------------
   Messages
   ----------------------------------------------------------------------------- */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.message {
  display: flex;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 24px;
  width: 100%;
}

.message.user {
  justify-content: flex-end;
  margin-top: 16px;
}

.message.assistant {
  justify-content: flex-start;
}

.message-content {
  width: 85%;
  padding: 14px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
  font-size: 12px;
  max-width: 100%;
  overflow-x: auto;
}

/* User message - brand blue box on right */
.message.user .message-content {
  width: 42.5%;
  background: rgba(17, 147, 212, 0.1);
  color: var(--brand-black);
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(17, 147, 212, 0.2);
  box-shadow: 0 2px 8px rgba(17, 147, 212, 0.15);
  margin-right: 15px;
}

/* Bot message - bordered card on left */
.message.assistant .message-content {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-left: 15px;
}

.message-role {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.9;
}

.message.user .message-role {
  color: var(--brand-blue);
  font-weight: 700;
}

.message.assistant .message-role {
  color: var(--accent-text);
}

.message-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
}

.message.user .message-text {
  color: var(--brand-black);
}

.message-text p {
  margin-bottom: 16px;
}

.message-text p:last-child {
  margin-bottom: 0;
}

/* -----------------------------------------------------------------------------
   Markdown Styling in Bot Messages
   ----------------------------------------------------------------------------- */
.message.assistant .message-text h1,
.message.assistant .message-text h2,
.message.assistant .message-text h3,
.message.assistant .message-text h4 {
  color: var(--accent-text);
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
}

.message.assistant .message-text h1 { font-size: 16px; }
.message.assistant .message-text h2 { font-size: 14px; }
.message.assistant .message-text h3 { font-size: 13px; }
.message.assistant .message-text h4 { font-size: 12px; }

.message.assistant .message-text h1:first-child,
.message.assistant .message-text h2:first-child,
.message.assistant .message-text h3:first-child {
  margin-top: 0;
}

.message.assistant .message-text p {
  margin-bottom: 16px;
}

.message.assistant .message-text ul,
.message.assistant .message-text ol {
  margin: 16px 0;
  padding-left: 24px;
}

.message.assistant .message-text li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.message.assistant .message-text strong {
  font-weight: 600;
  color: var(--accent-text);
}

.message.assistant .message-text code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: #dc2626;
}

.message.assistant .message-text pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
}

.message.assistant .message-text pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.message.assistant .message-text a {
  color: var(--accent-text);
  text-decoration: underline;
}

.message.assistant .message-text a:hover {
  color: var(--brand-blue);
}

.message.assistant .message-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

.message.assistant .message-text th,
.message.assistant .message-text td {
  border: 1px solid #e2e8f0;
  padding: 12px;
  text-align: left;
}

.message.assistant .message-text th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--accent-text);
}

.message.assistant .message-text hr {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 24px 0;
}

/* Responsive images, charts, canvas, and other media */
.message.assistant .message-text img,
.message.assistant .message-text svg,
.message.assistant .message-text video,
.message.assistant .message-text iframe,
.message.assistant .message-text object,
.message.assistant .message-text embed {
  max-width: 100%;
  height: auto;
}

.message.assistant .message-text canvas {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}

.message.assistant .message-text .chartjs-wrapper,
.message.assistant .message-text .chart-container,
.message.assistant .message-text [class*="chart"],
.message.assistant .message-text [id*="chart"] {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: auto;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0ms; }
.typing-indicator .dot:nth-child(2) { animation-delay: 160ms; }
.typing-indicator .dot:nth-child(3) { animation-delay: 320ms; }

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

/* -----------------------------------------------------------------------------
   Input Island
   ----------------------------------------------------------------------------- */
.input-island-wrapper {
  padding: 16px 24px 24px;
  flex-shrink: 0;
}

.input-island {
  max-width: 768px;
  margin: 0 auto;
  background: var(--island-bg);
  border-radius: var(--island-radius);
  box-shadow: var(--island-shadow);
  border: 1px solid var(--island-border);
  transition: all var(--transition-normal);
  overflow: hidden;
}

.input-island:focus-within {
  border-color: var(--island-border-focus);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
}

.input-island textarea {
  width: 100%;
  padding: 20px 20px 12px;
  border: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  resize: none;
  outline: none;
  min-height: 60px;
  max-height: 200px;
  font-family: inherit;
}

.input-island textarea::placeholder {
  color: var(--text-muted);
}

/* Input Toolbar */
.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 12px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toolbar-btn:hover {
  background: #f1f5f9;
  color: var(--text-secondary);
}

.toolbar-btn svg {
  width: 20px;
  height: 20px;
}

/* Web Search Toggle */
.toolbar-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toolbar-toggle:hover {
  background: #f1f5f9;
}

.toolbar-toggle.active {
  background: rgba(17, 147, 212, 0.1);
  border-color: rgba(17, 147, 212, 0.3);
  color: var(--brand-blue);
}

.toolbar-toggle svg {
  width: 14px;
  height: 14px;
}

.toolbar-toggle .toggle-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-blue);
  display: none;
}

.toolbar-toggle.active .toggle-indicator {
  display: block;
}

/* Send Button */
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e2e8f0;
  border: none;
  color: #94a3b8;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
}

.send-btn:not(:disabled) {
  background: var(--accent-primary);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 35, 70, 0.3);
}

.send-btn:not(:disabled):hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:not(:disabled):active {
  transform: scale(0.95);
}

.send-btn svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

/* Input Disclaimer */
.input-disclaimer {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* File Upload Section */
.file-upload-section {
  max-width: 768px;
  margin: 0 auto 12px;
  padding: 0 24px;
}

.attached-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attached-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.attached-file .remove-file {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
}

.attached-file .remove-file:hover {
  color: #ef4444;
}

/* -----------------------------------------------------------------------------
   Mobile Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
  }

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

  /* Mobile Overlay */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
  }

  .sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .floating-header {
    padding: 12px 16px;
  }

  .input-island-wrapper {
    padding: 12px 16px 20px;
  }

  .welcome-screen {
    padding: 24px 16px;
  }

  .welcome-title {
    font-size: 24px;
  }

  .welcome-subtitle {
    font-size: 16px;
  }
}

/* -----------------------------------------------------------------------------
   Selection Mode (for bulk delete)
   ----------------------------------------------------------------------------- */
.selection-action-bar {
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 8px;
}

.selection-actions-left {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.selection-actions-left .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--sidebar-text);
  cursor: pointer;
}

.selection-count {
  font-size: 11px;
  color: var(--sidebar-text-muted);
}

.selection-actions-right {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--sidebar-text);
  font-size: 11px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  padding: 6px 12px;
  border-radius: 6px;
  background: #dc2626;
  border: none;
  color: white;
  font-size: 11px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Checkbox for selection */
.chat-item-checkbox {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  cursor: pointer;
}

/* -----------------------------------------------------------------------------
   Header Icons
   ----------------------------------------------------------------------------- */
.header-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 12px;
}

.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.header-icon-btn:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--text-primary);
}

.header-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

/* -----------------------------------------------------------------------------
   Export Action Buttons
   ----------------------------------------------------------------------------- */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

.export-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--island-border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.export-action-btn:hover {
  background: var(--sidebar-bg);
  border-color: var(--sidebar-bg);
  color: white;
}

.export-action-btn svg {
  width: 18px;
  height: 18px;
}

.table-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 4px;
  background: transparent;
  border: 1px solid var(--island-border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.table-export-btn:hover {
  background: #217346;
  border-color: #217346;
  color: white;
}

.table-export-btn img {
  width: 18px;
  height: 18px;
}

/* -----------------------------------------------------------------------------
   Utility Classes
   ----------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
