/* =====================================================================
   Chatwoot Design System & Styling (cPanel Edition)
   Matches Chatwoot v3 / Radix UI Colors / Tailwind Theme
   ===================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-brand: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  
  /* BizConnect Brand Palette */
  --woot-50: #eff6ff;
  --woot-100: #dbeafe;
  --woot-200: #bfdbfe;
  --woot-300: #93c5fd;
  --woot-400: #60a5fa;
  --woot-500: #1f93ff;
  --woot-600: #0284c7;
  --woot-700: #0369a1;
  --woot-800: #075985;
  --woot-900: #0c4a6e;

  /* WhatsApp Brand Green */
  --wa-green: #25D366;
  --wa-dark-green: #128C7E;
  --wa-teal: #075E54;
  --wa-light: #dcf8c6;

  /* Radix Slate Palette */
  --slate-25: #fcfcfd;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #080d1a;

  /* UI Variables */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --sidebar-bg: #131c2d;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
}

/* Base Reset & Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Master App Layout Grid */
.cw-app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-primary);
}

/* 1. Primary Left Navigation Rail */
.cw-rail {
  width: 64px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  flex-shrink: 0;
  z-index: 50;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.cw-rail-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1f93ff, #0284c7);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(31, 147, 255, 0.35);
  margin-bottom: 24px;
}

.cw-rail-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.cw-rail-item {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.cw-rail-item:hover {
  color: var(--sidebar-active);
  background: var(--sidebar-hover);
}

.cw-rail-item.active {
  color: #ffffff;
  background: #1f93ff;
  box-shadow: 0 4px 12px rgba(31, 147, 255, 0.3);
}

.cw-rail-item .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  line-height: 1;
}

.cw-rail-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.cw-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.cw-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.cw-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}

.cw-status-dot.online { background: #10b981; }
.cw-status-dot.busy { background: #f59e0b; }
.cw-status-dot.offline { background: #6b7280; }

/* 2. Conversations Column (Column 1) */
.cw-conv-list-pane {
  width: 360px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
}

.cw-conv-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.cw-conv-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cw-conv-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-900);
}

.cw-btn-new-chat {
  background: var(--woot-50);
  color: var(--woot-600);
  border: 1px solid var(--woot-200);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.cw-btn-new-chat:hover {
  background: var(--woot-500);
  color: white;
  border-color: var(--woot-500);
}

/* Tabs: Mine / Unassigned / All */
.cw-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  background: var(--slate-100);
  padding: 3px;
  border-radius: 8px;
}

.cw-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-600);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.cw-tab-btn.active {
  background: #ffffff;
  color: var(--slate-900);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Search bar */
.cw-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cw-search-input {
  width: 100%;
  background: var(--slate-50);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  color: var(--slate-900);
  outline: none;
  transition: border-color 0.2s;
}

.cw-search-input:focus {
  border-color: var(--woot-500);
  background: #ffffff;
}

.cw-search-icon {
  position: absolute;
  left: 10px;
  color: var(--slate-400);
  pointer-events: none;
}

/* Conversation Cards Scroll Area */
.cw-conv-scroll {
  flex: 1;
  overflow-y: auto;
}

.cw-conv-card {
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  gap: 12px;
  transition: background 0.15s ease;
  position: relative;
}

.cw-conv-card:hover {
  background: var(--slate-50);
}

.cw-conv-card.active {
  background: #eef7ff;
  border-left: 3px solid var(--woot-500);
}

.cw-card-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cw-card-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.cw-wa-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #25D366;
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.cw-card-body {
  flex: 1;
  min-width: 0;
}

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

.cw-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-card-time {
  font-size: 11px;
  color: var(--slate-400);
  flex-shrink: 0;
  margin-left: 6px;
}

.cw-card-snippet {
  font-size: 13px;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.cw-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.cw-tag-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  color: white;
}

.cw-unread-badge {
  background: #10b981;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* 3. Main Chat Conversation Box (Column 2) */
.cw-chat-pane {
  flex: 1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.cw-chat-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  flex-shrink: 0;
}

.cw-chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cw-contact-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.cw-channel-pill {
  background: #e6f9ee;
  color: #128c7e;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cw-contact-sub {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 2px;
}

.cw-chat-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cw-select-btn {
  background: var(--slate-50);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-700);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}

.cw-btn-resolve {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.cw-btn-resolve:hover {
  background: #10b981;
  color: white;
}

.cw-btn-reopen {
  background: #eff6ff;
  color: #1f93ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.cw-btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--slate-600);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.cw-btn-icon:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

/* Chat Messages Feed */
.cw-messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
}

.cw-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.cw-date-divider span {
  background: var(--slate-200);
  color: var(--slate-600);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
}

/* Message Rows & Bubbles */
.cw-message-row {
  display: flex;
  flex-direction: column;
  max-width: 68%;
}

.cw-message-row.incoming {
  align-self: flex-start;
}

.cw-message-row.outgoing {
  align-self: flex-end;
}

.cw-message-row.activity {
  align-self: center;
  max-width: 90%;
  margin: 8px 0;
}

.cw-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cw-message-row.incoming .cw-bubble {
  background: #ffffff;
  color: var(--slate-900);
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
}

.cw-message-row.outgoing .cw-bubble {
  background: #1f93ff;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

/* Private Internal Note */
.cw-message-row.private {
  align-self: center;
  max-width: 85%;
  width: 100%;
}

.cw-message-row.private .cw-bubble {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
}

.cw-private-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b45309;
  margin-bottom: 4px;
}

.cw-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  margin-top: 4px;
}

.cw-message-row.incoming .cw-bubble-meta {
  color: var(--slate-400);
}

.cw-message-row.outgoing .cw-bubble-meta {
  color: rgba(255, 255, 255, 0.8);
}

/* WhatsApp Double Blue Ticks */
.cw-tick-read {
  color: #93c5fd;
  display: inline-flex;
}

.cw-tick-delivered {
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
}

/* Attachment Cards */
.cw-media-img {
  max-width: 320px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  display: block;
}

.cw-doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.05);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  text-decoration: none;
  color: inherit;
}

