/* WebChat Tab Styles - Professional, Soft & Harmonious */
/* Font fallback to system fonts to avoid CSP errors */

:root {
  /* Core Palette - Soft Emerald & Slate */
  --wa-primary: #10b981;
  --wa-primary-hover: #059669;
  --wa-primary-soft: rgba(16, 185, 129, 0.12);
  
  --wa-bg-app: #f8fafc;
  --wa-bg-panel: #ffffff;
  --wa-bg-sidebar: #ffffff;
  --wa-bg-chat: #f1f5f9;
  
  --wa-text-main: #334155;
  --wa-text-muted: #94a3b8;
  --wa-text-light: #cbd5e1;
  
  --wa-border: #e2e8f0;
  --wa-border-light: #f1f5f9;
  
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d1fae5;
  --wa-bubble-out-text: #064e3b;
  
  --wa-danger: #ef4444;
  --wa-danger-soft: #fee2e2;

  /* Menu Variables (for JS injected components) */
  --wc-action-bg: #ffffff;
  --wc-action-fg: #334155;
  --wc-action-hover: #f1f5f9;
  
  --wa-shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --wa-shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --wa-shadow-md: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
  
  --wa-radius-lg: 16px;
  --wa-radius-md: 12px;
  --wa-radius-sm: 8px;
  
  --wa-font-sans: 'Segoe UI', 'Tahoma', 'Geneva', 'Verdana', sans-serif;
}

[data-theme="dark"] {
  --wa-primary: #34d399;
  --wa-primary-hover: #10b981;
  --wa-primary-soft: rgba(52, 211, 153, 0.15);
  
  --wa-bg-app: #0f172a;
  --wa-bg-panel: #1e293b;
  --wa-bg-sidebar: #1e293b;
  --wa-bg-chat: #0b141a;
  
  --wa-text-main: #f1f5f9;
  --wa-text-muted: #94a3b8;
  --wa-text-light: #475569;
  
  --wa-border: #334155;
  --wa-border-light: #1e293b;
  
  --wa-bubble-in: #334155;
  --wa-bubble-out: #065f46;
  --wa-bubble-out-text: #ecfdf5;
  
  --wa-danger: #f87171;
  --wa-danger-soft: #450a0a;

  /* Menu Variables Dark */
  --wc-action-bg: #1e293b;
  --wc-action-fg: #f1f5f9;
  --wc-action-hover: #334155;
}

/* Global Reset & Base - Scoped to ID for specificity */
#wa-app-root * { box-sizing: border-box; outline: none; }
#wa-app-root [hidden] { display: none !important; }

#wa-app-root.wa-container {
  width: 100%;
  height: calc(100vh - 16px); /* Maximize height with small margin */
  min-height: 400px;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg-app);
  border: 1px solid var(--wa-border);
  box-shadow: var(--wa-shadow-md);
  border-radius: var(--wa-radius-lg);
  overflow: hidden;
  font-family: var(--wa-font-sans);
  color: var(--wa-text-main);
  transition: all 0.3s ease;
  position: relative;
  direction: rtl;
  text-align: right;
  margin: 8px auto; /* Center with margin */
}

/* Layout */
#wa-app-root .wa-layout { display: flex; flex: 1; overflow: hidden; position: relative; }

/* Sidebar Styles */
#wa-app-root .wa-sidebar {
  width: 320px; /* Reduced from 360px */
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg-sidebar);
  border-inline-end: 1px solid var(--wa-border);
  z-index: 20;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#wa-app-root .wa-sidebar-header {
  padding: 12px 16px; /* Reduced padding */
  background: var(--wa-bg-panel);
  border-bottom: 1px solid var(--wa-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px; /* Reduced height */
}

#wa-app-root .wa-sidebar-header-start { display: flex; align-items: center; gap: 12px; }

#wa-app-root .wa-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--wa-primary-soft);
  color: var(--wa-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s;
}
#wa-app-root .wa-user-avatar:hover { transform: scale(1.05); }

#wa-app-root .wa-sidebar-tools { display: flex; gap: 4px; border: none; padding: 0; margin: 0; min-inline-size: 0; }

#wa-app-root .wc-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--wa-text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}
#wa-app-root .wc-btn:hover { background: var(--wa-bg-app); color: var(--wa-text-main); }

