/* ==========================================================================
   DESIGN VARIABLES (WhatsApp Matching + Glassmorphism)
   ========================================================================== */
:root {
  /* Typography Stack */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Geist Mono', monospace;

  /* Color Palette - WhatsApp Web Dark Mode */
  --bg-main: #0b141a;          /* WhatsApp dark background */
  --bg-sidebar: #111b21;       /* WhatsApp sidebar background */
  --bg-header: #202c33;        /* WhatsApp header background */
  --bg-active: #2a3942;        /* WhatsApp active chat item */
  --bg-input: #1f2c34;         /* WhatsApp input background */
  
  --bubble-incoming: #202c33;  /* WhatsApp incoming bubble */
  --bubble-outgoing: #005c4b;  /* WhatsApp outgoing green bubble */
  
  --color-brand: #00a884;      /* WhatsApp bright green / active accent */
  --color-danger: #ea580c;     /* Orange-red */
  --color-alert: #eab308;      /* Gold */
  
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-focus: rgba(0, 168, 132, 0.5);
  
  --text-primary: #e9edef;     /* WhatsApp off-white primary text */
  --text-secondary: #8696a0;   /* WhatsApp grayish-blue muted text */
  --text-inactive: #667781;    /* WhatsApp darker placeholder text */

  /* Glassmorphism Refraction & Elevation */
  --glass-blur: blur(20px);
  --shadow-diffused: 0 12px 36px -8px rgba(0, 0, 0, 0.5), 0 8px 16px -8px rgba(0, 0, 0, 0.5);
  --shadow-inset-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  
  /* Layout Dimensions */
  --sidebar-w: 360px;
  --drawer-w: 390px;
  --header-h: 64px;
}

/* ==========================================================================
   RESET & STRUCTURE LOCKS
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  line-height: 1.5;
}

/* Background Depth Glows (Antigravity spatial layering) */
.bg-glow-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.bg-glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.08;
}

.sphere-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--color-brand) 0%, transparent 70%);
  top: -150px;
  left: -150px;
}

.sphere-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #2563eb 0%, transparent 70%);
  bottom: -200px;
  right: -200px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   MAIN SYSTEM LAYOUT
   ========================================================================== */
.app-wrapper {
  display: flex;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   LEFT PANEL: SIDEBAR (Chats Column)
   ========================================================================== */
.sidebar-container {
  width: var(--sidebar-w);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

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

.profile-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 168, 132, 0.15), rgba(37, 99, 235, 0.15));
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
}

.profile-avatar i {
  width: 20px;
  height: 20px;
}

.online-indicator {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-brand);
  border: 2px solid var(--bg-header);
  box-shadow: 0 0 6px var(--color-brand);
}

.profile-info h2 {
  font-size: 0.9rem;
  font-weight: 600;
}

.status-meta {
  font-size: 0.72rem;
  color: var(--color-brand);
  font-weight: 500;
}

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

.global-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  border-radius: 20px;
  transition: all 0.3s;
}

.ai-sparkle-icon {
  width: 16px;
  height: 16px;
  color: var(--color-brand);
}

/* Search Bar Area */
.search-section {
  padding: 8px 12px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
}

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

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.search-input-wrapper input {
  width: 100%;
  background-color: var(--bg-header);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px 8px 40px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  font-family: var(--font-sans);
  transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
  background-color: var(--bg-header);
  border-color: var(--border-focus);
}

/* Chat Feed sidebar scrollable */
.chats-list-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}

/* Chat Contact Cards */
.chat-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
}

.chat-card:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.chat-card.active {
  background-color: var(--bg-active);
  border-color: rgba(255, 255, 255, 0.02);
}

.chat-card-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.chat-card-avatar i {
  width: 22px;
  height: 22px;
}

