/* ============================================
   WAHA Dashboard — Dark WhatsApp Theme
   ============================================ */

/* ---------- Reset & Variables ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-main: #111b21;
  --bg-sidebar: #202c33;
  --bg-panel: #0b141a;
  --bg-bubble-recv: #202c33;
  --bg-bubble-sent: #005c4b;
  --bg-input: #2a3942;
  --bg-hover: #2a3942;
  --bg-active: #2a3942;
  --bg-header: #202c33;
  --bg-modal: #233138;
  --accent: #00a884;
  --accent-hover: #06cf9c;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --border: #2a3942;
  --border-light: #394955;
  --danger: #ea4335;
  --success: #00a884;
  --warning: #f4a123;
  --scrollbar-thumb: #374955;
  --scrollbar-track: transparent;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 50%;
  --transition: 150ms ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #4a5c6a;
}

/* ---------- Top Bar ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(0,168,132,0.5);
}
.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(234,67,53,0.4);
}
.status-dot.scanning {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(244,161,35,0.4);
  animation: pulse 1.5s infinite;
}

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

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  font-family: var(--font);
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--accent);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}
.btn-send:hover {
  background: var(--accent-hover);
}

.btn-close-panel,
.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.btn-close-panel:hover,
.btn-close-modal:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ---------- App Layout (3-column) ---------- */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr 0px;
  height: calc(100vh - 50px);
  overflow: hidden;
  transition: grid-template-columns 0.25s ease;
}
.app-layout.right-open {
  grid-template-columns: 280px 1fr 320px;
}

/* ---------- Left Sidebar ---------- */
.sidebar-left {
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.session-selector {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.session-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.session-dropdown {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238696a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.session-dropdown:focus {
  border-color: var(--accent);
}

.chat-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.search-wrapper {
  position: relative;
}

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

.search-input {
  width: 100%;
  padding: 8px 10px 8px 34px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input:focus {
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- Chat List ---------- */
.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(134,150,160,0.08);
  transition: background var(--transition);
}
.chat-item:hover {
  background: var(--bg-hover);
}
.chat-item.active {
  background: var(--bg-active);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--border-light);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-info-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.chat-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}
.chat-time.unread {
  color: var(--accent);
}

.chat-info-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ---------- Center Panel ---------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  overflow: hidden;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  min-height: 50px;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--border-light);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

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

.chat-header-phone {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Messages ---------- */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='p' width='40' height='40' patternUnits='userSpaceOnUse'%3E%3Cpath d='M20 0v40M0 20h40' stroke='%23ffffff' stroke-width='0.3' opacity='0.02'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23p)'/%3E%3C/svg%3E");
}

.center-empty {
  margin: auto;
  text-align: center;
}
.center-empty h2 {
  font-size: 22px;
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 16px;
}
.center-empty p {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 13px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.message-row {
  display: flex;
  margin-bottom: 1px;
}
.message-row.sent {
  justify-content: flex-end;
}
.message-row.received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 65%;
  padding: 6px 8px 6px 9px;
  border-radius: var(--radius-md);
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
}
.message-row.sent .message-bubble {
  background: var(--bg-bubble-sent);
  border-top-right-radius: 2px;
}
.message-row.received .message-bubble {
  background: var(--bg-bubble-recv);
  border-top-left-radius: 2px;
}

.message-text {
  font-size: 14px;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.message-time {
  font-size: 11px;
  color: rgba(233,237,239,0.5);
}

.message-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.15);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.message-doc-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

.message-doc-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Date separator */
.date-separator {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.date-separator span {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ---------- Message Input ---------- */
.message-input-area {
  padding: 8px 16px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
}
.message-input::placeholder {
  color: var(--text-muted);
}

/* ---------- Right Sidebar ---------- */
.sidebar-right {
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.contact-panel {
  padding: 16px;
}

.contact-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.contact-panel-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--border-light);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  margin: 0 auto 16px;
  text-transform: uppercase;
}

.contact-details {
  margin-bottom: 12px;
}

.contact-unknown {
  text-align: center;
}
.unknown-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.unknown-phone {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

.contact-field {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  border-bottom: 1px solid rgba(134,150,160,0.08);
}
.contact-field:last-child {
  border-bottom: none;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.field-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ---------- Document Generation ---------- */
.doc-generation {
  margin-top: 8px;
}

.doc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.doc-language {
  margin-bottom: 12px;
}

.doc-language-select {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238696a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  margin-top: 4px;
}
.doc-language-select:focus {
  border-color: var(--accent);
}

.doc-types {
  margin-bottom: 14px;
}

.doc-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.doc-type-btn {
  padding: 8px 6px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  line-height: 1.3;
}
.doc-type-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.doc-type-btn.active {
  background: rgba(0,168,132,0.15);
  color: var(--accent);
  border-color: var(--accent);
}

.doc-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-actions .btn {
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
}

/* Spinner */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
  display: inline-block;
  margin-left: 6px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius-lg);
  width: 400px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

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

.modal-body {
  padding: 20px;
}

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}
.form-input::placeholder {
  color: var(--text-muted);
}
.form-input:focus {
  border-color: var(--accent);
}

.qr-section {
  margin-top: 16px;
}

.qr-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.qr-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
}

.qr-container img {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.qr-placeholder {
  color: #666;
  font-size: 13px;
}

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

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: all;
  animation: toastIn 0.25s ease;
  max-width: 340px;
}
.toast.success {
  border-left: 3px solid var(--success);
}
.toast.error {
  border-left: 3px solid var(--danger);
}
.toast.info {
  border-left: 3px solid var(--accent);
}
.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* ---------- Loading States ---------- */
.chat-list-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-dots {
  display: flex;
  gap: 6px;
}
.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: loadDot 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.messages-loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 260px 1fr 0px;
  }
  .app-layout.right-open {
    grid-template-columns: 260px 1fr 280px;
  }
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .app-layout.right-open {
    grid-template-columns: 1fr;
  }

  .sidebar-left {
    display: none;
  }
  .sidebar-left.mobile-show {
    display: flex;
    position: absolute;
    left: 0;
    top: 50px;
    bottom: 0;
    width: 100%;
    z-index: 50;
  }

  .sidebar-right {
    position: absolute;
    right: 0;
    top: 50px;
    bottom: 0;
    width: 300px;
    z-index: 50;
  }

  .messages-container {
    padding: 12px 16px;
  }

  .message-bubble {
    max-width: 85%;
  }
}