#wa-app-root .wc-btn-discover {
  font-size: 12px; padding: 6px 12px;
  background: linear-gradient(135deg, var(--wa-primary) 0%, var(--wa-primary-hover) 100%);
  color: white; border: none; border-radius: 20px;
  box-shadow: 0 4px 10px var(--wa-primary-soft);
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; transition: transform 0.2s;
  font-family: inherit;
  font-weight: 600;
}
#wa-app-root .wc-btn-discover:hover { transform: translateY(-1px); box-shadow: 0 6px 12px var(--wa-primary-soft); }

/* Search & Filters */
#wa-app-root .wa-search-container {
  padding: 12px 20px;
  background: var(--wa-bg-sidebar);
}
#wa-app-root .wa-search-container input {
  width: 100%;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--wa-border);
  background: var(--wa-bg-app);
  color: var(--wa-text-main);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}
#wa-app-root .wa-search-container input:focus {
  border-color: var(--wa-primary);
  background: var(--wa-bg-panel);
  box-shadow: 0 0 0 3px var(--wa-primary-soft);
}

#wa-app-root .wc-filters {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  background: var(--wa-bg-sidebar);
  border-bottom: 1px solid var(--wa-border);
  overflow-x: auto;
  scrollbar-width: none;
}
#wa-app-root .wc-filters::-webkit-scrollbar { display: none; }

#wa-app-root .wc-chip {
  border: 1px solid var(--wa-border);
  background: var(--wa-bg-panel);
  color: var(--wa-text-muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
}
#wa-app-root .wc-chip:hover { background: var(--wa-bg-app); color: var(--wa-text-main); border-color: var(--wa-text-muted); }
#wa-app-root .wc-chip.active {
  background: var(--wa-primary);
  color: #fff;
  border-color: var(--wa-primary);
  box-shadow: 0 2px 8px var(--wa-primary-soft);
}
#wa-app-root .wc-chip .c {
  background: rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 0 5px;
  font-size: 10px;
  min-width: 16px;
  text-align: center;
}
#wa-app-root .wc-chip.active .c { background: rgba(255,255,255,0.2); }

/* Session List */
#wa-app-root .wa-session-list { flex: 1; overflow-y: auto; list-style: none; padding: 0; margin: 0; }

#wa-app-root .wc-session-item {
  display: flex;
  align-items: center;
  padding: 16px 20px; /* More breathing room */
  border-bottom: 1px solid var(--wa-border-light);
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}
#wa-app-root .wc-session-item:hover { background: var(--wa-bg-app); }
#wa-app-root .wc-session-item.active {
  background: var(--wa-bg-app); /* Subtle active state */
}
#wa-app-root .wc-session-item.active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: var(--wa-primary);
  border-top-right-radius: 4px; border-bottom-right-radius: 4px;
}

#wa-app-root .wc-session-avatar {
  width: 52px; height: 52px; /* Larger avatars */
  border-radius: 50%;
  background: var(--wa-bg-app); color: var(--wa-text-muted);
  border: 1px solid var(--wa-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-inline-end: 16px; flex-shrink: 0;
  position: relative;
}
#wa-app-root .wc-session-main { flex: 1; min-width: 0; }
#wa-app-root .wc-session-title {
  font-weight: 700; font-size: 15px; color: var(--wa-text-main);
  margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#wa-app-root .wc-session-last {
  font-size: 13px; color: var(--wa-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#wa-app-root .wc-session-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-inline-start: 10px;
}
#wa-app-root .wc-time { font-size: 11px; color: var(--wa-text-muted); font-weight: 500; }
#wa-app-root .wc-badge {
  background: var(--wa-primary); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center;
  box-shadow: 0 2px 4px var(--wa-primary-soft);
}

/* Chat Area */
#wa-app-root .wa-chatpane {
  flex: 1; display: flex; flex-direction: column; position: relative;
  background: var(--wa-bg-chat);
}
#wa-app-root .wa-chat-area { display: flex; flex-direction: column; height: 100%; width: 100%; }

#wa-app-root .wa-chat-header {
  padding: 0 20px;
  height: 56px; /* Reduced height */
  background: var(--wa-bg-panel);
  border-bottom: 1px solid var(--wa-border);
  display: flex; justify-content: space-between; align-items: center;
  z-index: 10;
  box-shadow: var(--wa-shadow-xs);
}
#wa-app-root .wc-conv-meta { display: flex; align-items: center; gap: 12px; }
#wa-app-root .wc-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--wa-bg-app); color: var(--wa-text-muted);
  border: 1px solid var(--wa-border);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
