@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #111b21;
  --text-muted: #8696a0;
  --text-light: #667781;
  --border: #e9edef;
  --primary: #00a884;
  --primary-dark: #008f72;
  --bubble-out: #d9fdd3;
  --bubble-in: #ffffff;
  --header-bg: #f0f2f5;
  --sidebar-bg: #ffffff;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --amber: #f59e0b;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */
.app-layout {
  display: flex;
  height: 100vh;
  position: relative;
}

/* === SIDEBAR === */
.sidebar {
  width: 380px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

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

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Profile tabs filter */
.profile-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fa;
}

.profile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-light);
  border-radius: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.profile-tab:hover {
  background: var(--border);
  color: var(--text);
}

.profile-tab.active {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  color: var(--text);
}

.tab-avatar-txt {
  font-size: 14px;
}

.tab-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  color: white;
}

.tab-avatar.pink { background: linear-gradient(135deg, #f472b6, #ec4899); }
.tab-avatar.blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.tab-avatar.green { background: linear-gradient(135deg, #34d399, #10b981); }

/* Vendor counter badges */
.tab-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

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

.icon-btn:hover { background: var(--border); color: var(--text); }

/* Filtros */
.filter-bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-chip:hover { background: var(--bg); }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px;
  padding: 8px 14px;
  background: var(--bg);
  border-radius: 10px;
}

.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

.search-bar input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  outline: none;
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.chat-item:hover { background: var(--bg); }
.chat-item.active { background: #f0faf8; }

/* Urgent chat highlighting */
.chat-item.urgent {
  border-left: 3px solid var(--danger);
  background: rgba(239, 68, 68, 0.03);
}
.chat-item.urgent:hover { background: rgba(239, 68, 68, 0.06); }

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #64748b;
  flex-shrink: 0;
  position: relative;
}

.chat-avatar.ia { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.chat-avatar.human { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }

.chat-avatar .vendor-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid white;
  font-size: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: white;
}

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

.chat-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

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

.chat-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.chat-time.unread { color: var(--primary); font-weight: 700; }

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

.chat-preview {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}

.chat-labels-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.mini-label {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mini-label.vendor { background: #fef3c7; color: #92400e; }
.mini-label.ia { background: #d1fae5; color: #065f46; }
.mini-label.custom { background: #ede9fe; color: #5b21b6; }
.mini-label.closed { background: #d1fae5; color: #065f46; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.notif-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.notif-btn:hover { background: var(--card); border-color: var(--text-muted); }

.notif-badge {
  position: absolute;
  top: -4px;
  left: 22px;
  min-width: 18px;
  height: 18px;
  background: var(--danger);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* === CHAT AREA === */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d5cec3' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px;
}

.empty-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #059669;
}

.empty-state h2 {
  font-size: 22px;
  font-weight: 800;
  color: #41525d;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.6;
}

.active-chat { display: flex; flex-direction: column; height: 100%; }

/* Chat Header */
.chat-header {
  padding: 10px 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.back-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-light);
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #64748b;
  flex-shrink: 0;
}
.chat-header-avatar.ia { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.chat-header-avatar.human { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }

.chat-header-info { flex: 1; }

.chat-header-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.status-dot-sm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot-sm.active { background: var(--primary); animation: pulse 2s infinite; }
.status-dot-sm.human { background: var(--blue); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(0,168,132,0.2); }
  50% { box-shadow: 0 0 0 5px rgba(0,168,132,0.3); }
}

#chatStatusText {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.labels-display {
  display: flex;
  gap: 4px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover { background: var(--bg); border-color: var(--text-muted); }
.action-btn.danger { color: var(--danger); border-color: #fecaca; background: var(--danger-light); }
.action-btn.danger:hover { background: #fee2e2; }
.action-btn.success { color: var(--primary); border-color: #a7f3d0; background: #ecfdf5; }
.action-btn.success:hover { background: #d1fae5; }
.action-btn.primary { color: white; background: var(--primary); border-color: var(--primary); }
.action-btn.primary:hover { background: var(--primary-dark); }

/* Status Dropdown */
.status-dropdown {
  position: relative;
}

.status-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  min-width: 200px;
  overflow: hidden;
  animation: modalIn 0.15s ease-out;
}

.status-dropdown.open .status-dropdown-menu {
  display: block;
}

.status-dropdown-menu button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.status-dropdown-menu button:hover {
  background: var(--bg);
}

.status-dropdown-menu button:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.msg-row {
  display: flex;
  max-width: 65%;
  margin-bottom: 4px;
}

.msg-row.user { align-self: flex-start; }
.msg-row.assistant { align-self: flex-end; }
.msg-row.note { align-self: center; max-width: 80%; }

.msg-bubble {
  padding: 6px 10px 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
  word-wrap: break-word;
}

/* Note bubble (internal notes) */
.note-bubble {
  background: #fef9c3 !important;
  border: 1px dashed #f59e0b;
  border-radius: 8px !important;
}

.note-bubble::before,
.note-bubble::after {
  display: none !important;
}

.note-header {
  font-size: 10px;
  font-weight: 800;
  color: #92400e;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Colitas de burbujas estilo WhatsApp Web original */
.msg-row.user .msg-bubble {
  background: var(--bubble-in);
  border-top-left-radius: 0;
}
.msg-row.user .msg-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 13px;
  background: var(--bubble-in);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.msg-row.assistant .msg-bubble {
  background: var(--bubble-out);
  border-top-right-radius: 0;
}
.msg-row.assistant .msg-bubble::after {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 13px;
  background: var(--bubble-out);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.msg-text { white-space: pre-line; }

.msg-time {
  font-size: 10px;
  color: rgba(102,119,129,0.9);
  text-align: right;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  float: right;
  margin-left: 12px;
}

.msg-ticks {
  color: #53bdeb; /* Azul oficial de WhatsApp de doble tilde leído */
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.preview-ticks {
  color: #8696a0; /* Gris oficial de WhatsApp para tildes en lista de chats */
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
}

.msg-row.assistant .msg-time { color: rgba(102,119,129,0.9); }

.msg-media img {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}

.msg-media audio {
  width: 240px;
  height: 32px;
  margin-bottom: 4px;
}

.msg-type-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: inline-block;
}

.msg-type-badge.image { background: #dbeafe; color: #1d4ed8; }
.msg-type-badge.audio { background: #d1fae5; color: #065f46; }

/* Input Bar */
.input-bar {
  padding: 12px 20px;
  background: var(--header-bg);
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-bar input[type="text"] {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.input-bar input[type="text"]:focus { border-color: var(--primary); }

/* Quick Reply trigger button */
.qr-trigger {
  font-size: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.qr-trigger:hover {
  background: rgba(0, 168, 132, 0.1);
  transform: scale(1.1);
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* === CONTACT PANEL (Right Sidebar) === */
.contact-panel {
  width: 320px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  animation: slideInRight 0.25s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.cp-header h3 {
  font-size: 14px;
  font-weight: 800;
}

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

.cp-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cp-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a884, #008f72);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 28px;
  color: white;
}

.cp-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.cp-phone {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}

.cp-phone:hover { color: var(--primary); }

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

.cp-info-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cp-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cp-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cp-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.cp-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cp-action-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.cp-action-btn:hover {
  background: var(--card);
  border-color: var(--primary);
  color: var(--primary);
}

/* === MODALS === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}

.modal-card.qr-modal {
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.vendor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.vendor-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.vendor-btn:hover { border-color: var(--primary); background: #ecfdf5; transform: translateY(-2px); box-shadow: var(--shadow); }

.vendor-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: white;
}

.cancel-btn {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.cancel-btn:hover { background: var(--border); }

/* Label Grid */
.label-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
}

.label-chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.label-chip:hover { border-color: var(--text-muted); }

.label-add {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.label-add input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

/* Quick Reply Grid */
.qr-grid {
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qr-category-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.qr-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}

.qr-item:hover {
  border-color: var(--primary);
  background: rgba(0, 168, 132, 0.04);
  transform: translateY(-1px);
}

.qr-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

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

.qr-add-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
}

/* Notifications Panel */
.notif-panel {
  position: absolute;
  bottom: 70px;
  left: 16px;
  width: 350px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 50;
  max-height: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease-out;
}

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

.notif-header h3 { font-size: 14px; font-weight: 800; }

.notif-list {
  flex: 1;
  overflow-y: auto;
  max-height: 320px;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

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

.notif-item .notif-type {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 4px;
}

.notif-item .notif-msg {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}

.notif-item .notif-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.empty-notif {
  padding: 40px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Loading */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a2e;
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  z-index: 200;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateY(0); opacity: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5c5c5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    display: flex;
  }
  
  .chat-area {
    display: none;
    width: 100%;
  }
  
  .contact-panel {
    display: none !important;
  }
  
  /* Cuando hay un chat activo, alternamos la vista de forma fluida */
  .app-layout.has-chat .sidebar {
    display: none;
  }
  
  .app-layout.has-chat .chat-area {
    display: flex;
    width: 100%;
  }

  .back-btn {
    display: flex;
    margin-right: 8px;
  }

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

  .msg-row {
    max-width: 85%;
  }
  
  /* Ajustes estéticos para pantallas pequeñas */
  .chat-header {
    padding: 10px 12px;
  }
  
  .chat-header-actions {
    gap: 6px;
  }
  
  .action-btn span {
    display: none; /* Oculta texto en mobile, solo deja el icono para ganar espacio */
  }
  
  .action-btn {
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    justify-content: center;
  }
  
  .input-bar {
    padding: 8px 12px;
  }
}
