/* ========================================================
   Tổng đài Quốc gia Bảo vệ Trẻ em 111 - Chat Widget CSS
   ======================================================== */

:root {
  --cp-primary: #0284c7;
  --cp-primary-dark: #0369a1;
  --cp-primary-light: #e0f2fe;
  --cp-emergency: #dc2626;
  --cp-emergency-bg: #fef2f2;
  --cp-emergency-border: #fca5a5;
  --cp-text-main: #1e293b;
  --cp-text-muted: #64748b;
  --cp-bg: #f8fafc;
  --cp-white: #ffffff;
  --cp-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --cp-radius: 16px;
  --cp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#cp-widget-container {
  font-family: var(--cp-font);
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
}

/* Floating Action Button (Launcher) */
#cp-widget-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.4);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 15px;
}

#cp-widget-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 24px rgba(2, 132, 199, 0.5);
}

#cp-widget-launcher .cp-launcher-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cp-widget-launcher .cp-badge-111,
#cp-widget-launcher .cp-badge-247 {
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  animation: pulse-red 2s infinite;
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
}

@keyframes pulse-red {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Chat Window Box */
#cp-chat-window {
  display: none;
  flex-direction: column;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 100px);
  background: var(--cp-white);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow);
  overflow: hidden;
  border: 1px solid #e2e8f0;
  position: absolute;
  bottom: 0;
  right: 0;
  animation: cp-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cp-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chat Header */
.cp-chat-header {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cp-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cp-header-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.cp-header-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.cp-header-subtitle {
  font-size: 11px;
  color: #bae6fd;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.cp-status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
}

.cp-header-actions button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cp-header-actions button:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Sticky Emergency Banner */
.cp-emergency-banner {
  background: var(--cp-emergency-bg);
  border-bottom: 1px solid var(--cp-emergency-border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #991b1b;
}

.cp-emergency-banner-btn {
  background: #dc2626;
  color: #fff;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cp-emergency-banner-btn:hover {
  background: #b91c1c;
}

/* Messages Container */
.cp-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: var(--cp-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message Bubbles */
.cp-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.cp-msg-row.user {
  align-self: flex-end;
}

.cp-msg-row.bot {
  align-self: flex-start;
}

.cp-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.cp-msg-row.user .cp-bubble {
  background: #0284c7;
  color: #fff;
  border-bottom-right-radius: 3px;
}

.cp-msg-row.bot .cp-bubble {
  background: #ffffff;
  color: var(--cp-text-main);
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cp-bubble p {
  margin: 0 0 6px 0;
}
.cp-bubble p:last-child {
  margin-bottom: 0;
}

.cp-bubble ul, .cp-bubble ol {
  margin: 4px 0;
  padding-left: 20px;
}

.cp-bubble strong {
  color: #0369a1;
}

.cp-msg-time {
  font-size: 10px;
  color: var(--cp-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.cp-msg-row.user .cp-msg-time {
  text-align: right;
}

/* Emergency Box in Stream */
.cp-emergency-card {
  background: #fff;
  border: 2px solid #ef4444;
  border-radius: 12px;
  padding: 14px;
  margin: 6px 0;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.cp-em-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.cp-em-hotlines {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.cp-em-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  text-decoration: none;
  font-weight: 600;
  font-size: 12.5px;
  transition: all 0.2s;
}

.cp-em-btn:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.cp-em-btn .cp-em-num {
  background: #dc2626;
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.cp-em-steps {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.4;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
}

.cp-em-steps ol {
  margin: 4px 0 0 0;
  padding-left: 16px;
}

/* Suggested Question Chips */
.cp-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.cp-chip {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.cp-chip:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
  transform: translateX(2px);
}

/* Typing Indicator */
.cp-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  width: fit-content;
}

.cp-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: cp-bounce 1.4s infinite ease-in-out both;
}

.cp-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cp-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes cp-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.cp-chat-input-area {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px;
}

.cp-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cp-input-field {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.cp-input-field:focus {
  border-color: #0284c7;
}

.cp-send-btn {
  background: #0284c7;
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cp-send-btn:hover {
  background: #0369a1;
}

.cp-footer-note {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
}