.chat-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.chat-card-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-card-time {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.chat-card-excerpt {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-card-badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.ai-badge-pill {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.3s;
}

.ai-badge-pill.active {
  background: rgba(0, 168, 132, 0.1);
  border: 1px solid rgba(0, 168, 132, 0.25);
  color: var(--color-brand);
}

.ai-badge-pill.paused {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.ai-badge-pill i {
  width: 10px;
  height: 10px;
}

/* ==========================================================================
   CENTER PANEL: CHAT VIEWPORT
   ========================================================================== */
.chat-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  position: relative;
}

.chat-header {
  height: var(--header-h);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 5;
}

.active-contact-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-contact-profile .contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.active-contact-profile .contact-avatar i {
  width: 20px;
  height: 20px;
}

.contact-details h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-details p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.chat-actions {
  display: flex;
  align-items: center;
}

.chat-ai-override {
  display: flex;
  align-items: center;
  gap: 10px;
}

.override-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Messages container with custom repeating SVG pattern */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  /* WhatsApp Doodle Background Pattern (Teal/Green Subtle Tint) */
  background-color: #0b141a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%2300a884' fill-opacity='0.02'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm1-61c3.16 0 5.72-2.56 5.72-5.72 0-3.16-2.56-5.72-5.72-5.72-3.16 0-5.72 2.56-5.72 5.72 0 3.16 2.56 5.72 5.72 5.72zm53 3c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM9 58c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm23-5c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm50-13c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM3 13c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm81 2c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm-81 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm81 2c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM24 6c5.523 0 10-4.477 10-10S29.523-14 24-14s-10 4.477-10 10 4.477 10 10 10zm0 90c5.523 0 10-4.477 10-10S29.523 76 24 76s-10 4.477-10 10 4.477 10 10 10zm27-52c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm0 28c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5z'/%3E%3C/g%3E%3C/svg%3E");
}

/* Welcome frame (Default view when no chat is selected) */
.welcome-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  color: var(--text-secondary);
}

