/* ========================================================
   PT BEYOND TECHNOLOGY INFINITE - CRM & LIVECHAT STYLES
   Design System: Anti-AISLOP, Professional Lightmode, Clean
   ======================================================== */

:root {
  --bg-body: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-hover: #E2E8F0;
  
  --border-color: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-focus: #2563EB;
  
  --text-main: #0F172A;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;
  
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-border: #BFDBFE;
  
  --wa-green: #059669;
  --wa-green-hover: #047857;
  --wa-green-light: #ECFDF5;
  --wa-green-border: #A7F3D0;

  --ai-purple: #7C3AED;
  --ai-purple-light: #F5F3FF;
  --ai-purple-border: #DDD6FE;
  
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --warning-border: #FDE68A;
  
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', var(--font-sans);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-body);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
}

/* Custom Minimal Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Base Layout Structure */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-body);
}

/* ========================================================
   1. PRIMARY SIDEBAR
   ======================================================== */
.app-sidebar {
  width: 240px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  user-select: none;
}

.sidebar-top {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border-color);
}

.brand-link {
  display: block;
  text-decoration: none;
}

.brand-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  display: block;
}

.brand-subtext {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  text-align: left;
  width: 100%;
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

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

.nav-item:hover i {
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.nav-item.active i {
  color: var(--primary);
}

.nav-badge {
  margin-left: auto;
  background-color: var(--primary);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1;
}

.ai-status-indicator {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--wa-green);
}

.pulse-green {
  box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border-color);
  background-color: #FAFAFA;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.connection-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online { background-color: var(--wa-green); }
.status-dot.offline { background-color: var(--danger); }

.official-number-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.official-number-card .wa-icon {
  font-size: 18px;
  color: var(--wa-green);
}

.official-number-card .num-details {
  display: flex;
  flex-direction: column;
}

.official-number-card .lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.official-number-card .num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

/* ========================================================
   2. MAIN APPLICATION CONTENT AREA
   ======================================================== */
.app-main {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-body);
}

.view-panel {
  display: none;
  height: 100%;
  width: 100%;
  overflow-y: auto;
}

.view-panel.active {
  display: flex;
}

/* ========================================================
   VIEW A: LIVECHAT 3-COLUMN INTERFACE
   ======================================================== */
#viewLivechat {
  display: none;
  height: 100%;
  width: 100%;
  overflow: hidden;
}
#viewLivechat.active {
  display: flex;
}

/* Column 1: Conversations List */
.chat-list-column {
  width: 350px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.chat-list-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title-row h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.chat-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.chat-search-box i {
  position: absolute;
  left: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.chat-search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

.chat-search-box input:focus {
  background-color: #FFFFFF;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.chat-filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.filter-pill.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.chat-conversations-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Single Lead/Chat Item */
.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  cursor: pointer;
  transition: background-color 0.15s ease;
  position: relative;
}

.conv-item:hover {
  background-color: var(--bg-subtle);
}

.conv-item.active {
  background-color: #F8FAFC;
  border-left: 3px solid var(--primary);
}

.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #E2E8F0;
  color: #334155;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.conv-item.unread .conv-avatar {
  background: var(--primary-light);
  color: var(--primary);
}

.conv-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.conv-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 11px;
  color: var(--text-subtle);
  white-space: nowrap;
}

.conv-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conv-company {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-stage-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background-color: var(--bg-subtle);
  color: var(--text-body);
}

.conv-snippet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}

.conv-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-item.unread .conv-snippet {
  font-weight: 600;
  color: var(--text-main);
}

.conv-unread-count {
  background-color: var(--wa-green);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.chat-list-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  background-color: #FAFAFA;
}

.btn-text-action {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background-color: #FFFFFF;
  border: 1px dashed var(--border-strong);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-text-action:hover {
  background-color: var(--bg-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

/* Column 2: Active Chat Room */
.chat-thread-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #FFFFFF;
  height: 100%;
  min-width: 0;
  position: relative;
}

/* Empty Thread State */
.empty-thread-state {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 440px;
  padding: 30px;
}

.empty-icon-box {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--wa-green-light);
  color: var(--wa-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 20px;
}

.empty-thread-state h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
}

.empty-thread-state p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.quick-tips {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  width: 100%;
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-body);
}