#wa-app-root .wc-conv-titles { display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
#wa-app-root .wc-title-row { display: flex; align-items: center; gap: 8px; }
#wa-app-root .wc-conv-title { 
  font-weight: 700; 
  font-size: 14px; 
  color: var(--wa-text-main); 
  line-height: 1.2; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  cursor: pointer;
}
#wa-app-root .wc-conv-title.expanded { white-space: normal; overflow: visible; word-break: break-word; }
#wa-app-root .wc-conv-sub { font-size: 12px; color: var(--wa-text-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
#wa-app-root .wc-conv-sub::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--wa-text-light);
}

#wa-app-root .wc-conv-actions { display: flex; gap: 8px; }
#wa-app-root .wc-btn.danger { color: var(--wa-danger); }
#wa-app-root .wc-btn.danger:hover { background: var(--wa-danger-soft); }

/* Messages Area */
#wa-app-root .wa-message-area {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  background: var(--wa-bg-chat);
  scroll-behavior: smooth;
  /* Fix for dark bar issue - ensure no background image or gradient leaks */
  background-image: none !important;
}

#wa-app-root .wc-message-scroll { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }

/* Typing Indicator Fix */
#wa-app-root .wc-typing {
  padding: 8px 16px;
  margin: 0 24px 12px;
  background: var(--wa-bg-panel);
  border-radius: 16px;
  width: fit-content;
  box-shadow: var(--wa-shadow-xs);
  display: flex; gap: 4px; align-items: center;
  min-height: 36px;
}
#wa-app-root .wc-typing[hidden] { display: none !important; }
#wa-app-root .wc-typing .dot {
  width: 6px; height: 6px; background: var(--wa-text-muted); border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
#wa-app-root .wc-typing .dot:nth-child(1) { animation-delay: -0.32s; }
#wa-app-root .wc-typing .dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

#wa-app-root .wc-day-sep {
  align-self: center;
  background: var(--wa-bg-panel);
  color: var(--wa-text-muted);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin: 16px 0;
  box-shadow: var(--wa-shadow-xs);
  border: 1px solid var(--wa-border-light);
}

#wa-app-root .wc-msg-row { display: flex; margin-bottom: 2px; width: 100%; }
#wa-app-root .wc-msg-bubble {
  max-width: 65%;
  width: fit-content;
  padding: 8px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

#wa-app-root .wc-msg-row.in { justify-content: flex-start; }
#wa-app-root .wc-msg-row.in .wc-msg-bubble {
  background: var(--wa-bubble-in);
  color: var(--wa-text-main);
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 2px;
}

#wa-app-root .wc-msg-row.out { justify-content: flex-end; }
#wa-app-root .wc-msg-row.out .wc-msg-bubble {
  background: var(--wa-bubble-out);
  color: var(--wa-bubble-out-text);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 2px;
}

#wa-app-root .wc-msg-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 4px; font-size: 11px; opacity: 0.7;
}
#wa-app-root .wc-msg-ticks { font-size: 12px; }
#wa-app-root .wc-msg-ticks.st-read { color: var(--wa-primary); }
#wa-app-root .wc-msg-ticks.st-delivered { color: var(--wa-text-muted); }

/* Composer */
#wa-app-root .wa-composer-area {
  background: var(--wa-bg-panel);
  padding: 10px 16px; /* Reduced padding */
  border-top: 1px solid var(--wa-border);
  position: relative;
}

#wa-app-root .wc-composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--wa-bg-app);
  padding: 6px 10px; /* Compact padding */
  border-radius: 20px;
  border: 1px solid var(--wa-border);
  transition: all 0.2s;
  min-height: 44px;
}
#wa-app-root .wc-composer:focus-within {
  background: var(--wa-bg-panel);
  border-color: var(--wa-primary);
  box-shadow: 0 0 0 2px var(--wa-primary-soft);
}

