:root {
  --rose-50: #fff1f2;
  --rose-100: #ffe4e6;
  --rose-200: #fecdd3;
  --rose-300: #fda4af;
  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-700: #be123c;

  --ink: #27181d;
  --muted: #8a6e75;
  --border: #f3d9dd;
  --bg: #fffafb;
  --surface: #ffffff;
  --bubble-in: #ffffff;
  --bubble-out: var(--rose-500);
  --shadow: 0 2px 10px rgba(190, 18, 60, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Segoe UI', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

/* ---------- shared ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--rose-500);
  color: #fff;
}
.btn-primary:hover { background: var(--rose-600); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-block { width: 100%; }

.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--rose-100); color: var(--rose-600); }

/* ---------- login page ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--rose-50), var(--rose-100));
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 28px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  gap: 4px;
}

.login-logo {
  font-size: 26px;
  font-weight: 800;
  color: var(--rose-600);
}

.login-tagline {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

.field input {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--rose-400); }

.form-error {
  background: var(--rose-50);
  color: var(--rose-700);
  border: 1px solid var(--rose-200);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 0;
}

/* ---------- app shell ---------- */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 100%;
  max-width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

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

.brand-block { display: flex; flex-direction: column; }
.brand { font-weight: 800; font-size: 18px; color: var(--rose-600); }
.agent-name { font-size: 12px; color: var(--muted); }

.search-box { padding: 10px 14px; }
.search-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--rose-50);
  outline: none;
  font-size: 14px;
}
.search-box input:focus { border-color: var(--rose-300); background: #fff; }

.label-filter {
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
  overflow-x: auto;
}
.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.chip-active { background: var(--rose-500); border-color: var(--rose-500); color: #fff; }

.conversation-list { flex: 1; overflow-y: auto; }

.list-empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

.conv-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.conv-item:hover { background: var(--rose-50); }
.conv-active { background: var(--rose-100); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--rose-200);
  color: var(--rose-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.conv-info { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.conv-preview {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.conv-labels { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.mini-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- chat panel ---------- */

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--rose-50);
  min-width: 0;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.chat-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }

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

.back-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--rose-600);
  cursor: pointer;
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-name { font-weight: 700; font-size: 15px; }
.chat-number { font-size: 12px; color: var(--muted); }

.assign-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  background: #fff;
  max-width: 140px;
}

.chat-labels {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.label-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.pill button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.label-add { position: relative; }
.label-add input {
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  outline: none;
  width: 140px;
}
.label-suggestions {
  position: absolute;
  top: 32px;
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 160px;
  z-index: 10;
  overflow: hidden;
}
.suggestion-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.suggestion-item:hover { background: var(--rose-50); }
.suggestion-new { color: var(--rose-600); font-weight: 600; border-top: 1px solid var(--border); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row { display: flex; }
.msg-in { justify-content: flex-start; }
.msg-out { justify-content: flex-end; }

.msg-bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.4;
}
.msg-in .msg-bubble { background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg-out .msg-bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 4px; }

.msg-text { white-space: pre-wrap; word-break: break-word; }

.msg-media {
  max-width: 100%;
  border-radius: 10px;
  display: block;
  margin-bottom: 4px;
}
.msg-media-audio { width: 220px; max-width: 100%; margin-bottom: 4px; }
.msg-doc {
  display: inline-block;
  color: inherit;
  text-decoration: underline;
  margin-bottom: 4px;
}
.msg-location a { color: inherit; }

.msg-meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  opacity: 0.75;
  margin-top: 4px;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  max-height: 120px;
}
.chat-composer textarea:focus { border-color: var(--rose-300); }

/* ---------- mobile ---------- */

@media (max-width: 767px) {
  .sidebar { max-width: none; }
  .chat-panel { display: none; }
  .app.mobile-chat-active .sidebar { display: none; }
  .app.mobile-chat-active .chat-panel { display: flex; }
  .back-btn { display: inline-block; }
}
