/* ============================================================
   RisvegliaCase — Chatbot Widget Styles
   ============================================================ */

:root {
  --cb-yellow:  #FFC72C;
  --cb-black:   #0A0A0A;
  --cb-red:     #E63946;
  --cb-white:   #FFFFFF;
  --cb-gray-bg: #F5F5F5;
  --cb-border:  #E5E7EB;
  --cb-text:    #1A1A1A;
  --cb-subtext: #6B7280;
  --cb-shadow:  0 20px 60px rgba(0,0,0,0.18);
  --cb-radius:  20px;
}

/* ============================================================
   WIDGET CONTAINER
   ============================================================ */
#chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================================
   TOGGLE BUTTON
   ============================================================ */
#chatbot-toggle {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--cb-yellow);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,199,44,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

#chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(255,199,44,0.55);
}

#chatbot-toggle:focus-visible {
  outline: 3px solid var(--cb-black);
  outline-offset: 3px;
}

#chatbot-toggle.pulse {
  animation: cb-pulse 2s ease-out 3;
}

@keyframes cb-pulse {
  0%   { box-shadow: 0 4px 20px rgba(255,199,44,.45), 0 0 0 0   rgba(255,199,44,.55); }
  70%  { box-shadow: 0 4px 20px rgba(255,199,44,.45), 0 0 0 18px rgba(255,199,44,0);  }
  100% { box-shadow: 0 4px 20px rgba(255,199,44,.45), 0 0 0 0   rgba(255,199,44,0);  }
}

/* ============================================================
   NOTIFICATION BADGE
   ============================================================ */
#chatbot-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cb-red);
  color: var(--cb-white);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid var(--cb-white);
  animation: cb-badge-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.4);
}

@keyframes cb-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ============================================================
   TOOLTIP
   ============================================================ */
#chatbot-tooltip {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  background: var(--cb-black);
  color: var(--cb-white);
  padding: 9px 15px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#chatbot-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 22px;
  border: 7px solid transparent;
  border-top-color: var(--cb-black);
}

#chatbot-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */
#chatbot-window {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 365px;
  height: 530px;
  background: var(--cb-white);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.82) translateY(16px);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.175,0.885,0.32,1.275),
              opacity 0.25s ease;
  pointer-events: none;
  border: 1px solid rgba(0,0,0,0.08);
}

#chatbot-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ============================================================
   HEADER
   ============================================================ */
#chatbot-header {
  background: var(--cb-black);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cb-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: var(--cb-black);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.cb-header-info {
  flex: 1;
  min-width: 0;
}

.cb-header-name {
  color: var(--cb-white);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  margin: 0;
}

.cb-header-status {
  color: #4ADE80;
  font-size: 11px;
  font-weight: 500;
  margin: 0;
}

#chatbot-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

#chatbot-close:hover {
  color: var(--cb-white);
  background: rgba(255,255,255,0.12);
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F9FAFB;
  scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar       { width: 4px; }
#chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#chatbot-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }

/* ============================================================
   MESSAGE BUBBLES
   ============================================================ */
.cb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
  animation: cb-msg-in 0.28s ease both;
}

@keyframes cb-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg.user {
  flex-direction: row-reverse;
}

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cb-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 9px;
  color: var(--cb-black);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.cb-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
}

.cb-msg.bot .cb-bubble {
  background: var(--cb-white);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cb-msg.user .cb-bubble {
  background: var(--cb-black);
  color: var(--cb-white);
  border-bottom-right-radius: 4px;
}

.cb-bubble a {
  color: var(--cb-yellow);
  text-decoration: underline;
}

.cb-bubble strong { font-weight: 700; }
.cb-bubble em     { font-style: italic; }

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
#cb-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: cb-msg-in 0.28s ease both;
}

.cb-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--cb-white);
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cb-typing-dot {
  width: 7px;
  height: 7px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: cb-typing 1.3s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes cb-typing {
  0%, 60%, 100% { transform: translateY(0);    opacity: .6; }
  30%           { transform: translateY(-5px); opacity: 1;  }
}

/* ============================================================
   QUICK REPLY OPTIONS
   ============================================================ */
.cb-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-left: 36px;
  animation: cb-msg-in 0.28s ease 0.08s both;
}

.cb-opt-btn {
  background: var(--cb-white);
  border: 1.5px solid var(--cb-yellow);
  color: var(--cb-black);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s, opacity 0.15s;
  font-family: inherit;
  line-height: 1.3;
  white-space: nowrap;
}

.cb-opt-btn:hover:not(:disabled) {
  background: var(--cb-yellow);
  color: var(--cb-black);
  transform: translateY(-1px);
}

.cb-opt-btn:active:not(:disabled) {
  transform: translateY(0);
}

.cb-opt-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  border-color: #D1D5DB;
  color: var(--cb-subtext);
}

/* ============================================================
   INPUT AREA
   ============================================================ */
#chatbot-input-area {
  padding: 12px 14px;
  background: var(--cb-white);
  border-top: 1px solid var(--cb-border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  border: 1.5px solid var(--cb-border);
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  background: #F9FAFB;
  color: var(--cb-text);
  min-width: 0;
}

#chatbot-input:focus {
  border-color: var(--cb-yellow);
  background: var(--cb-white);
}

#chatbot-input::placeholder {
  color: #9CA3AF;
}

#chatbot-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--cb-yellow);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
  outline: none;
}

#chatbot-send:hover {
  transform: scale(1.1);
  background: #e6b325;
}

#chatbot-send:active {
  transform: scale(0.95);
}

#chatbot-send:focus-visible {
  outline: 3px solid var(--cb-black);
  outline-offset: 2px;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  #chatbot-widget {
    bottom: 16px;
    right: 16px;
  }

  #chatbot-window {
    width: calc(100vw - 32px);
    height: 72vh;
    right: -8px;
    bottom: 74px;
  }

  .cb-bubble {
    max-width: 88%;
  }
}
