/* ==========================================================================
   Live 3-Column WhatsApp Shared Inbox & Chat Views
   Enterprise standard with Human-in-the-Loop takeover & CAPI Inspector
   ========================================================================== */

.inbox-container {
  display: grid;
  grid-template-columns: var(--inbox-list-width) 1fr var(--inbox-inspector-width);
  height: 100%;
  background: #FFFFFF;
  border-top: 1px solid var(--slate-200);
  overflow: hidden;
}

/* -------------------------------------------------------------
   COLUMN 1: CONVERSATION LIST
   ------------------------------------------------------------- */
.inbox-list-col {
  border-right: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  height: 100%;
  overflow: hidden;
}

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

.inbox-search-box {
  position: relative;
  width: 100%;
}

.inbox-search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  background: var(--slate-50);
  font-size: 0.85rem;
}

.inbox-search-box input:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--primary-600);
}

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

.inbox-filter-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.inbox-filter-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate-600);
  background: var(--slate-100);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.inbox-filter-chip:hover {
  background: var(--slate-200);
}

.inbox-filter-chip.active {
  background: var(--slate-900);
  color: #FFFFFF;
}

.threads-scroll {
  flex: 1;
  overflow-y: auto;
}

.thread-item {
  display: flex;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--slate-100);
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.thread-item:hover {
  background: var(--slate-50);
}

.thread-item.active {
  background: var(--primary-50);
  border-left: 3px solid var(--primary-600);
}

.thread-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--slate-700);
  flex-shrink: 0;
  position: relative;
}

.thread-avatar .agent-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
}

.agent-indicator.ai-mode {
  background: var(--primary-600);
}

.agent-indicator.human-mode {
  background: #F59E0B;
}

.thread-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.thread-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-time {
  font-size: 0.75rem;
  color: var(--slate-400);
  flex-shrink: 0;
}

.thread-msg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thread-snippet {
  font-size: 0.8rem;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
}

.thread-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

/* -------------------------------------------------------------
   COLUMN 2: ACTIVE CHAT CONVERSATION VIEW
   ------------------------------------------------------------- */
.inbox-chat-col {
  display: flex;
  flex-direction: column;
  background: var(--slate-100);
  height: 100%;
  position: relative;
}

.chat-header {
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

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

.chat-user-meta h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-user-meta p {
  font-size: 0.78rem;
  color: var(--slate-500);
}

.chat-mode-banner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.ai-status-pill.ai-active {
  background: var(--primary-50);
  color: var(--primary-800);
  border: 1px solid var(--primary-200);
}

.ai-status-pill.human-active {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
}

/* Chat Messages Canvas (WhatsApp Theme) */
.chat-messages-area {
  flex: 1;
  background-color: #EFEAE2;
  background-image: radial-gradient(#CBD5E1 1px, transparent 1px);
  background-size: 20px 20px;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.date-divider {
  align-self: center;
  background: #FFFFFF;
  padding: 4px 12px;
  border-radius: var(--radius-md);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--slate-500);
  box-shadow: var(--shadow-xs);
  margin: 6px 0;
}

/* WhatsApp Bubbles */
.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: fadeIn 0.15s ease;
}

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

.msg-bubble-wrap.outgoing {
  align-self: flex-end;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

.msg-bubble-wrap.incoming .msg-bubble {
  background: #FFFFFF;
  color: var(--slate-900);
  border-top-left-radius: 2px;
}

.msg-bubble-wrap.outgoing .msg-bubble {
  background: #E7FCE3; /* WhatsApp authentic outgoing light green */
  color: var(--slate-900);
  border-top-right-radius: 2px;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--slate-400);
  margin-top: 4px;
}

.msg-sender-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary-800);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* CTWA Ad Payload Banner in Message */
.ctwa-ad-banner {
  background: #F1F5F9;
  border-left: 4px solid var(--accent-meta);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 0.78rem;
}

.ctwa-ad-banner strong {
  display: block;
  color: var(--slate-900);
}

/* Interactive WhatsApp Buttons */
.wa-interactive-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 6px;
}

.wa-btn-option {
  background: #FFFFFF;
  color: var(--wa-teal);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 1px solid #E2E8F0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.wa-btn-option:hover {
  background: #F8FAFC;
}

/* Catalog Card Bubble */
.wa-catalog-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--slate-200);
  max-width: 320px;
  box-shadow: var(--shadow-sm);
}

.wa-catalog-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--slate-100);
}

.wa-catalog-body {
  padding: 12px;
}

.wa-catalog-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--slate-900);
}

.wa-catalog-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-800);
  margin: 4px 0;
}

.wa-catalog-badge {
  font-size: 0.72rem;
  background: #F1F5F9;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: var(--slate-600);
}

/* Chat Input Bar */
.chat-composer-bar {
  background: #FFFFFF;
  border-top: 1px solid var(--slate-200);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-ai-suggestions {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.ai-pill-btn {
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  color: var(--primary-900);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.ai-pill-btn:hover {
  background: var(--primary-100);
}

.composer-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer-input-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--slate-300);
  background: var(--slate-50);
  font-size: 0.9rem;
}

.composer-input-row input:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--primary-600);
}

/* -------------------------------------------------------------
   COLUMN 3: CUSTOMER & CAPI ATTRIBUTION INSPECTOR
   ------------------------------------------------------------- */
.inbox-inspector-col {
  border-left: 1px solid var(--slate-200);
  background: #FFFFFF;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspector-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-400);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-card {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

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

.data-label {
  color: var(--slate-500);
}

.data-value {
  font-weight: 600;
  color: var(--slate-800);
  text-align: right;
}

.capi-status-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  padding-left: 16px;
}

.capi-status-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--slate-200);
}

.capi-step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.capi-step-dot {
  position: absolute;
  left: -16px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--slate-300);
  border: 2px solid #FFFFFF;
}

.capi-step.completed .capi-step-dot {
  background: var(--primary-600);
}

.capi-step-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-800);
}

.capi-step-time {
  font-size: 0.72rem;
  color: var(--slate-400);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
