/* ═══════════════════════════════════════
   STORIED FLAVOURS — CAM Chatbot Styles
   Floating button + chat interface
   ═══════════════════════════════════════ */

/* ── Chatbot-specific colors ── */
:root {
  --cam-bg-user: var(--color-amber-light);
  --cam-bg-cam: var(--surface-card);
  --cam-text-user: var(--color-brown-900);
  --cam-text-cam: var(--text-primary);
  --cam-fab-bg: var(--color-vintage-grape);
  --cam-fab-shadow: 0 4px 20px rgba(93, 57, 84, 0.4);
  --cam-unread-dot: var(--color-red);
}

/* ══════════════════════════════════════
   Floating Action Button (FAB)
   ══════════════════════════════════════ */

.cam-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: var(--color-vintage-grape);
  box-shadow: var(--cam-fab-shadow);
  border: none;
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: all var(--duration-normal) var(--ease-out);
  animation: cam-float 3s ease-in-out infinite;
}

.cam-fab:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 30px rgba(93, 57, 84, 0.5);
}

.cam-fab.open .cam-fab-icon {
  transform: rotate(180deg);
}

.cam-fab-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  display: block;
  transition: transform var(--duration-normal);
}

/* Unread badge */
.cam-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--cam-unread-dot);
  border: 2px solid var(--surface-page);
  border-radius: var(--radius-full);
  animation: cam-pulse 2s infinite;
}

/* Float animation */
@keyframes cam-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes cam-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
  }
}

/* ══════════════════════════════════════
   Chat Container
   ══════════════════════════════════════ */

.cam-chat {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  height: 600px;
  background: var(--surface-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: cam-slide-in var(--duration-normal) var(--ease-out);
}

@keyframes cam-slide-in {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.cam-chat.closing {
  animation: cam-slide-out var(--duration-normal) var(--ease-out);
}

@keyframes cam-slide-out {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
}

/* ══════════════════════════════════════
   Header
   ══════════════════════════════════════ */

.cam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-card);
  flex-shrink: 0;
}

.cam-header-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cam-header-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.cam-header-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.cam-header-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  line-height: 1.2;
}

.cam-header-actions {
  display: flex;
  gap: var(--space-2);
}

.cam-header .btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  font-size: 18px;
}

.cam-header .btn-icon:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

/* ══════════════════════════════════════
   Messages Area
   ══════════════════════════════════════ */

.cam-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.cam-messages::-webkit-scrollbar {
  width: 6px;
}

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

.cam-messages::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

.cam-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-brown-400);
}

/* ══════════════════════════════════════
   Message Bubble
   ══════════════════════════════════════ */

.cam-message {
  display: flex;
  gap: var(--space-3);
  animation: cam-message-slide-in var(--duration-fast) var(--ease-out);
}

@keyframes cam-message-slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cam-message.user {
  flex-direction: row-reverse;
}

.cam-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-amber-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.cam-message.user .cam-message-avatar {
  background: var(--color-terracotta-light);
}

.cam-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.cam-message-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.cam-message.user .cam-message-content {
  align-items: flex-end;
}

.cam-message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.cam-message.cam .cam-message-bubble {
  background: var(--cam-bg-cam);
  color: var(--cam-text-cam);
  border-bottom-left-radius: var(--radius-sm);
}

.cam-message.user .cam-message-bubble {
  background: var(--cam-bg-user);
  color: var(--cam-text-user);
  border-bottom-right-radius: var(--radius-sm);
}

.cam-message-timestamp {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  padding: 0 var(--space-2);
}

/* ══════════════════════════════════════
   Quick Actions
   ══════════════════════════════════════ */

.cam-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.cam-quick-action {
  padding: 6px 12px;
  background: var(--color-amber-light);
  border: 1px solid var(--color-amber);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-amber-dark);
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
}

.cam-quick-action:hover {
  background: var(--color-amber);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.cam-quick-action:active {
  transform: translateY(0);
}

/* ══════════════════════════════════════
   Typing Indicator
   ══════════════════════════════════════ */

.cam-typing {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  width: fit-content;
}

.cam-typing-dots {
  display: flex;
  gap: 4px;
}

.cam-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: cam-typing-wave 1.4s infinite;
}

