/* WS Cloud Enterprise Design System matching Screenshots 1 & 2 */
:root {
  --primary-color: #1677ff;
  --success-color: #52c41a;
  --warning-color: #faad14;
  --danger-color: #ff4d4f;
  --sidebar-bg: #232d3b;
  --sidebar-hover: #2e3b4e;
  --sidebar-active: #1677ff;
  --bg-main: #f5f7fa;
  --border-color: #e5e7eb;
  --font-family: 'Inter', 'Kantumruy Pro', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background-color: var(--bg-main); color: #1f2937; font-size: 14px; -webkit-font-smoothing: antialiased; }

/* App Layout: Dark Sidebar + Main Content Container */
.app-layout { display: flex; width: 100vw; height: 100vh; overflow: hidden; }

/* DARK BLUE COLLAPSIBLE LEFT SIDEBAR (Screenshot 2) */
.dark-sidebar {
  width: 220px;
  background-color: var(--sidebar-bg);
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  z-index: 100;
  border-right: 1px solid #1a222c;
}

.dark-sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.sidebar-brand {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background-color: #1a222c;
  border-bottom: 1px solid #141a22;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: var(--primary-color);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.sidebar-item {
  display: flex;
  flex-direction: column;
}

.sidebar-item-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  color: #cbd5e1;
  transition: all 0.2s;
}

.sidebar-item-header:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
}

.sidebar-item.open .sidebar-item-header {
  color: #ffffff;
  font-weight: 600;
}

.menu-icon {
  margin-right: 10px;
  font-size: 14px;
}

.menu-label {
  flex: 1;
}

.arrow-icon {
  font-size: 10px;
  transition: transform 0.2s;
  color: #94a3b8;
}

.sidebar-item.open .arrow-icon {
  transform: rotate(180deg);
}

.sidebar-submenu {
  display: none;
  background-color: #1a222c;
  padding: 4px 0;
}

.sidebar-item.open .sidebar-submenu {
  display: block;
}

.submenu-item {
  padding: 8px 16px 8px 40px;
  font-size: 12px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
}

.submenu-item:hover {
  color: #ffffff;
  background-color: #243040;
}

.submenu-item.active {
  color: #ffffff;
  background-color: var(--primary-color);
  font-weight: 600;
}