/* Activity message */
.cw-activity-pill {
  font-size: 12px;
  color: var(--slate-500);
  background: var(--slate-100);
  padding: 4px 14px;
  border-radius: 12px;
  display: inline-block;
  text-align: center;
}

/* 4. Chat Composer Area */
.cw-composer-wrap {
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  padding: 12px 20px;
  flex-shrink: 0;
}

.cw-composer-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.cw-composer-tab {
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-500);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cw-composer-tab.active {
  background: var(--woot-50);
  color: var(--woot-600);
}

.cw-composer-tab.private-active {
  background: #fef3c7;
  color: #b45309;
}

.cw-composer-box {
  background: var(--slate-50);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.cw-composer-box.private-mode {
  background: #fffdf5;
  border-color: #fde68a;
}

.cw-composer-box:focus-within {
  border-color: var(--woot-500);
  background: #ffffff;
}

.cw-composer-textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--slate-900);
  resize: none;
  min-height: 48px;
  max-height: 140px;
  outline: none;
}

.cw-composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.cw-composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cw-tool-btn {
  background: transparent;
  border: none;
  color: var(--slate-500);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.cw-tool-btn:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.cw-btn-send {
  background: #1f93ff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.cw-btn-send:hover {
  background: #0284c7;
}

.cw-btn-send.private-send {
  background: #f59e0b;
}

.cw-btn-send.private-send:hover {
  background: #d97706;
}

/* Canned Response Autocomplete Dropdown */
.cw-canned-dropdown {
  position: absolute;
  bottom: 80px;
  left: 20px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  width: 320px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
}

.cw-canned-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}

.cw-canned-item:hover {
  background: var(--woot-50);
}

.cw-canned-code {
  font-size: 13px;
  font-weight: 700;
  color: var(--woot-600);
}

.cw-canned-snippet {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 2px;
}

/* 5. Right Contact CRM Sidebar (Column 3) */
.cw-contact-pane {
  width: 320px;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  height: 100%;
}

.cw-contact-profile-card {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cw-profile-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 12px;
  object-fit: cover;
  border: 3px solid var(--woot-100);
}

.cw-profile-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
}

.cw-profile-phone {
  font-size: 13px;
  color: var(--slate-500);
  margin-top: 4px;
}

.cw-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--slate-400);
  padding: 16px 20px 8px;
}

.cw-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 13px;
}

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

.cw-detail-val {
  color: var(--slate-900);
  font-weight: 600;
}

/* 6. Full Pages (Contacts, WhatsApp Settings, Campaigns, Reports) */
.cw-full-page {
  flex: 1;
  background: #f8fafc;
  overflow-y: auto;
  padding: 32px;
  height: 100%;
}

.cw-page-container {
  max-width: 1100px;
  margin: 0 auto;
}

.cw-page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cw-page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--slate-900);
}

.cw-page-subtitle {
  font-size: 14px;
  color: var(--slate-500);
  margin-top: 4px;
}

.cw-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cw-form-group {
  margin-bottom: 18px;
}

.cw-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.cw-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--slate-900);
  outline: none;
  transition: border-color 0.2s;
}

.cw-input:focus {
  border-color: var(--woot-500);
  box-shadow: 0 0 0 3px rgba(31, 147, 255, 0.15);
}

/* Metric Cards */
.cw-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.cw-metric-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cw-metric-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--slate-900);
  margin: 6px 0;
}

.cw-metric-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
}

/* Modals */
.cw-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.cw-modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  padding: 28px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Table styles */
.cw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cw-table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--slate-500);
  font-weight: 600;
}

.cw-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--slate-800);
}

.cw-table tr:hover td {
  background: var(--slate-50);
}
