/* ═══════════════════════════════════════════════════════════════
   Alvarez Tree Service — Chatbot Widget Styles
   ═══════════════════════════════════════════════════════════════ */

:root {
  --chat-primary: #F4651A;
  --chat-primary-dark: #d4550f;
  --chat-secondary: #52B788;
  --chat-forest: #1B4332;
  --chat-forest-deep: #0D1A10;
  --chat-bg: #0f1512;
  --chat-surface: #1a2420;
  --chat-surface-light: #243530;
  --chat-text: #f0ede8;
  --chat-text-muted: #8a9a92;
  --chat-border: rgba(255,255,255,0.08);
  --chat-radius: 20px;
  --chat-width: 380px;
  --chat-height: 540px;
}

/* ─── Floating Button ─────────────────────────────────────────── */
.alvarez-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  box-shadow:
    0 4px 20px rgba(244,101,26,0.4),
    0 0 0 0 rgba(244,101,26,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s;
  animation: chatPulse 3s ease-in-out infinite;
}

.alvarez-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(244,101,26,0.5);
  animation: none;
}

.alvarez-chat-btn:active {
  transform: scale(0.95);
}

.alvarez-chat-btn svg {
  width: 30px;
  height: 30px;
  fill: white;
  transition: transform 0.3s ease;
}

.alvarez-chat-btn:hover svg {
  transform: rotate(-8deg) scale(1.05);
}

.alvarez-chat-btn.open svg.icon-tree { display: none; }
.alvarez-chat-btn.open svg.icon-close { display: block; }
.alvarez-chat-btn:not(.open) svg.icon-tree { display: block; }
.alvarez-chat-btn:not(.open) svg.icon-close { display: none; }

/* Notification badge */
.alvarez-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--chat-secondary);
  color: white;
  font-size: 11px;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: badgePop 0.35s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(244,101,26,0.35), 0 0 0 0 rgba(244,101,26,0.25); }
  50% { box-shadow: 0 4px 20px rgba(244,101,26,0.35), 0 0 0 10px rgba(244,101,26,0); }
}

@keyframes badgePop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ─── Chat Container ──────────────────────────────────────────── */
.alvarez-chat-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9999;
  width: var(--chat-width);
  height: var(--chat-height);
  border-radius: var(--chat-radius);
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.alvarez-chat-container.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ─── Header ──────────────────────────────────────────────────── */
.alvarez-chat-header {
  background: linear-gradient(135deg, var(--chat-forest) 0%, var(--chat-forest-deep) 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(82,183,136,0.15);
}

.alvarez-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(82,183,136,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alvarez-chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: var(--chat-secondary);
}

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

.alvarez-chat-header-name {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: white;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.alvarez-chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.alvarez-chat-header-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-secondary);
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.alvarez-chat-header-status span {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.03em;
}

.alvarez-chat-close {
  background: rgba(255,255,255,0.08);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.alvarez-chat-close:hover {
  background: rgba(255,255,255,0.15);
}

.alvarez-chat-close svg {
  width: 14px;
  height: 14px;
  stroke: rgba(255,255,255,0.7);
}

/* ─── Messages Area ───────────────────────────────────────────── */
.alvarez-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.alvarez-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.alvarez-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.alvarez-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

/* Message bubbles */
.alvarez-msg {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  animation: messageIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  word-break: break-word;
}

@keyframes messageIn {
  0% { opacity: 0; transform: translateY(8px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.alvarez-msg.bot {
  align-self: flex-start;
  background: var(--chat-surface);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
}

.alvarez-msg.bot a {
  color: var(--chat-primary);
  text-decoration: none;
  font-weight: 600;
}

.alvarez-msg.bot a:hover {
  text-decoration: underline;
}

.alvarez-msg.bot strong {
  color: white;
  font-weight: 700;
}

.alvarez-msg.bot ul, .alvarez-msg.bot ol {
  margin: 6px 0;
  padding-left: 18px;
}

.alvarez-msg.bot li {
  margin-bottom: 3px;
}

.alvarez-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.alvarez-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 18px;
  background: var(--chat-surface);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  animation: messageIn 0.2s ease;
}

.alvarez-typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-text-muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.alvarez-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.alvarez-typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ─── Quick Buttons ───────────────────────────────────────────── */
.alvarez-chat-quick {
  padding: 6px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.alvarez-quick-btn {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--chat-border);
  background: transparent;
  color: var(--chat-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.alvarez-quick-btn:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
  background: rgba(244,101,26,0.08);
}

/* ─── Input Area ──────────────────────────────────────────────── */
.alvarez-chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--chat-bg);
}

.alvarez-chat-textarea {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--chat-text);
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  padding: 10px 14px;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.45;
  transition: border-color 0.2s;
}

.alvarez-chat-textarea::placeholder {
  color: var(--chat-text-muted);
}

.alvarez-chat-textarea:focus {
  border-color: rgba(244,101,26,0.4);
}

.alvarez-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--chat-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.alvarez-chat-send:hover {
  background: var(--chat-primary-dark);
  transform: scale(1.05);
}

.alvarez-chat-send:active {
  transform: scale(0.93);
}

.alvarez-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.alvarez-chat-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* ─── Responsive — mobile fullscreen ──────────────────────────── */
@media (max-width: 480px) {
  .alvarez-chat-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-height: 100dvh;
  }

  .alvarez-chat-btn {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .alvarez-chat-btn svg {
    width: 26px;
    height: 26px;
  }
}
