/* =============================================
   Chat Pro - Frontend Widget CSS v1.2
   ============================================= */

:root {
  --cp-primary:      #6366f1;
  --cp-primary-d:    #4f46e5;
  --cp-wa:           #25d366;
  --cp-wa-d:         #128c5e;
  --cp-text:         #1e293b;
  --cp-text-light:   #64748b;
  --cp-border:       #e2e8f0;
  --cp-bg:           #ffffff;
  --cp-bg-soft:      #f8fafc;
  --cp-bubble-user:  #6366f1;
  --cp-bubble-agent: #f1f5f9;
  --cp-radius:       16px;
  --cp-shadow:       0 20px 60px rgba(0,0,0,.18);
  --cp-z:            999999;
  --cp-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --cp-anim:         .2s cubic-bezier(.4,0,.2,1);
}

/* ── Root ── */
.chatpro-root {
  position: fixed;
  bottom: 24px;
  z-index: var(--cp-z);
  font-family: var(--cp-font);
}
.chatpro-right { right: 24px; }
.chatpro-left  { left: 24px; }

/* ── Launchers ── */
.cp-launchers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}
.chatpro-left .cp-launchers { align-items: flex-start; }

/* ── WhatsApp launcher — pill style, prominent ── */
.cp-wa-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cp-wa);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0 20px 0 6px;
  height: 56px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 24px rgba(37,211,102,.45);
  transition: transform var(--cp-anim), box-shadow var(--cp-anim);
  white-space: nowrap;
  font-family: var(--cp-font);
}
.cp-wa-launcher:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 10px 32px rgba(37,211,102,.55);
}
.cp-wa-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cp-wa-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
}
.cp-wa-sublabel {
  font-size: 11px;
  opacity: .85;
  margin-top: 1px;
}

/* ── Chat launcher button ── */
.cp-chat-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cp-primary);
  color: #fff;
  box-shadow: 0 6px 24px rgba(99,102,241,.45);
  transition: transform var(--cp-anim), box-shadow var(--cp-anim);
  position: relative;
  flex-shrink: 0;
}
.cp-chat-launcher:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 10px 32px rgba(99,102,241,.55);
}

.cp-launcher-icon { display: flex; align-items: center; }
.cp-notif-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: cp-pulse 1.5s infinite;
}
@keyframes cp-pulse {
  0%,100% { transform: scale(1); opacity:1; }
  50%      { transform: scale(1.4); opacity:.7; }
}

/* ── Panel ── */
.cp-panel {
  position: absolute;
  bottom: 82px;
  width: 380px;
  max-height: 600px;
  background: var(--cp-bg);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cpSlideUp var(--cp-anim);
}
.chatpro-right .cp-panel { right: 0; }
.chatpro-left  .cp-panel { left: 0; }

@keyframes cpSlideUp {
  from { opacity:0; transform: translateY(20px) scale(.95); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

/* ── Panel Header ── */
.cp-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--cp-primary);
  color: #fff;
}
.cp-panel-brand { display: flex; align-items: center; gap: 12px; }
.cp-panel-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  overflow: hidden;
  flex-shrink: 0;
}
.cp-panel-avatar img { width:100%; height:100%; object-fit:cover; }
.cp-panel-name  { font-weight: 600; font-size: 15px; }
.cp-panel-status { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; margin-top:2px; }
.cp-status-dot  { width:8px; height:8px; background:#4ade80; border-radius:50%; animation: cp-pulse 2s infinite; }
.cp-panel-close {
  background: rgba(255,255,255,.2);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--cp-anim);
}
.cp-panel-close:hover { background: rgba(255,255,255,.35); }

/* ── Tabs ── */
.cp-panel-tabs {
  display: flex;
  background: var(--cp-bg-soft);
  border-bottom: 1px solid var(--cp-border);
}
.cp-ptab {
  flex: 1; padding: 10px;
  background: none; border: none;
  font-size: 13px; font-weight: 500;
  color: var(--cp-text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--cp-anim);
}
.cp-ptab.active {
  color: var(--cp-primary);
  border-bottom-color: var(--cp-primary);
  background: var(--cp-bg);
}

/* ── Tab content ── */
.cp-tab-content { flex:1; display:flex; flex-direction:column; overflow:hidden; }

/* ── Pre-chat ── */
.cp-prechat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
}
.cp-prechat-welcome {
  text-align: center;
  margin-bottom: 24px;
}
.cp-prechat-icon { font-size: 40px; margin-bottom: 8px; }
.cp-prechat-welcome h3 { margin: 0 0 6px; font-size: 18px; color: var(--cp-text); }
.cp-prechat-welcome p  { margin: 0; font-size: 14px; color: var(--cp-text-light); }

