/* =====================================================
   CASCINA BRUNO - Chatbot Widget Styles
   ===================================================== */

/* ----- Floating Button ----- */
.cb-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-accent, #7E8D75);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.cb-chat-btn:hover {
  background: var(--color-accent-hover, #5E6B56);
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.cb-chat-btn svg {
  width: 28px;
  height: 28px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cb-chat-btn .cb-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg);
}

.cb-chat-btn.cb-open .cb-icon-chat {
  opacity: 0;
  transform: rotate(90deg);
}

.cb-chat-btn.cb-open .cb-icon-close {
  opacity: 1;
  transform: rotate(0deg);
}

/* Pulse animation on first load */
@keyframes cb-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); }
  50% { box-shadow: 0 4px 16px rgba(126, 141, 117, 0.5), 0 0 0 8px rgba(126, 141, 117, 0.15); }
}

.cb-chat-btn.cb-pulse {
  animation: cb-pulse 2s ease-in-out 3;
}

/* ----- Chat Window ----- */
.cb-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cb-chat-window.cb-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ----- Header ----- */
.cb-chat-header {
  background: var(--color-accent, #7E8D75);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cb-chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.cb-chat-header-info {
  flex: 1;
  min-width: 0;
}

.cb-chat-header-name {
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.2;
}

.cb-chat-header-status {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.3;
}

.cb-chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.cb-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ----- Messages Area ----- */
.cb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9f8f6;
  min-height: 200px;
  max-height: 320px;
}

.cb-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.cb-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cb-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

/* ----- Message Bubbles ----- */
.cb-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: cb-msg-in 0.3s ease;
}

@keyframes cb-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.cb-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--color-text-primary, #212121);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cb-msg-user {
  align-self: flex-end;
  background: var(--color-accent, #7E8D75);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cb-msg-bot a {
  color: var(--color-accent, #7E8D75);
  text-decoration: underline;
}

.cb-msg-bot a:hover {
  color: var(--color-accent-hover, #5E6B56);
}

/* Typing indicator */
.cb-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cb-typing span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: cb-typing-dot 1.2s ease-in-out infinite;
}

.cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ----- Quick Suggestions ----- */
.cb-suggestions {
  padding: 8px 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f9f8f6;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.cb-suggestions button {
  background: #fff;
  border: 1px solid var(--color-accent, #7E8D75);
  color: var(--color-accent, #7E8D75);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  font-family: var(--font-sans, 'Manrope', sans-serif);
}

.cb-suggestions button:hover {
  background: var(--color-accent, #7E8D75);
  color: #fff;
}

/* ----- Input Area ----- */
.cb-chat-input {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  gap: 8px;
  flex-shrink: 0;
}

.cb-chat-input input {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font-sans, 'Manrope', sans-serif);
  outline: none;
  transition: border-color 0.2s ease;
  background: #f9f8f6;
}

.cb-chat-input input:focus {
  border-color: var(--color-accent, #7E8D75);
}

.cb-chat-input input::placeholder {
  color: #999;
}

.cb-chat-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent, #7E8D75);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.cb-chat-input button:hover {
  background: var(--color-accent-hover, #5E6B56);
}

.cb-chat-input button:active {
  transform: scale(0.92);
}

/* ----- Responsive ----- */
@media (max-width: 480px) {
  .cb-chat-window {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }

  .cb-chat-messages {
    max-height: none;
    flex: 1;
  }

  .cb-chat-btn {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }

  .cb-chat-btn svg {
    width: 24px;
    height: 24px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .cb-chat-window {
    width: 340px;
    max-height: 480px;
  }
}

/* ----- Language Picker ----- */
.cb-lang-picker {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: #f9f8f6;
  text-align: center;
  gap: 24px;
}

.cb-lang-picker-title {
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text-primary, #212121);
  line-height: 1.3;
}

.cb-lang-picker-subtitle {
  font-size: 13px;
  color: #666;
  margin-top: -12px;
}

.cb-lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.cb-lang-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  font-family: var(--font-sans, 'Manrope', sans-serif);
}

.cb-lang-option:hover {
  border-color: var(--color-accent, #7E8D75);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cb-lang-option:active {
  transform: scale(0.97);
}

.cb-lang-flag {
  font-size: 32px;
  line-height: 1;
}

.cb-lang-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary, #212121);
}

/* ----- Print: hide chatbot ----- */
@media print {
  .cb-chat-btn,
  .cb-chat-window {
    display: none !important;
  }
}