.welcome-card {
  max-width: 460px;
  text-align: center;
  padding: 36px;
  background: var(--surface-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  box-shadow: var(--shadow-diffused);
  animation: floatIn 0.5s ease-out;
}

.welcome-logo {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(0, 168, 132, 0.2), rgba(37, 99, 235, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
  margin: 0 auto 20px;
  box-shadow: 0 0 15px rgba(0, 168, 132, 0.2);
}

.welcome-logo i {
  width: 28px;
  height: 28px;
}

.welcome-card h2 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.welcome-card p {
  font-size: 0.85rem;
  line-height: 1.6;
}

.welcome-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: 24px 0;
}

.welcome-subtext {
  font-size: 0.75rem;
  color: var(--text-inactive);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ==========================================================================
   CHAT MESSAGES STREAM STYLING
   ========================================================================== */
.message {
  display: flex;
  flex-direction: column;
  max-width: 65%;
  margin-bottom: 2px; /* tight message stacking */
  animation: messageSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Add separation between different senders */
.message.incoming + .message.outgoing-manual,
.message.incoming + .message.outgoing-ai,
.message.outgoing-manual + .message.incoming,
.message.outgoing-ai + .message.incoming {
  margin-top: 12px;
}

.message-bubble {
  padding: 8px 12px 20px 12px; /* padding bottom leaves space for time stamp */
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-primary);
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.message-time {
  position: absolute;
  bottom: 4px;
  right: 10px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Senders Styles */
.message.incoming {
  align-self: flex-start;
}
.message.incoming .message-bubble {
  background-color: var(--bubble-incoming);
  border-top-left-radius: 0px; /* speech bubble tail simulation */
}

.message.outgoing-manual {
  align-self: flex-end;
}
.message.outgoing-manual .message-bubble {
  background-color: var(--bubble-outgoing);
  border-top-right-radius: 0px;
}
.message.outgoing-manual .message-time {
  color: rgba(233, 237, 239, 0.6);
}

.message.outgoing-ai {
  align-self: flex-end;
}
.message.outgoing-ai .message-bubble {
  background-color: var(--bubble-outgoing);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-top-right-radius: 0px;
  padding-right: 48px; /* space for the absolute AI tag */
}
.message.outgoing-ai .message-time {
  color: rgba(233, 237, 239, 0.6);
}

.message-bubble-ai-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.6rem;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border-radius: 4px;
  padding: 1px 4px;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 2px;
}

.message-bubble-ai-badge i {
  width: 8px;
  height: 8px;
}

/* ==========================================================================
   FOOTER: MESSAGE INPUT BAR
   ========================================================================== */
.chat-input-bar {
  background-color: var(--bg-header);
  padding: 12px 24px;
  border-top: 1px solid var(--border-subtle);
  z-index: 5;
}

.chat-input-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-input-form input {
  flex: 1;
  background-color: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  font-family: var(--font-sans);
  transition: all 0.3s;
}

.chat-input-form input:focus {
  border-color: var(--border-focus);
}

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

.send-message-btn:hover {
  color: var(--color-brand);
  background-color: rgba(255, 255, 255, 0.03);
}

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

/* ==========================================================================
   RIGHT PANEL: CONFIGURATION SETTINGS DRAWER
   ========================================================================== */
.settings-drawer {
  width: var(--drawer-w);
  height: 100dvh;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-diffused);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
}

.settings-drawer.collapsed {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.drawer-header {
  height: var(--header-h);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.drawer-title h2 {
  font-size: 1rem;
  font-weight: 600;
}

.drawer-title i {
  width: 18px;
  height: 18px;
  color: var(--color-brand);
}

.drawer-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

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

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.settings-group {
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 8px;
}

.group-title h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.group-title i {
  width: 14px;
  height: 14px;
  color: var(--color-brand);
}

/* Fields & Forms */
.form-field {
  margin-bottom: 12px;
}

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

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  font-family: var(--font-sans);
  transition: all 0.3s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--border-focus);
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-field {
  flex: 1;
}

.password-input-container {
  position: relative;
}

.password-input-container input {
  padding-right: 40px;
}

.eye-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.eye-toggle-btn i {
  width: 16px;
  height: 16px;
}

.drawer-save-btn {
  width: 100%;
  background: var(--color-brand);
  color: var(--bg-main);
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s;
  font-family: var(--font-sans);
}

.drawer-save-btn:hover {
  opacity: 0.9;
}

.drawer-save-btn:active {
  transform: scale(0.98);
}

.quick-instructions {
  margin-top: 16px;
  background-color: rgba(0, 168, 132, 0.02);
  border: 1px solid rgba(0, 168, 132, 0.1);
  border-radius: 12px;
  padding: 14px;
}

.quick-instructions h4 {
  font-size: 0.78rem;
  color: var(--color-brand);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-instructions h4 i {
  width: 14px;
  height: 14px;
}

.quick-instructions ul {
  padding-left: 14px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.quick-instructions li {
  margin-bottom: 6px;
}

.quick-instructions code {
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ==========================================================================
   GENERIC INTERACTIVE COMPONENTS (Toggles, buttons, toast)
   ========================================================================== */
.control-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.control-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

/* Custom switch sliders */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: rgba(0, 168, 132, 0.3);
}

input:checked + .slider:before {
  background-color: var(--color-brand);
  transform: translateX(16px);
}

/* Status Indicator Dot */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-inactive);
}

.connected .status-dot {
  background-color: var(--color-brand);
  box-shadow: 0 0 6px var(--color-brand);
}

/* Toast popup styling */
.toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  background-color: var(--bg-header);
  border: 1px solid var(--border-subtle);
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-diffused);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.toast-popup.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
}

.toast-body i {
  width: 18px;
  height: 18px;
  color: var(--color-brand);
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  color: var(--text-secondary);
  text-align: center;
  height: 60%;
}

.empty-state i {
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state span {
  font-size: 0.75rem;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES (Antigravity transitions)
   ========================================================================== */
@keyframes floatIn {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes messageSlideIn {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ==========================================================================
   SIDEBAR TABS & TAB BUTTONS
   ========================================================================== */
.sidebar-tabs {
  display: flex;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px;
  gap: 4px;
}

.sidebar-tabs .tab-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  transition: all 0.2s ease-in-out;
  font-family: var(--font-sans);
  min-width: 0;
}

.sidebar-tabs .tab-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.02);
}

.sidebar-tabs .tab-btn.active {
  color: var(--color-brand);
  background-color: rgba(0, 168, 132, 0.08);
  border-color: rgba(0, 168, 132, 0.2);
}

.sidebar-tabs .tab-btn i {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   INLINE CHAT ATTACHMENT DRAWER
   ========================================================================== */
.attachment-menu {
  position: absolute;
  bottom: 100%;
  left: 20px;
  right: 20px;
  background-color: var(--bg-header);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
  animation: floatIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.attachment-menu-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.15);
}

.attachment-menu-header h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.attachment-menu-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.attachment-menu-body .form-field {
  margin-bottom: 6px;
}

.attachment-menu-body .form-field label {
  font-size: 0.7rem;
  margin-bottom: 4px;
}

.attachment-menu-body .form-field input,
.attachment-menu-body .form-field select,
.attachment-menu-body .form-field textarea {
  background-color: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  font-size: 0.78rem;
}

.icon-pulse {
  animation: spin 2s linear infinite;
}

/* ==========================================================================
   LEADS CRM TABLE STYLING
   ========================================================================== */
.crm-table-container {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-diffused);
  margin-top: 10px;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.crm-table th {
  background-color: var(--bg-header);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.crm-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.crm-table tbody tr {
  transition: background-color 0.2s ease;
}

.crm-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.crm-table tbody tr:last-child td {
  border-bottom: none;
}

/* Service Badge Pills */
.crm-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.crm-badge.badge-visa {
  background: rgba(37, 99, 235, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.crm-badge.badge-classes {
  background: rgba(0, 168, 132, 0.1);
  color: var(--color-brand);
  border: 1px solid rgba(0, 168, 132, 0.2);
}

.crm-badge.badge-languages {
  background: rgba(234, 88, 12, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(234, 88, 12, 0.2);
}

/* CRM Table action buttons */
.crm-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin: 0 auto;
}

.crm-delete-btn:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

.crm-delete-btn i {
  width: 14px;
  height: 14px;
}

.crm-circle-btn {
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.crm-circle-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.document-link {
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.document-link:hover {
  background: rgba(0, 168, 132, 0.2) !important;
  transform: translateY(-1px);
}

#lead-export-btn {
  transition: transform 0.2s ease, opacity 0.2s ease;
}
#lead-export-btn:hover {
  opacity: 0.9;
}
#lead-export-btn:active {
  transform: scale(0.98);
}

#lead-service-filter {
  transition: border-color 0.2s ease;
}
#lead-service-filter:hover {
  border-color: var(--color-brand) !important;
}


/* ==========================================================================
   AUTHENTICATION OVERLAY STYLING
   ========================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(11, 20, 26, 0.85); /* WhatsApp background color with transparency */
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  max-width: 400px;
  width: 90%;
  padding: 36px 30px;
  background: rgba(32, 44, 51, 0.4); /* WhatsApp header color with glass transparency */
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-inset-highlight), var(--shadow-diffused);
  text-align: center;
  animation: floatIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(0, 168, 132, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
  margin: 0 auto 20px;
}

.login-logo i {
  width: 24px;
  height: 24px;
}

.login-card h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.login-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.login-btn {
  width: 100%;
  background-color: var(--color-brand);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--bg-main);
  font-weight: 600;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 168, 132, 0.2);
}

.login-btn:hover {
  background-color: #00bf96;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 168, 132, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn i {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   ANALYTICS VIEWS & CARDS
   ========================================================================== */
.anal-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.anal-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.anal-card {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-diffused);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.anal-card h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 6px 0;
  color: var(--text-primary);
}

.anal-card h3 {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.anal-card h4 {
  margin: 0 0 15px 0;
  font-size: 0.95rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.anal-card span.card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.anal-card span.card-subtext {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.anal-icon-wrapper {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.anal-activity-row {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.anal-activity-row span.day-label {
  width: 40px;
  font-weight: 600;
}

.anal-activity-row .bar-track {
  flex: 1;
  height: 16px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  border: 1px solid var(--border-subtle);
}

.anal-activity-row span.detail-label {
  flex-shrink: 0;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-left: 10px;
  min-width: 140px;
}

.anal-table-container {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow-x: auto;
  margin-top: 10px;
  max-width: 100%;
}

.anal-table-container table {
  width: 100%;
  min-width: 450px;
}