.tip-item i {
  color: var(--primary);
  font-size: 14px;
}

/* Active Chat Shell */
.active-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.chat-topbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 10;
}

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

.mobile-back-btn {
  display: none;
}

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #E2E8F0;
  color: #334155;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.customer-info-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customer-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.customer-name-row h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.stage-tag-pill {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.customer-sub-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-toggle-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-body);
}

.ai-toggle-box .toggle-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-body);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-toggle-box .toggle-label i {
  color: var(--wa-green);
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #CBD5E1;
  transition: .2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
}
input:checked + .slider { background-color: var(--wa-green); }
input:checked + .slider:before { transform: translateX(14px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

.btn-icon-soft {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  color: var(--text-body);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-icon-soft:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.wa-direct-link:hover {
  color: var(--wa-green);
  border-color: var(--wa-green);
}

/* Messages Stream */
.messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: #F8FAFC;
}

/* Message Bubble Types */
.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.msg-bubble-wrap.customer {
  align-self: flex-start;
}

.msg-bubble-wrap.agent,
.msg-bubble-wrap.ai {
  align-self: flex-end;
}

.msg-bubble-wrap.system {
  align-self: center;
  max-width: 85%;
}

.msg-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

/* Customer message: White card with subtle border */
.msg-bubble-wrap.customer .msg-bubble {
  background-color: #FFFFFF;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border-top-left-radius: 2px;
}

/* Human Agent message: Primary Blue */
.msg-bubble-wrap.agent .msg-bubble {
  background-color: var(--primary);
  color: #FFFFFF;
  border-top-right-radius: 2px;
}

/* AI Auto-Reply message: Emerald / Green WhatsApp style */
.msg-bubble-wrap.ai .msg-bubble {
  background-color: var(--wa-green-light);
  border: 1px solid var(--wa-green-border);
  color: #064E3B;
  border-top-right-radius: 2px;
}

.ai-pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: #FFFFFF;
  color: var(--wa-green);
  border: 1px solid var(--wa-green-border);
  padding: 1px 6px;
  border-radius: 999px;
  margin-bottom: 6px;
}

/* System Event message */
.msg-bubble-wrap.system .msg-bubble {
  background-color: #FFFFFF;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  text-align: center;
}

.msg-time-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10.5px;
  margin-top: 3px;
  color: var(--text-subtle);
}

.msg-bubble-wrap.agent .msg-time-status {
  color: rgba(255, 255, 255, 0.8);
}

/* Co-Pilot Suggestion Banner */
.ai-copilot-banner {
  border-top: 1px solid var(--ai-purple-border);
  background-color: var(--ai-purple-light);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 -4px 10px rgba(124, 58, 237, 0.04);
}

.copilot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copilot-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ai-purple);
}

.copilot-model-badge {
  font-size: 10px;
  font-weight: 800;
  background: #FFFFFF;
  border: 1px solid var(--ai-purple-border);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--ai-purple);
}

.copilot-body {
  font-size: 13px;
  line-height: 1.5;
  color: #3B0764;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
  background: #FFFFFF;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ai-purple-border);
}