#wa-app-root .wc-composer-tools { display: flex; gap: 2px; position: relative; }
#wa-app-root .wc-tools-menu {
  display: flex; gap: 4px;
  position: absolute;
  bottom: 100%;
  inset-inline-start: 0;
  margin-bottom: 8px;
  background: var(--wa-bg-panel);
  padding: 6px;
  border-radius: 50px;
  box-shadow: var(--wa-shadow-md);
  border: 1px solid var(--wa-border);
  animation: toolsPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}
@keyframes toolsPop { from { opacity: 0; transform: scale(0.8) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
#wa-app-root .wc-tools-menu[hidden] { display: none !important; }

#wa-app-root #wcToolsToggle {
  transition: transform 0.2s;
}
#wa-app-root #wcToolsToggle.active {
  transform: rotate(45deg);
  background: var(--wa-bg-panel);
  color: var(--wa-primary);
}

#wa-app-root .wc-input-wrapper { flex: 1; display: flex; flex-direction: column; justify-content: center; }

#wa-app-root #wcInput {
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 4px;
  font-size: 14px;
  resize: none;
  max-height: 100px; /* Limit max height */
  min-height: 24px;
  color: var(--wa-text-main);
  font-family: inherit;
  line-height: 1.4;
}
#wa-app-root #wcInput::placeholder { color: var(--wa-text-light); }

#wa-app-root .wc-send-wrapper { display: flex; gap: 6px; align-items: center; }

#wa-app-root .wc-btn.send {
  background: var(--wa-primary);
  color: white;
  width: 36px; height: 36px; /* Smaller send button */
  border-radius: 50%;
  padding: 0;
  box-shadow: 0 2px 8px var(--wa-primary-soft);
  transition: transform 0.2s, background 0.2s;
}
#wa-app-root .wc-btn.send:hover { background: var(--wa-primary-hover); transform: scale(1.05); }
#wa-app-root .wc-btn.ai { color: var(--wa-primary); font-size: 20px; }
#wa-app-root .wc-btn.ai:hover { background: var(--wa-primary-soft); }

/* Quick Panel & Emoji */
#wa-app-root .wc-quick-panel {
  position: absolute;
  z-index: 30;
  background: var(--wa-bg-panel);
  border: 1px solid var(--wa-border);
  border-radius: 16px;
  padding: 8px;
  display: grid; gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--wa-shadow-md);
  bottom: 100%; left: 0; right: 0;
  margin-bottom: 12px;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#wa-app-root .wc-quick-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  background: var(--wa-bg-app);
  transition: background 0.2s;
}
#wa-app-root .wc-quick-item:hover { background: var(--wa-primary-soft); }
#wa-app-root .wc-quick-item .txt { font-size: 13px; color: var(--wa-text-main); }

/* Emoji Panel */
#wa-app-root .wc-emoji-panel {
  position: absolute;
  z-index: 30;
  background: var(--wa-bg-panel);
  border: 1px solid var(--wa-border);
  border-radius: 16px;
  box-shadow: var(--wa-shadow-md);
  width: 320px;
  height: 350px;
  display: flex; flex-direction: column;
  bottom: 100%; left: 0;
  margin-bottom: 12px;
  overflow: hidden;
  animation: slideUp 0.2s ease-out;
}
#wa-app-root .wc-emoji-header { padding: 10px; border-bottom: 1px solid var(--wa-border); background: var(--wa-bg-app); }
#wa-app-root #wcEmojiSearch { width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--wa-border); font-size: 13px; }
#wa-app-root .wc-emoji-body { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
#wa-app-root .wc-emoji-body .e { font-size: 20px; cursor: pointer; padding: 4px; border-radius: 6px; text-align: center; }
#wa-app-root .wc-emoji-body .e:hover { background: var(--wa-bg-app); }

/* Scrollbars */
#wa-app-root ::-webkit-scrollbar { width: 6px; height: 6px; }
#wa-app-root ::-webkit-scrollbar-track { background: transparent; }
#wa-app-root ::-webkit-scrollbar-thumb { background: var(--wa-text-light); border-radius: 3px; }
#wa-app-root ::-webkit-scrollbar-thumb:hover { background: var(--wa-text-muted); }