.cam-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.cam-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes cam-typing-wave {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

/* ══════════════════════════════════════
   Context Bar (Page-Specific Suggestions)
   ══════════════════════════════════════ */

.cam-context-bar {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-light);
  background: var(--surface-card);
  flex-shrink: 0;
}

.cam-context-action {
  padding: 4px 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
}

.cam-context-action:hover {
  background: var(--color-amber-light);
  border-color: var(--color-amber);
  color: var(--color-amber-dark);
  transform: translateY(-1px);
}

.cam-context-action:active {
  transform: translateY(0);
}

/* ══════════════════════════════════════
   Input Area
   ══════════════════════════════════════ */

.cam-input-area {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-light);
  background: var(--surface-card);
  flex-shrink: 0;
}

.cam-input-wrapper {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.cam-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--text-primary);
  resize: none;
  max-height: 100px;
  min-height: 40px;
  transition: border-color var(--duration-fast);
  line-height: 1.5;
}

.cam-input:focus {
  border-color: var(--color-amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
  outline: none;
}

.cam-input::placeholder {
  color: var(--text-muted);
}

.cam-send-btn {
  width: 40px;
  height: 40px;
  background: var(--color-amber);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--duration-fast);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cam-send-btn:hover:not(:disabled) {
  background: var(--color-amber-dark);
  transform: scale(1.05);
}

.cam-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.cam-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ══════════════════════════════════════
   Mobile Responsive
   ══════════════════════════════════════ */

@media (max-width: 768px) {
  .cam-fab {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  .cam-chat {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: cam-slide-up var(--duration-normal) var(--ease-out);
  }

  @keyframes cam-slide-up {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .cam-chat.closing {
    animation: cam-slide-down var(--duration-normal) var(--ease-out);
  }

  @keyframes cam-slide-down {
    from {
      transform: translateY(0);
    }
    to {
      transform: translateY(100%);
    }
  }

  .cam-message-bubble {
    max-width: 85%;
  }

  .cam-messages {
    padding: var(--space-4);
  }

  .cam-input-area {
    padding: var(--space-3) var(--space-4);
  }
}

/* ══════════════════════════════════════
   Tablet
   ══════════════════════════════════════ */

@media (max-width: 1024px) and (min-width: 769px) {
  .cam-chat {
    width: 360px;
    height: 550px;
  }
}

/* ══════════════════════════════════════
   Accessibility
   ══════════════════════════════════════ */

/* Focus visible styles */
.cam-fab:focus-visible,
.cam-send-btn:focus-visible,
.cam-quick-action:focus-visible,
.cam-context-action:focus-visible,
.cam-header .btn-icon:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}

.cam-input:focus-visible {
  outline: none;
  border-color: var(--color-amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .cam-fab,
  .cam-chat,
  .cam-message,
  .cam-quick-action,
  .cam-typing-dot {
    animation: none;
  }

  .cam-fab,
  .cam-send-btn,
  .cam-quick-action,
  .cam-context-action,
  .cam-input {
    transition: none;
  }
}

/* ══════════════════════════════════════
   Recall Style Cards
   ══════════════════════════════════════ */

.cam-recall-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.cam-recall-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  opacity: 0;
  animation: cam-card-fadein 280ms var(--ease-out) forwards;
  box-shadow: 0 1px 4px rgba(120, 80, 40, 0.10);
  transition: box-shadow var(--duration-fast), transform var(--duration-fast);
  text-align: left;
  width: 100%;
}

.cam-recall-card:nth-child(1) { animation-delay: 80ms; }
.cam-recall-card:nth-child(2) { animation-delay: 160ms; }
.cam-recall-card:nth-child(3) { animation-delay: 240ms; }

.cam-recall-card:hover {
  box-shadow: 0 3px 10px rgba(120, 80, 40, 0.18);
  transform: translateY(-1px);
}

.cam-recall-card-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.cam-recall-card-desc {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

@keyframes cam-card-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