.copilot-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Quick Template Strip */
.quick-template-strip {
  padding: 8px 18px;
  background-color: #FFFFFF;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.strip-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.template-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-body);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.template-chip:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Chat Input Area */
.chat-input-area {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border-color);
  background-color: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-copilot-trigger {
  padding: 4px 10px;
  background-color: var(--ai-purple-light);
  border: 1px solid var(--ai-purple-border);
  color: var(--ai-purple);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copilot-trigger:hover {
  background-color: var(--ai-purple);
  color: #FFFFFF;
}

.typing-notice {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.input-bar textarea {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-main);
  outline: none;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  transition: all 0.15s ease;
}

.input-bar textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-send-message {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--wa-green);
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
}

.btn-send-message:hover {
  background-color: var(--wa-green-hover);
}

/* Column 3: Customer Dossier */
.chat-dossier-column {
  width: 320px;
  background-color: #FFFFFF;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.dossier-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dossier-header h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

#btnCloseDossierMobile {
  display: none;
}

.dossier-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dossier-card {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dossier-card h4 {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.dossier-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dossier-field .lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.dossier-field .val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.stage-selector {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
}

.dossier-notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.note-item {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #78350F;
}

.note-time {
  font-size: 10px;
  color: #B45309;
  margin-top: 4px;
}

.add-note-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.add-note-box textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  resize: vertical;
  min-height: 50px;
}

/* ========================================================
   VIEW B: PIPELINE KANBAN BOARD
   ======================================================== */
#viewPipeline {
  flex-direction: column;
  padding: 24px 30px;
  gap: 20px;
}

.pipeline-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pv-title-box h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.pv-title-box p {
  font-size: 13.5px;
  color: var(--text-muted);
}

.pipeline-metrics-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.metric-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.metric-card.highlight {
  border-color: var(--wa-green-border);
  background-color: var(--wa-green-light);
}

.metric-card.highlight .m-val {
  color: var(--wa-green);
}

.metric-card .m-val {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}

.metric-card .m-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kanban-board-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 20px;
  flex: 1;
}

.kanban-col {
  width: 290px;
  min-width: 290px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 230px);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.kanban-col[data-stage="deal_won"] {
  border-top: 3px solid #059669;
}

.kanban-col[data-stage="lost"] {
  border-top: 3px solid #DC2626;
  background-color: #FEF2F2;
}

.kanban-col[data-stage="lost"] .kanban-col-title {
  color: #DC2626;
}

.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-col-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 750;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-col-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background-color: #FFFFFF;
  color: var(--text-body);
}

.kanban-cards-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 180px;
  transition: all 0.15s ease;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.kanban-cards-list.drag-over {
  background-color: #EFF6FF !important;
  outline: 2px dashed #2563EB;
  outline-offset: -4px;
}

.kanban-col[data-stage="lost"] .kanban-cards-list.drag-over {
  background-color: #FEE2E2 !important;
  outline: 2px dashed #DC2626;
}

.kanban-empty-drop-hint {
  padding: 24px 12px;
  text-align: center;
  color: #94A3B8;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  user-select: none;
}

.kanban-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.kanban-card:active {
  cursor: grabbing;
}

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

.kanban-card.dragging {
  opacity: 0.35 !important;
  transform: scale(0.96) rotate(1deg);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.15) !important;
  border: 2px dashed #2563EB !important;
}

.kanban-card.card-lost {
  border-left: 3px solid #DC2626;
}

.kanban-card.card-won {
  border-left: 3px solid #059669;
}

.kc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.kc-drag-handle {
  color: var(--text-subtle);
  font-size: 12px;
  opacity: 0.35;
  cursor: grab;
  transition: all 0.15s ease;
  padding: 0 2px;
}

.kanban-card:hover .kc-drag-handle {
  opacity: 1;
  color: var(--primary);
}

.kc-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.kc-company {
  font-size: 11.5px;
  color: var(--text-muted);
}

.kc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
}

.kc-val {
  font-weight: 700;
  color: var(--primary);
}

/* ========================================================
   VIEW C: AI ENGINE & DUAL-SWITCH
   ======================================================== */
#viewAiDesk {
  flex-direction: column;
  padding: 24px 30px;
  gap: 24px;
}

.ai-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-view-title h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.ai-view-title p {
  font-size: 13.5px;
  color: var(--text-muted);
}

.ai-engine-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.model-status-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.msc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.msc-title .msc-tier {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.msc-title h4 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

.msc-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.msc-badge.active {
  background-color: var(--wa-green-light);
  color: var(--wa-green);
  border: 1px solid var(--wa-green-border);
}

.msc-badge.standby {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.msc-badge.switched {
  background-color: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.msc-desc {
  font-size: 12.5px;
  color: var(--text-body);
  line-height: 1.5;
  flex: 1;
}

.msc-metrics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
}

.msc-metrics .metric-sub {
  display: flex;
  justify-content: space-between;
}

.msc-metrics .lbl { color: var(--text-muted); }
.msc-metrics .val { font-weight: 700; color: var(--text-main); }
.text-success { color: var(--wa-green) !important; }

.control-card {
  background: #FAF5FF;
  border-color: var(--ai-purple-border);
}

.control-actions-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

/* Knowledge Base Panel */
.knowledge-base-panel,
.ai-logs-panel {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.kbp-header h3,
.alp-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbp-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.knowledge-items-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kb-card {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-card h5 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 750;
  color: var(--text-main);
}

.kb-card p {
  font-size: 12px;
  color: var(--text-body);
  line-height: 1.5;
}

/* Tables */
.alp-logs-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  color: var(--text-muted);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-body);
}

.data-table tr:hover td {
  background-color: var(--bg-body);
}

/* ========================================================
   VIEW D: SETTINGS
   ======================================================== */
#viewSettings {
  flex-direction: column;
  padding: 24px 30px;
  gap: 20px;
}