/* Responsive */
@media (max-width: 900px) {
  #wa-app-root .wa-sidebar {
    position: absolute; inset: 0; width: 100%; max-width: none;
    transform: translateX(100%); /* Hide off-canvas (RTL: move right) */
  }
  #wa-app-root .wa-sidebar.is-open { transform: translateX(0); }
  #wa-app-root .wa-chatpane { width: 100%; }
  #wa-app-root.wa-container {
    height: 100vh; /* Full screen on mobile */
    margin: 0;
    border-radius: 0;
    border: none;
  }
  
  /* Compact Composer for Mobile */
  #wa-app-root .wc-composer { padding: 4px 8px; min-height: 40px; gap: 4px; }
  #wa-app-root .wc-btn.send { width: 32px; height: 32px; font-size: 14px; }
  #wa-app-root .wc-btn.ai { width: 32px; height: 32px; font-size: 16px; }
  #wa-app-root .wc-send-wrapper { gap: 4px; flex-direction: column; }
  #wa-app-root .wc-composer-tools .wc-btn { width: 32px; height: 32px; font-size: 14px; }
}

/* Message Options Trigger - Subtle */
.wc-msg-opt-trigger {
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 0 !important; /* Hide default text/icon */
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.05);
  position: absolute; top: 4px; left: 4px;
}
.wc-msg-opt-trigger::after {
  content: '\f141'; /* FontAwesome ellipsis-h */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 12px;
  color: var(--wa-text-muted);
}
#wa-app-root .wc-msg-bubble:hover .wc-msg-opt-trigger { opacity: 1; }
.wc-msg-opt-trigger:hover { background: rgba(0,0,0,0.1); }

/* Force override for JS injected menu */
.wc-msg-menu {
  background: var(--wc-action-bg) !important;
  color: var(--wc-action-fg) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
  border: 1px solid var(--wa-border) !important;
  border-radius: 12px !important;
  z-index: 9999 !important;
}
.wc-msg-menu-item:hover {
  background: var(--wc-action-hover) !important;
}

/* Utilities */
#wa-app-root .wc-error { padding: 12px; background: var(--wa-danger-soft); color: var(--wa-danger); border-radius: 8px; margin: 16px; font-size: 13px; text-align: center; border: 1px solid rgba(0,0,0,0.05); }
#wa-app-root .wc-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--wa-text-muted); }
#wa-app-root .wc-empty-icon { font-size: 64px; opacity: 0.2; margin-bottom: 16px; color: var(--wa-text-main); }
#wa-app-root .wc-empty-text { font-size: 16px; font-weight: 500; }

/* Footer - Moved to Sidebar */
#wa-app-root .wa-sidebar-footer {
  padding: 8px 16px;
  background: var(--wa-bg-panel);
  border-top: 1px solid var(--wa-border-light);
  text-align: center;
  font-size: 10px;
  color: var(--wa-text-muted);
  margin-top: auto; /* Push to bottom */
}

/* Info Pane */
#wa-app-root .wc-info-pane {
  width: 280px; background: var(--wa-bg-sidebar); border-inline-start: 1px solid var(--wa-border);
  display: flex; flex-direction: column;
}
#wa-app-root .wc-info-header { padding: 16px; font-weight: 700; border-bottom: 1px solid var(--wa-border); }
#wa-app-root .wc-info-body { padding: 16px; overflow-y: auto; }

/* Scroll Down Button */
.wc-scroll-down-btn {
  position: absolute;
  bottom: 80px;
  left: 20px; /* RTL friendly position */
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa-bg-panel);
  color: var(--wa-text-muted);
  border: 1px solid var(--wa-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}
.wc-scroll-down-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.wc-scroll-down-btn:hover {
  background: var(--wa-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
  border-color: var(--wa-primary);
}

/* Professional Header Styling */
#wa-app-root .wa-sidebar-header {
  padding: 0 16px;
  height: 64px;
  background: var(--wa-bg-sidebar);
  border-bottom: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#wa-app-root .wa-sidebar-header-start {
  display: flex;
  align-items: center;
}

#wa-app-root .wa-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
  transition: all 0.2s ease;
}
#wa-app-root .wa-user-avatar:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

/* Branding Title */
#wa-app-root .wc-brand-title {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-inline-start: 12px;
  user-select: none;
}

#wa-app-root .wc-brand-main {
  font-family: 'Segoe UI', sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--wa-text-main) 30%, var(--wa-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  /* Fallback for non-webkit */
  color: var(--wa-text-main);
}

