/* ============================================================
   Custom Live Chat – Widget CSS
   ============================================================ */

:root {
  --clc-color: #d6232f;
  --clc-color-dark: #a81520;
  --clc-radius: 16px;
  --clc-shadow: 0 8px 32px rgba(0,0,0,.18);
  --clc-z: 9999;
  --clc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Root ─────────────────────────────────────────── */
#clc-root {
  --clc-color: var(--clc-color); /* overridden via JS .style.setProperty */
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--clc-z);
  font-family: var(--clc-font);
  font-size: 14px;
  line-height: 1.45;
}

/* ── Bubble ───────────────────────────────────────── */
#clc-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--clc-color);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  transition: transform .2s ease, background .15s ease;
  position: relative;
  margin-left: auto;
}

#clc-bubble:hover { background: var(--clc-color-dark); transform: scale(1.08); }
#clc-bubble.clc-bubble-open { background: #374151; }

#clc-bubble svg { width: 26px; height: 26px; stroke: #fff; flex: 0 0 auto; }

/* Badge chưa đọc */
.clc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  background: #ef4444;
  color: #fff;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  pointer-events: none;
}
.clc-hidden { display: none !important; }

/* ── Panel ────────────────────────────────────────── */
#clc-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 340px;
  max-height: 520px;
  background: #fff;
  border-radius: var(--clc-radius);
  box-shadow: var(--clc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

#clc-panel.clc-panel-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ── Header ───────────────────────────────────────── */
.clc-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--clc-color);
  color: #fff;
  flex: 0 0 auto;
}

.clc-panel-avatar {
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
}

.clc-panel-title { flex: 1; overflow: hidden; }
.clc-panel-title strong { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.clc-online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.clc-online-text { font-size: 12px; opacity: .9; }

.clc-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  opacity: .8;
  flex: 0 0 auto;
}
.clc-close-btn:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ── Message area ─────────────────────────────────── */
.clc-msg-area {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8f9fb;
  scroll-behavior: smooth;
}

.clc-msg { display: flex; flex-direction: column; max-width: 80%; }
.clc-msg--visitor { align-self: flex-end; align-items: flex-end; }
.clc-msg--admin   { align-self: flex-start; align-items: flex-start; }

.clc-msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.clc-msg--visitor .clc-msg-bubble {
  background: var(--clc-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.clc-msg--admin .clc-msg-bubble {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.clc-msg-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 3px;
  padding: 0 4px;
}

.clc-msg-system {
  align-self: center;
  background: #e9f0fb;
  color: #4b5563;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 20px;
  text-align: center;
  max-width: 90%;
}

/* ── Phone form ───────────────────────────────────── */
.clc-phone-form {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #f1f1f1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}
.clc-phone-form p { margin: 0 0 4px; color: #6b7280; font-size: 13px; }
.clc-phone-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.clc-phone-form input:focus { border-color: var(--clc-color); }

/* ── Input bar ────────────────────────────────────── */
.clc-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f1f1f1;
  background: #fff;
  flex: 0 0 auto;
}

#clcInput {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: var(--clc-font);
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.45;
  transition: border-color .15s;
}
#clcInput:focus { border-color: var(--clc-color); }

/* ── Send / Submit button ─────────────────────────── */
.clc-send-btn {
  flex: 0 0 auto;
  background: var(--clc-color);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 0 14px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--clc-font);
  gap: 5px;
  transition: background .15s, transform .1s;
}
.clc-send-btn:hover { background: var(--clc-color-dark); }
.clc-send-btn:active { transform: scale(.96); }
.clc-send-btn svg { width: 18px; height: 18px; fill: #fff; }
.clc-phone-form .clc-send-btn { width: 100%; height: 40px; font-size: 14px; border-radius: 8px; }

/* ── Mobile ───────────────────────────────────────── */
@media (max-width: 480px) {
  #clc-root { bottom: 16px; right: 14px; }
  #clc-panel { width: calc(100vw - 28px); bottom: 64px; right: 0; max-height: 80vh; }
  #clc-bubble { width: 50px; height: 50px; }
  #clc-bubble svg { width: 22px; height: 22px; }
}

/* ── Bảo mật: honeypot ẩn + captcha ───────────────── */
.clc-hp {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.clc-captcha { margin: 8px 0; min-height: 0; }
.clc-captcha:empty { margin: 0; }