.settings-view-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.settings-view-header p {
  font-size: 13.5px;
  color: var(--text-muted);
}

.settings-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 1100px;
}

.settings-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-card.full-width {
  grid-column: 1 / -1;
}

.sc-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.sc-icon {
  font-size: 22px;
  color: var(--primary);
  margin-top: 2px;
}

.sc-icon.wa-color {
  color: var(--wa-green);
}

.sc-header h4 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.sc-header p {
  font-size: 12.5px;
  color: var(--text-muted);
}

.sc-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  background-color: #FFFFFF;
  transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.col-half {
  flex: 1;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.field-hint a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.webhook-endpoint-info {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.copy-url-bar {
  display: flex;
  gap: 8px;
}

.copy-url-bar input {
  font-family: monospace;
  font-size: 12px;
  background: #FFFFFF;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-body);
  margin-top: 4px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--wa-green);
  cursor: pointer;
}

.settings-footer-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.save-status-msg {
  font-size: 12px;
  font-weight: 600;
  color: var(--wa-green);
}

/* ========================================================
   MODALS & DIALOGS
   ======================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { opacity: 0; transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
}

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

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  background-color: var(--bg-body);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.sim-quick-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.sample-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-sample {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
}
.btn-sample:hover {
  background: var(--primary-light);
}

/* ========================================================
   BUTTONS & COMMON COMPONENTS
   ======================================================== */
.btn-primary {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: #FFFFFF;
  border: 1px solid var(--primary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-primary-sm {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: #FFFFFF;
  border: 1px solid var(--primary);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn-primary-sm:hover { background-color: var(--primary-hover); }

.btn-primary-xs {
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background-color: var(--primary);
  color: #FFFFFF;
  border: none;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background-color: #FFFFFF;
  color: var(--text-body);
  border: 1px solid var(--border-color);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-secondary:hover { background-color: var(--bg-subtle); color: var(--text-main); }

.btn-secondary-sm {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background-color: #FFFFFF;
  color: var(--text-body);
  border: 1px solid var(--border-color);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn-secondary-sm:hover { background-color: var(--bg-subtle); color: var(--text-main); }

.btn-secondary-xs {
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background-color: #FFFFFF;
  color: var(--text-body);
  border: 1px solid var(--border-color);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-warning-xs {
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  background-color: #FFFBEB;
  color: #B45309;
  border: 1px solid #FDE68A;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-warning-xs:hover { background-color: #FEF3C7; }

.btn-xs {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}
.btn-xs:hover { color: var(--text-main); }

.btn-icon {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
}

.btn-icon-xs {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease;
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--wa-green); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.error { border-left: 4px solid var(--danger); }

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

/* Loading States */
.loading-state {
  margin: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ========================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ======================================================== */
@media (max-width: 1100px) {
  .ai-engine-cards-grid {
    grid-template-columns: 1fr;
  }
  .knowledge-items-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-cards-grid {
    grid-template-columns: 1fr;
  }
  .pipeline-metrics-bar {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 860px) {
  .app-sidebar {
    width: 68px;
  }
  .brand-subtext,
  .nav-label,
  .sidebar-footer .lbl,
  .sidebar-footer .num {
    display: none;
  }
  .sidebar-top {
    padding: 14px 10px;
    display: flex;
    justify-content: center;
  }
  .brand-img {
    height: 28px;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  .nav-badge {
    position: absolute;
    top: 6px;
    right: 6px;
  }
  .ai-status-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
  }
  .official-number-card {
    justify-content: center;
    padding: 8px;
  }
  .connection-status-pill .status-text {
    display: none;
  }
  
  /* Chat column collapsing */
  .chat-dossier-column {
    position: fixed;
    top: 0;
    right: -320px;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-modal);
    transition: right 0.25s ease;
  }
  .chat-dossier-column.open {
    right: 0;
  }
  #btnCloseDossierMobile {
    display: block;
  }
}

@media (max-width: 680px) {
  .app-container {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    height: 54px;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-top {
    padding: 8px 14px;
    border-bottom: none;
  }
  .sidebar-nav {
    flex-direction: row;
    padding: 0 10px;
    overflow-y: visible;
  }
  .sidebar-footer {
    display: none;
  }
  .app-main {
    flex: 1;
    height: calc(100vh - 54px);
  }
  
  /* In mobile chat: toggle between list and active chat */
  .chat-list-column {
    width: 100%;
  }
  .chat-list-column.hide-on-mobile {
    display: none;
  }
  .chat-thread-column {
    display: none;
    width: 100%;
  }
  .chat-thread-column.show-on-mobile {
    display: flex;
  }
  .mobile-back-btn {
    display: block;
  }
  .pipeline-metrics-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .knowledge-items-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================================
   10. LOGIN PAGE & AUTHENTICATION STYLES
   ======================================================== */
.login-body {
  min-height: 100vh;
  width: 100vw;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: var(--font-sans);
}

.login-wrapper {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 10;
}

.login-ambient-blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(85px);
  pointer-events: none;
  z-index: 1;
}

.login-ambient-blob.blob-1 {
  width: 420px;
  height: 420px;
  background: rgba(37, 99, 235, 0.12);
  top: 5%;
  left: 8%;
}

.login-ambient-blob.blob-2 {
  width: 380px;
  height: 380px;
  background: rgba(5, 150, 105, 0.10);
  bottom: 8%;
  right: 8%;
}

.login-card {
  position: relative;
  z-index: 10;
  background: #FFFFFF;
  width: 100%;
  max-width: 450px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.02);
  padding: 38px 34px;
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand-wrapper {
  margin-bottom: 12px;
}

.login-logo {
  height: 40px;
  width: auto;
  max-width: 210px;
  object-fit: contain;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.login-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--danger-light);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
  animation: fadeIn 0.2s ease-in-out;
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
  z-index: 5;
}

.input-with-icon input,
.form-group .input-with-icon input,
.form-group .input-with-icon input[type="text"],
.form-group .input-with-icon input[type="password"] {
  width: 100% !important;
  height: 44px !important;
  padding-left: 44px !important;
  padding-right: 44px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 14px !important;
  color: var(--text-main) !important;
  background-color: #FFFFFF !important;
  transition: all 0.15s ease !important;
  box-sizing: border-box !important;
}

.input-with-icon input:focus,
.form-group .input-with-icon input:focus,
.form-group .input-with-icon input[type="text"]:focus,
.form-group .input-with-icon input[type="password"]:focus {
  border-color: var(--primary) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

.btn-toggle-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
  z-index: 5;
}

.btn-toggle-eye:hover {
  color: var(--text-main);
}

.login-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 20px;
  font-size: 12.5px;
}

.checkbox-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-body);
  user-select: none;
}

.checkbox-remember input {
  cursor: pointer;
  accent-color: var(--primary);
}

.btn-login-submit {
  width: 100%;
  height: 44px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-login-submit:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}

.btn-login-submit:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}

.btn-login-submit .btn-arrow {
  transition: transform 0.2s ease;
}

.btn-login-submit:hover .btn-arrow {
  transform: translateX(3px);
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.security-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--wa-green);
  font-weight: 500;
  font-size: 11.5px;
}

/* User Profile in Dashboard Sidebar Footer */
.user-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-top: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

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

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

.user-role {
  font-size: 10.5px;
  color: var(--text-muted);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  transition: all 0.15s ease;
  font-size: 13.5px;
}

.btn-logout:hover {
  color: var(--danger);
  background: var(--danger-light);
}