#wa-app-root .wc-brand-dot {
  width: 8px;
  height: 8px;
  background: var(--wa-primary);
  border-radius: 50%;
  margin-inline-start: 2px;
  box-shadow: 0 0 8px var(--wa-primary-soft);
}

#wa-app-root .wa-sidebar-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--wa-bg-app);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--wa-border-light);
}

#wa-app-root .wc-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--wa-text-muted);
  font-size: 15px;
  transition: all 0.2s ease;
  background: transparent;
}

#wa-app-root .wc-btn:hover {
  background: var(--wa-bg-panel);
  color: var(--wa-primary);
  transform: translateY(-1px);
}

/* Special styling for Discover button icon */
#wa-app-root .wc-btn-discover-icon {
  color: #f59e0b; /* Amber color for discovery/book */
  background: rgba(245, 158, 11, 0.1);
}
#wa-app-root .wc-btn-discover-icon:hover {
  background: rgba(245, 158, 11, 0.2);
  color: #d97706;
}

/* Specific icon colors on hover */
#wa-app-root #wcEmbedBtn:hover { color: #8b5cf6; background: rgba(139, 92, 246, 0.1); }
#wa-app-root #wcNotifyBtn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
#wa-app-root #wcRefreshSessions:hover { color: #10b981; background: rgba(16, 185, 129, 0.1); }

/* Embed Modal Professional Styling */
.wc-embed-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wc-embed-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wc-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--wa-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mv-help {
  margin: 0;
  font-size: 13px;
  color: var(--wa-text-muted);
  line-height: 1.5;
}
.mv-help code {
  background: rgba(0,0,0,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #f59e0b;
}

.wc-code-block-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 8px;
}

.wc-code-block {
  flex: 1;
  background: transparent;
  border: none;
  color: #a5b4fc; /* Light indigo for code */
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  resize: none;
  outline: none;
  direction: ltr;
  line-height: 1.4;
}
.wc-code-block.single-line {
  height: 36px;
  padding: 8px 0;
}

.wc-code-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wc-code-block.single-line + .wc-code-actions {
  flex-direction: row;
}

.wc-btn-action {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  min-width: 32px;
  height: 32px;
}

.wc-btn-action.primary {
  background: var(--wa-primary);
  color: white;
}
.wc-btn-action.primary:hover {
  background: var(--wa-primary-hover);
}

.wc-btn-action.secondary {
  background: rgba(255,255,255,0.1);
  color: var(--wa-text-main);
}
.wc-btn-action.secondary:hover {
  background: rgba(255,255,255,0.15);
}

.wc-btn-action.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.wc-btn-action.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.wc-embed-divider {
  height: 1px;
  background: var(--wa-border);
  opacity: 0.5;
  margin: 0 10px;
}

.wc-status-msg {
  font-size: 12px;
  color: #10b981;
  min-height: 18px;
}

/* Embed Modal Sizing & Close Button */
.wc-embed-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.wc-embed-card {
  background: var(--wa-bg-panel);
  color: var(--wa-text-main);
  border: 1px solid var(--wa-border);
  border-radius: 16px;
  padding: 0; /* Reset padding, handled by header/body */
  width: auto; /* Fit content */
  max-width: 90vw;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: modalScaleUp 0.2s ease-out;
}

@keyframes modalScaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.wc-embed-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--wa-bg-app);
  border-radius: 16px 16px 0 0;
  flex-direction: row-reverse; /* Move close button to left (in RTL) */
}

.wc-embed-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--wa-text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wc-close-embed {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  padding: 0;
}

.wc-close-embed:hover {
  background: #ef4444;
  color: white;
  transform: rotate(90deg);
}

/* Improved Session List Typography & Actions */
#wa-app-root .wc-session-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--wa-text-main);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  /* Ensure good contrast */
  text-shadow: 0 0 1px rgba(0,0,0,0.01);
}

#wa-app-root .wc-session-last {
  font-size: 13px;
  color: var(--wa-text-muted);
  font-weight: 400;
  opacity: 0.85;
}

/* Redesigned Arrow Button (More subtle) */
#wa-app-root .wc-more {
  background: transparent;
  border: none;
  color: var(--wa-text-light);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s;
  opacity: 0; /* Hidden by default */
  transform: translateY(2px);
}

/* Show on hover */
#wa-app-root .wc-session-item:hover .wc-more {
  opacity: 1;
  transform: translateY(0);
}

