/* ─── CERTIFICATE CHAT WIDGET ──────────────────── */
.cert-chat {
  position: fixed; bottom: 26px; right: 26px;
  z-index: 9998; font-family: 'Poppins', sans-serif;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}

/* Toggle button */
.cert-chat-btn {
  display: flex; align-items: center; gap: 9px;
  background: linear-gradient(135deg, #0a3d62, #1565a3);
  color: white; border: none; border-radius: 50px;
  padding: 12px 22px 12px 16px;
  font-size: 0.82rem; font-weight: 700; font-family: 'Poppins', sans-serif;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 8px 26px rgba(10,61,98,0.42);
  transition: all 0.28s ease;
}
.cert-chat-btn:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(10,61,98,0.52); }
.cert-chat-btn i { font-size: 1.05rem; }

/* Panel */
.cert-chat-panel {
  width: 340px; background: white;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.16), 0 0 0 1px rgba(10,61,98,0.07);
  overflow: hidden; flex-direction: column;
  display: none; max-height: 500px;
}
.cert-chat-panel.open {
  display: flex;
  animation: chatUp 0.24s cubic-bezier(0.4,0,0.2,1) both;
}
@keyframes chatUp {
  from { opacity:0; transform: translateY(12px) scale(0.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

/* Header */
.ccp-header {
  background: linear-gradient(135deg, #040f1a, #0a3d62);
  padding: 13px 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ccp-header-left  { display: flex; align-items: center; gap: 10px; }
.ccp-header-right { display: flex; align-items: center; gap: 6px; }
.ccp-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(246,185,59,0.15); border: 1.5px solid rgba(246,185,59,0.3);
  display: flex; align-items: center; justify-content: center;
  color: #f6b93b; font-size: 0.75rem; font-weight: 900;
  overflow: hidden; flex-shrink: 0;
}
.ccp-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ccp-name { font-size: 0.83rem; font-weight: 800; color: white; }
.ccp-status {
  font-size: 0.65rem; color: rgba(255,255,255,0.5);
  display: flex; align-items: center; gap: 5px; font-weight: 500; margin-top: 1px;
}
.ccp-dot {
  width: 6px; height: 6px; background: #22c55e; border-radius: 50%;
  animation: ccpBlink 2s ease-in-out infinite;
}
@keyframes ccpBlink { 0%,100%{opacity:1} 50%{opacity:0.35} }
.ccp-close, .ccp-clear {
  background: rgba(255,255,255,0.1); border: none; border-radius: 7px;
  color: rgba(255,255,255,0.65); width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.72rem; transition: all 0.2s;
}
.ccp-close:hover { background: rgba(255,255,255,0.2); color: white; }
.ccp-clear:hover { background: rgba(220,38,38,0.3); color: white; }

/* Messages */
.ccp-messages {
  flex: 1; overflow-y: auto; padding: 12px 12px 4px;
  display: flex; flex-direction: column; gap: 9px;
  min-height: 150px; max-height: 240px; scroll-behavior: smooth;
}
.ccp-messages::-webkit-scrollbar { width: 3px; }
.ccp-messages::-webkit-scrollbar-thumb { background: rgba(10,61,98,0.12); border-radius: 3px; }
.ccp-msg { display: flex; gap: 7px; align-items: flex-end; animation: msgIn 0.18s ease both; }
.ccp-msg.user { flex-direction: row-reverse; }
@keyframes msgIn { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }

.ccp-msg-inner { display: flex; flex-direction: column; max-width: 80%; }
.ccp-msg.user .ccp-msg-inner { align-items: flex-end; }
.ccp-msg.bot  .ccp-msg-inner { align-items: flex-start; }

.ccp-bubble {
  padding: 8px 12px; position: relative;
  font-size: 0.78rem; line-height: 1.62; font-weight: 500;
}
.ccp-msg.bot  .ccp-bubble { background:#f1f5f9; color:#1e293b; border-radius:12px 12px 12px 3px; }
.ccp-msg.user .ccp-bubble { background:linear-gradient(135deg,#0a3d62,#1565a3); color:white; border-radius:12px 12px 3px 12px; }
.ccp-bubble strong { font-weight: 800; }
.ccp-bubble em { font-style: italic; opacity: 0.85; }
.ccp-bubble a { color: #0a3d62; font-weight: 700; text-decoration: none; }
.ccp-msg.user .ccp-bubble a { color: #ffd866; }

/* Timestamp */
.ccp-time {
  font-size: 0.6rem; color: #94a3b8; font-weight: 500;
  margin-top: 3px; padding: 0 4px;
}

/* Copy button */
.ccp-copy {
  position: absolute; top: 5px; right: 6px;
  background: rgba(10,61,98,0.07); border: none; border-radius: 5px;
  color: #94a3b8; width: 20px; height: 20px;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.6rem; transition: all 0.18s;
  padding: 0;
}
.ccp-msg.bot .ccp-bubble:hover .ccp-copy { display: flex; }
.ccp-copy:hover { background: #0a3d62; color: white; }

/* Typing indicator */
.typing-dots { display: flex; align-items: center; gap: 4px; padding: 4px 2px; }
.typing-dot {
  width: 7px; height: 7px; background: #94a3b8; border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* Suggestions */
.ccp-suggestions {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  max-height: 190px;
  overflow-y: auto;
}
.ccp-suggestions::-webkit-scrollbar { width: 3px; }
.ccp-suggestions::-webkit-scrollbar-thumb { background: rgba(10,61,98,0.1); border-radius: 3px; }

.ccp-sug {
  display: flex;
  align-items: center;
  gap: 9px;
  background: white;
  border: 1.5px solid #e2e8f0;
  border-left: 3px solid #0a3d62;
  border-radius: 8px;
  padding: 7px 10px 7px 10px;
  font-size: 0.73rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: 'Poppins', sans-serif;
  transition: all 0.18s ease;
  line-height: 1.3;
}
.ccp-sug::before {
  content: '?';
  width: 20px; height: 20px;
  background: rgba(10,61,98,0.07);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 900; color: #0a3d62;
  flex-shrink: 0;
}
.ccp-sug::after {
  content: '→';
  margin-left: auto;
  font-size: 0.72rem;
  color: #94a3b8;
  transition: all 0.18s ease;
  flex-shrink: 0;
}
.ccp-sug:hover {
  background: #0a3d62;
  border-color: #0a3d62;
  color: white;
  transform: translateX(3px);
}
.ccp-sug:hover::before { background: rgba(255,255,255,0.15); color: white; }
.ccp-sug:hover::after  { color: rgba(255,255,255,0.7); }

.ccp-sug-removing {
  animation: pillFade 0.22s ease forwards;
  pointer-events: none;
}
@keyframes pillFade {
  from { opacity: 1; transform: translateX(0) scaleY(1); max-height: 60px; }
  to   { opacity: 0; transform: translateX(6px) scaleY(0.7); max-height: 0; padding: 0; margin: 0; }
}

/* Input row */
.ccp-input-row {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 10px; border-top: 1px solid #f1f5f9; flex-shrink: 0;
}
.ccp-input {
  flex: 1; border: 1.5px solid #e2e8f0; border-radius: 50px;
  padding: 7px 13px; font-size: 0.77rem; font-family: 'Poppins', sans-serif;
  outline: none; color: #1e293b; transition: border-color 0.2s;
}
.ccp-input:focus { border-color: #0a3d62; }
.ccp-input::placeholder { color: #94a3b8; }
.ccp-send {
  width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg,#0a3d62,#1565a3);
  color: white; border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.72rem; transition: all 0.2s;
}
.ccp-send:hover { transform: scale(1.1); box-shadow: 0 4px 12px rgba(10,61,98,0.35); }

@media (max-width: 767px) {
  .cert-chat          { bottom: 16px; right: 16px; }
  .cert-chat-btn      { padding: 10px 16px 10px 13px; font-size: 0.78rem; }
  .cert-chat-panel    { width: 300px; max-height: 430px; }
  .ccp-messages       { max-height: 200px; min-height: 120px; }
  .ccp-bubble         { font-size: 0.76rem; }
  .ccp-sug            { font-size: 0.65rem; padding: 4px 9px; }
}

@media (max-width: 480px) {
  .cert-chat          { bottom: 12px; right: 12px; }
  .cert-chat-panel    { width: calc(100vw - 24px); max-height: 420px; }
  .cert-chat-btn      { padding: 9px 14px 9px 12px; font-size: 0.76rem; }
  .ccp-messages       { max-height: 180px; }
}

@media (max-width: 360px) {
  .cert-chat-btn span { display: none; }
  .cert-chat-btn      { padding: 11px; border-radius: 50%; }
  .cert-chat-btn i    { font-size: 1.1rem; margin: 0; }
}