@media (max-width: 600px) {
  .top-bar-title {
    font-size: 14px;
  }
  .btn span:not(.status-dot) {
    display: none;
  }
  .modal {
    width: 95vw;
  }
  .sidebar-right {
    width: 100%;
  }
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

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

/* ---------- Unread dot ---------- */
.unread-dot {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  position: absolute;
  top: 12px;
  right: 12px;
}

.chat-item {
  position: relative;
}

/* ---------- Instance badge on chat items ---------- */
.instance-badge {
  font-size: 9px;
  background: #2a3942;
  color: #8696a0;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ---------- Collapsible instance group ---------- */
.instance-group-header {
  padding: 8px 16px;
  background: #1a2228;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #8696a0;
  border-bottom: 1px solid #2a3942;
  user-select: none;
}
.instance-group-header:hover {
  background: #202c33;
}
.instance-group-header .arrow {
  transition: transform 0.2s;
  font-size: 10px;
}
.instance-group-header.collapsed .arrow {
  transform: rotate(-90deg);
}
.instance-group-header .unread-count {
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
}

/* ---------- Company intel card ---------- */
.intel-card {
  background: #1a2228;
  border: 1px solid #2a3942;
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}
.intel-card h5 {
  font-size: 12px;
  color: #00a884;
  margin-bottom: 8px;
}

/* ---------- Contact header (compact) ---------- */
.contact-header-compact {
  text-align: center;
  margin-bottom: 12px;
}
.contact-header-compact .contact-name-large {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.contact-header-compact .contact-title-large {
  font-size: 12px;
  color: var(--text-secondary);
}
.contact-header-compact .contact-company-line {
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 4px;
}
.contact-header-compact .contact-hq-line {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- CEO card ---------- */
.ceo-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  margin-top: 8px;
}
.ceo-card img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.ceo-card .ceo-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.ceo-card .ceo-info {
  flex: 1;
}
.ceo-card .ceo-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.ceo-card .ceo-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ---------- Quick action buttons ---------- */
.quick-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.quick-actions .qa-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 150ms ease;
}
.quick-actions .qa-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.quick-actions .qa-btn svg {
  flex-shrink: 0;
}

/* ---------- Intel section ---------- */
.intel-section {
  margin-top: 12px;
}
.intel-section .btn-analyze {
  width: 100%;
  padding: 8px;
  background: rgba(0,168,132,0.1);
  color: var(--accent);
  border: 1px solid rgba(0,168,132,0.3);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 150ms ease;
}
.intel-section .btn-analyze:hover {
  background: rgba(0,168,132,0.2);
  border-color: var(--accent);
}
.intel-section .btn-analyze:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chat list enhancements */
.chat-item-unread { background: rgba(0,168,132,0.05) !important; }
.chat-item-unread:hover { background: rgba(0,168,132,0.08) !important; }
.chat-subtitle { font-size: 10px; color: #8696a0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.chat-company-tag { font-size: 9px; background: #1a2e23; color: #00a884; padding: 0 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }

/* Time under name */
.chat-meta-line { display:flex; align-items:center; gap:6px; margin:1px 0 2px; }
.chat-time-under { font-size:10px; color:#8696a0; }
.chat-time-under.unread { color:#00a884; font-weight:600; }