#wa-app-root .wc-more:hover {
  background: var(--wa-bg-app);
  color: var(--wa-primary);
}

/* Active state for menu open */
#wa-app-root .wc-more.active {
  opacity: 1;
  color: var(--wa-primary);
  background: var(--wa-primary-soft);
}
/* Enhanced Unread Badge & Meta Interaction */

/* Meta container - Relative for absolute positioning of the 'more' button */
#wa-app-root .wc-session-meta {
    position: relative;
    min-width: 50px;
    padding-bottom: 2px;
    justify-content: flex-start; /* Align to top */
}

/* Time - Top right */
#wa-app-root .wc-time {
    margin-bottom: 4px;
    font-size: 10px;
    opacity: 0.8;
}

/* The Unread Badge - Beautiful & Prominent */
#wa-app-root .wc-badge.wc-badge-unread {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 0 7px;
    height: 20px;
    min-width: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(239, 68, 68, 0.3);
    margin-top: 2px;
    animation: wc-badge-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255,255,255,0.15);
    transition: all 0.2s ease;
    z-index: 1;
}

@keyframes wc-badge-pop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* The 'More' button - Absolute positioning */
#wa-app-root .wc-more {
    position: absolute;
    bottom: -2px;
    right: -6px;
    width: 28px;
    height: 28px;
    background: transparent;
    border-radius: 50%;
    z-index: 2;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-text-muted);
}

#wa-app-root .wc-more:hover {
    background: var(--wa-primary-soft);
    color: var(--wa-primary);
}

/* Interaction: On hover, show More button, hide Badge (if present) */
#wa-app-root .wc-session-item:hover .wc-more {
    opacity: 1;
    transform: scale(1);
}

/* If there is a badge, fade it out on hover so the button is clear */
#wa-app-root .wc-session-item:hover .wc-badge.wc-badge-unread {
    opacity: 0;
    transform: scale(0.8);
}

/* Dark mode adjustments */
[data-theme="dark"] #wa-app-root .wc-badge.wc-badge-unread {
    box-shadow: 0 3px 8px rgba(239, 68, 68, 0.5);
    border: none;
}

/* Collapsible Header Actions */
#wa-app-root .wc-header-actions-collapsible {
  position: relative;
}

#wa-app-root .wc-arrow-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--wa-text-muted);
  transition: all 0.2s;
}
#wa-app-root .wc-arrow-btn:hover {
  background: var(--wa-bg-app);
  color: var(--wa-text-main);
}
#wa-app-root .wc-arrow-btn.active {
  background: var(--wa-bg-app);
  color: var(--wa-primary);
  transform: rotate(180deg);
}

#wa-app-root .wc-actions-menu {
  position: absolute;
  top: 100%;
  left: 0; /* Align to left edge in RTL context (or right if LTR) */
  margin-top: 8px;
  background: var(--wa-bg-panel);
  border: 1px solid var(--wa-border);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--wa-shadow-md);
  z-index: 100;
  min-width: 44px;
  align-items: center;
  animation: menuSlideDown 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}
/* RTL adjustment: if direction is rtl, left:0 aligns to left. */

@keyframes menuSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

#wa-app-root .wc-actions-menu .wc-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
#wa-app-root .wc-actions-menu .wc-btn:hover {
  background: var(--wa-bg-app);
}

#wa-app-root .wc-sep {
  width: 20px;
  height: 1px;
  background: var(--wa-border);
  margin: 4px 0;
}

/* Sidebar Tools Collapsible */
#wa-app-root .wa-sidebar-tools-collapsible {
  position: relative;
  display: flex;
  align-items: center;
}

#wa-app-root .wc-sidebar-menu {
  position: absolute;
  top: 100%;
  left: 0; /* Align left */
  margin-top: 8px;
  background: var(--wa-bg-panel);
  border: 1px solid var(--wa-border);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--wa-shadow-md);
  z-index: 100;
  min-width: 180px; /* Wider for text */
  animation: menuSlideDown 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#wa-app-root .wc-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--wa-text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

#wa-app-root .wc-menu-item:hover {
  background: var(--wa-bg-app);
  color: var(--wa-primary);
}

#wa-app-root .wc-menu-item i {
  width: 20px;
  text-align: center;
  font-size: 14px;
}