/* RIGHT MAIN BODY CONTAINER */
.main-body-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.top-header { height: 50px; background: #ffffff; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; user-select: none; z-index: 10; }
.header-left { display: flex; align-items: center; gap: 16px; }
.top-menu-items { display: flex; gap: 4px; }
.top-menu-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 4px; border: none; background: transparent; color: #4b5563; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.top-menu-btn:hover { background-color: #f3f4f6; color: #111827; }
.top-menu-btn.active { background-color: #e6f4ff; color: #1677ff; font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 16px; font-size: 12px; color: #6b7280; }
.server-time-badge { background: #f9fafb; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border-color); font-family: monospace; }
.lang-selector { display: flex; align-items: center; gap: 4px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.user-profile-badge { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: #e5e7eb; display: flex; align-items: center; justify-content: center; color: #6b7280; }

/* Sub Nav */
.sub-nav-bar { height: 36px; background: #ffffff; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 16px; gap: 8px; }
.sub-nav-tab { display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 3px; font-size: 12px; font-weight: 500; cursor: pointer; background: #e5e7eb; color: #374151; }
.sub-nav-tab.active { background: #1677ff; color: #ffffff; }
.close-btn { margin-left: 4px; opacity: 0.8; font-size: 11px; cursor: pointer; }
.close-btn:hover { opacity: 1; }

/* Main Views */
.main-content { flex: 1; overflow-y: auto; padding: 16px; background: #f5f7fa; position: relative; }
.view-section { display: none; }
.view-section.active { display: block; }

/* Dashboard Card (Matches Screenshot 1 & 2) */
.dashboard-grid { display: flex; flex-direction: column; gap: 16px; max-width: 1400px; margin: 0 auto; }
.dashboard-top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.status-pill { font-size: 12px; background: #e6f4ff; color: #1677ff; padding: 2px 8px; border-radius: 4px; font-weight: 500; }

.stat-card-row { display: flex; border: 1px solid var(--border-color); background: #ffffff; border-radius: 2px; }
.stat-header-badge { width: 120px; background: #6bbe25; color: #ffffff; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; }
.stat-grid-content { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); border-left: 1px solid var(--border-color); }
.stat-box { padding: 14px 20px; border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.stat-box:nth-child(4n) { border-right: none; }
.stat-box:nth-child(n+5) { border-bottom: none; }
.stat-label { color: #4b5563; font-weight: 500; }
.stat-value { font-weight: 600; color: #111827; }

.fans-card-row { display: flex; border: 1px solid var(--border-color); background: #ffffff; border-radius: 2px; }
.fans-card-left { flex: 3; display: flex; flex-direction: column; }
.fans-title-box { padding: 14px; text-align: center; border-bottom: 1px solid var(--border-color); font-weight: 600; font-size: 14px; }
.fans-sub-grid { display: flex; }
.fans-sub-box { flex: 1; padding: 16px; text-align: center; border-right: 1px solid var(--border-color); font-size: 13px; color: #4b5563; }
.fans-sub-box:last-child { border-right: none; }
.fans-card-right { flex: 1; padding: 24px; display: flex; align-items: center; justify-content: center; text-align: center; border-left: 1px solid var(--border-color); font-weight: 500; font-size: 13px; color: #374151; background-color: #fafafa; }

.highlight-val { font-weight: 700; color: #1677ff; margin-left: 6px; }
.highlight-val-sm { font-weight: 600; color: #111827; margin-left: 4px; }
.highlight-val-green { font-weight: 700; color: #52c41a; font-size: 15px; margin-left: 6px; }

/* Chat Container (Matches Screenshot 2) */
.chat-container { display: flex; height: calc(100vh - 86px); width: 100%; background: #ffffff; border: 1px solid var(--border-color); overflow: hidden; }
.chat-sidebar-icons { width: 50px; background: #ffffff; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 16px; }
.sidebar-icon-btn { width: 42px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #6b7280; font-size: 9px; cursor: pointer; padding: 6px 0; border: none; background: transparent; border-radius: 4px; text-align: center; transition: all 0.2s; }
.sidebar-icon-btn:hover { background-color: #f3f4f6; color: #1677ff; }
.sidebar-icon-btn.active { color: #1677ff; font-weight: 600; }

.account-pane { width: 180px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; background: #ffffff; }
.account-search-bar { padding: 10px; border-bottom: 1px solid #f0f0f0; }
.search-input { width: 100%; padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 12px; outline: none; }
.search-input:focus { border-color: #1677ff; }

.account-tabs { display: flex; border-bottom: 1px solid #f0f0f0; }
.account-tab-btn { flex: 1; padding: 6px 0; text-align: center; font-size: 12px; border: none; background: transparent; cursor: pointer; color: #6b7280; }
.account-tab-btn.active { color: #1677ff; border-bottom: 2px solid #1677ff; font-weight: 600; background-color: #e6f4ff; }

.account-list-content { flex: 1; overflow-y: auto; padding: 4px; }
.acc-item { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; border-left: 3px solid transparent; cursor: pointer; background: #ffffff; margin-bottom: 4px; border-radius: 6px; transition: all 0.2s; user-select: none; display: flex; align-items: center; gap: 10px; }
.acc-item:hover { background: #f0f7ff; border-left-color: #91caff; }
.acc-item.active { background: #e6f4ff; border-left-color: #1677ff; box-shadow: 0 1px 3px rgba(22, 119, 255, 0.15); }
.acc-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid #d9d9d9; background: #e6f4ff; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.acc-details-box { flex: 1; min-width: 0; }
.acc-item-title { font-weight: 600; font-size: 13px; color: #111827; display: flex; align-items: center; justify-content: space-between; }
.acc-nickname { font-size: 12px; font-weight: 600; color: #1677ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-item-badge { font-size: 10px; background: #52c41a; color: white; padding: 1px 6px; border-radius: 3px; font-weight: 500; }
.btn-edit-acc { width: 22px; height: 22px; border-radius: 4px; border: 1px solid #d9d9d9; background: #ffffff; color: #4b5563; display: flex; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; opacity: 0.7; transition: all 0.2s; flex-shrink: 0; }
.btn-edit-acc:hover { opacity: 1; border-color: #1677ff; color: #1677ff; background: #f0f7ff; }

.chats-pane { width: 220px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; background: #ffffff; }
.chats-header { padding: 10px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; justify-content: space-between; }
.chats-header-tabs { display: flex; gap: 12px; font-size: 13px; font-weight: 500; }
.chats-header-tab { cursor: pointer; }
.chats-header-tab.active { color: #1677ff; font-weight: 600; }

.chats-action-btns { display: flex; gap: 6px; }
.icon-circle-btn { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #1677ff; background: #1677ff; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; font-weight: 600; }
.icon-circle-btn.outline { background: white; color: #1677ff; }

.chat-search-bar { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
.chats-list-body { flex: 1; overflow-y: auto; }

.chat-item { padding: 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; background: #ffffff; transition: background 0.2s; }
.chat-item:hover { background: #f9fafb; }
.chat-item.active { background: #e6f4ff; border-left: 3px solid #1677ff; }

.dialogue-pane { flex: 1; display: flex; flex-direction: column; background: #ffffff; position: relative; }
.dialogue-header { height: 48px; border-bottom: 1px solid #e5e7eb; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; background: #fafafa; }
.tag-pill { font-size: 11px; background: #f0fdf4; color: #16a34a; padding: 2px 8px; border-radius: 4px; border: 1px solid #bbf7d0; font-weight: 500; }
.badge-source-ad { font-size: 10px; background: #2f54eb; color: #ffffff; border: 1px solid #2f54eb; padding: 1px 6px; border-radius: 3px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.badge-source-post { font-size: 10px; background: #fa8c16; color: #ffffff; border: 1px solid #fa8c16; padding: 1px 6px; border-radius: 3px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.badge-source-direct { font-size: 10px; background: #52c41a; color: #ffffff; border: 1px solid #52c41a; padding: 1px 6px; border-radius: 700; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }

/* EMBEDDED FB AD POST CARD (Matches Screenshot 1 & 3) */
.fb-ad-card {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: 8px;
  padding: 12px;
  max-width: 320px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.fb-ad-card-header { font-size: 11px; font-weight: 600; color: #d48806; display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.fb-ad-card-id { font-size: 10px; color: #8c6b00; margin-bottom: 8px; font-family: monospace; }
.fb-ad-card-img { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; border: 1px solid #ffe58f; }
.fb-ad-card-title { font-weight: 700; font-size: 12px; color: #1f2937; margin-bottom: 4px; line-height: 1.3; }
.fb-ad-card-desc { font-size: 11px; color: #4b5563; line-height: 1.3; }

/* SYSTEM PILL BADGE (Matches Screenshot 1 & 3) */
.system-pill-msg {
  align-self: center;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 12px;
  font-weight: 500;
  margin: 6px 0;
  border: 1px solid #e2e8f0;
}

/* CUSTOMER INFO PANEL (Far Right - Matches Screenshot 1, 2, 3) */
.customer-info-pane {
  width: 250px;
  border-left: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  font-size: 12px;
}
.cust-info-avatar-box { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 16px; border-bottom: 1px solid #f0f0f0; padding-bottom: 16px; }
.cust-info-avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; margin-bottom: 8px; border: 2px solid #1677ff; }
.cust-info-name { font-weight: 700; font-size: 15px; color: #111827; }
.cust-info-id { font-size: 10px; color: #9ca3af; margin-top: 2px; }

.cust-action-icons { display: flex; gap: 12px; justify-content: center; margin: 12px 0; color: #6b7280; }
.cust-action-btn { cursor: pointer; padding: 4px; border-radius: 4px; }
.cust-action-btn:hover { background: #f3f4f6; color: #1677ff; }

.cust-info-section { margin-bottom: 16px; }
.cust-info-title { font-weight: 600; color: #6b7280; font-size: 11px; text-transform: uppercase; margin-bottom: 8px; }
.cust-info-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #fafafa; }

/* BOTTOM QUICK TAG BAR (Matches Screenshot 2 & 3) */
.bottom-tag-strip {
  height: 32px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  overflow-x: auto;
}
.tag-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  border: none;
  color: white;
}
.tag-btn.under30 { background: #94a3b8; }
.tag-btn.fake { background: #ff4d4f; }
.tag-btn.ads { background: #1677ff; }
.tag-btn.pushtg { background: #52c41a; }
.tag-btn.oldws { background: #faad14; }
.tag-btn.tmr { background: #8c8c8c; }


.messages-stream { flex: 1; padding: 16px; overflow-y: auto; background: #f9fafb; display: flex; flex-direction: column; gap: 12px; }
.msg-bubble { max-width: 70%; padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.4; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.msg-bubble.customer { align-self: flex-start; background: #ffffff; color: #1f2937; border: 1px solid #e5e7eb; }
.msg-bubble.agent { align-self: flex-end; background: #1677ff; color: #ffffff; }

.chat-input-form { border-top: 1px solid #e5e7eb; padding: 12px; background: #ffffff; display: flex; gap: 8px; align-items: center; }
.btn-icon { border: none; background: transparent; color: #6b7280; cursor: pointer; display: flex; align-items: center; }

.quick-reply-bar { width: 32px; border-left: 1px solid var(--border-color); background: #ffffff; display: flex; flex-direction: column; align-items: center; padding-top: 16px; font-size: 12px; color: #6b7280; writing-mode: vertical-rl; letter-spacing: 1px; cursor: pointer; user-select: none; }
.quick-reply-bar:hover { background: #f9fafb; color: #1677ff; }

.quick-reply-drawer { width: 240px; border-left: 1px solid #e5e7eb; background: #ffffff; padding: 12px; overflow-y: auto; display: none; }
.quick-reply-drawer.open { display: block; }
.quick-item { padding: 8px; border: 1px solid #e5e7eb; border-radius: 4px; cursor: pointer; background: #fafafa; margin-bottom: 8px; }
.quick-item:hover { border-color: #1677ff; background: #e6f4ff; }

/* Buttons & Settings */
.btn-primary { background-color: #1677ff; color: white; border: none; padding: 8px 16px; border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary:hover { background-color: #4096ff; }
.btn-success { background-color: #52c41a; color: white; border: none; padding: 8px 16px; border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-success:hover { background-color: #73d13d; }

.settings-card { background-color: #ffffff; border: 1px solid var(--border-color); border-radius: 6px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-input, .form-select { width: 100%; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 13px; outline: none; font-family: inherit; }
.form-input:focus, .form-select:focus { border-color: #1677ff; }

/* Modal Dialog */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.open { display: flex; }
.modal-card { background: #ffffff; border-radius: 8px; width: 450px; max-width: 90%; padding: 24px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e5e7eb; padding-bottom: 12px; margin-bottom: 16px; font-weight: 600; font-size: 16px; }
.modal-close { cursor: pointer; font-size: 18px; color: #6b7280; }
.modal-close:hover { color: #111827; }