.cp-field-group { margin-bottom: 14px; }
.cp-field-group label { display: block; font-size: 13px; font-weight: 500; color: var(--cp-text); margin-bottom: 5px; }
.cp-required { color: #ef4444; }
.cp-field {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px;
  border: 1.5px solid var(--cp-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--cp-font);
  color: var(--cp-text);
  background: var(--cp-bg);
  transition: border-color var(--cp-anim);
  outline: none;
}
.cp-field:focus { border-color: var(--cp-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

.cp-start-btn {
  width: 100%;
  padding: 12px;
  background: var(--cp-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background var(--cp-anim), transform var(--cp-anim);
  margin-top: 6px;
}
.cp-start-btn:hover { background: var(--cp-primary-d); transform: translateY(-1px); }

.cp-error { color: #ef4444; font-size: 13px; margin-bottom: 8px; text-align: center; }

/* ── Chat Body ── */
.cp-chat-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.cp-chat-msgs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  flex: 1;
}

/* ── Messages ── */
.cp-msg-wrap { display: flex; align-items: flex-end; gap: 6px; max-width: 85%; }
.cp-msg-wrap.cp-from-user  { align-self: flex-end; flex-direction: row-reverse; }
.cp-msg-wrap.cp-from-agent { align-self: flex-start; }

.cp-msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.cp-from-user  .cp-msg-bubble { background: var(--cp-primary); color: #fff; border-bottom-right-radius: 4px; }
.cp-from-agent .cp-msg-bubble { background: var(--cp-bubble-agent); color: var(--cp-text); border-bottom-left-radius: 4px; }

.cp-msg-image { max-width: 220px; border-radius: 12px; cursor: pointer; display: block; }
.cp-msg-file  { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.cp-from-user .cp-msg-file { color: #fff; }
.cp-from-agent .cp-msg-file { color: var(--cp-primary); }
.cp-file-icon { font-size: 20px; }
.cp-file-name { font-size: 13px; font-weight: 500; text-decoration: underline; }

.cp-msg-time { font-size: 10px; opacity: .6; margin-top: 3px; white-space: nowrap; }
.cp-from-user  .cp-msg-time { text-align: right; }
.cp-from-agent .cp-msg-time { text-align: left; }

.cp-msg-avatar-sm {
  width: 26px; height: 26px;
  background: var(--cp-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px;
  flex-shrink: 0;
}

/* Typing indicator */
.cp-typing { display: flex; gap: 4px; padding: 12px 16px; }
.cp-typing span {
  width: 7px; height: 7px;
  background: var(--cp-text-light);
  border-radius: 50%;
  animation: cp-bounce .8s infinite;
}
.cp-typing span:nth-child(2) { animation-delay:.15s; }
.cp-typing span:nth-child(3) { animation-delay:.3s; }
@keyframes cp-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-6px); }
}

/* ── Input area ── */
.cp-input-wrap {
  padding: 12px 14px;
  border-top: 1px solid var(--cp-border);
  background: var(--cp-bg);
}
.cp-input-row { display: flex; align-items: flex-end; gap: 8px; }
.cp-attach-btn {
  cursor: pointer;
  color: var(--cp-text-light);
  padding: 6px;
  border-radius: 8px;
  transition: color var(--cp-anim), background var(--cp-anim);
  flex-shrink: 0;
}
.cp-attach-btn:hover { color: var(--cp-primary); background: var(--cp-bg-soft); }
.cp-user-input {
  flex: 1;
  border: 1.5px solid var(--cp-border);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: var(--cp-font);
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color var(--cp-anim);
  color: var(--cp-text);
  background: var(--cp-bg);
}
.cp-user-input:focus { border-color: var(--cp-primary); }
.cp-send {
  width: 38px; height: 38px;
  background: var(--cp-primary);
  border: none; border-radius: 50%;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--cp-anim), transform var(--cp-anim);
}
.cp-send:hover { background: var(--cp-primary-d); transform: scale(1.08); }

.cp-upload-preview {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--cp-bg-soft);
  border-radius: 8px; padding: 7px 10px;
  font-size: 13px; color: var(--cp-text);
  margin-top: 8px;
}
.cp-preview-remove { background:none; border:none; cursor:pointer; color:var(--cp-text-light); font-size:16px; }

/* ── FAQ ── */
.cp-faq-search { padding: 12px 16px; border-bottom: 1px solid var(--cp-border); }
.cp-faq-list { flex:1; overflow-y:auto; padding: 8px 0; }

.cp-faq-item { border-bottom: 1px solid var(--cp-border); }
.cp-faq-q {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px; font-weight: 500;
  color: var(--cp-text);
  gap: 10px;
  transition: background var(--cp-anim);
}
.cp-faq-q:hover { background: var(--cp-bg-soft); }
.cp-faq-arrow { font-size: 12px; color: var(--cp-text-light); transition: transform var(--cp-anim); flex-shrink:0; }
.cp-faq-item.cp-open .cp-faq-arrow { transform: rotate(180deg); }
.cp-faq-a {
  display: none;
  padding: 0 18px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--cp-text-light);
}
.cp-faq-item.cp-open .cp-faq-a { display: block; }

.cp-faq-empty { text-align:center; padding:30px; color:var(--cp-text-light); font-size:14px; }
.cp-loading-small { text-align:center; padding:20px; color:var(--cp-text-light); font-size:13px; }

/* ── Scrollbar ── */
.cp-chat-body::-webkit-scrollbar,
.cp-prechat::-webkit-scrollbar,
.cp-faq-list::-webkit-scrollbar { width:4px; }
.cp-chat-body::-webkit-scrollbar-thumb,
.cp-prechat::-webkit-scrollbar-thumb,
.cp-faq-list::-webkit-scrollbar-thumb { background:var(--cp-border); border-radius:4px; }

/* ── Date separator ── */
.cp-date-sep {
  text-align: center;
  margin: 12px 0;
  font-size: 11px;
  color: var(--cp-text-light);
  position: relative;
}
.cp-date-sep::before, .cp-date-sep::after {
  content:'';
  position:absolute; top:50%; width:28%;
  height:1px; background:var(--cp-border);
}
.cp-date-sep::before { left:0; }
.cp-date-sep::after  { right:0; }

/* ── Mobile ── */
@media (max-width:480px) {
  .chatpro-root { bottom:0; right:0 !important; left:0 !important; width:100%; }
  .cp-launchers {
    position: fixed; bottom:16px; right:16px;
    align-items: flex-end;
  }
  .cp-panel {
    position: fixed; bottom:0; left:0; right:0;
    width:100%; max-height:92vh;
    border-radius:20px 20px 0 0;
  }
  .cp-wa-launcher { padding: 0 14px 0 5px; }
  .cp-wa-label { font-size: 13px; }
}
