/**
 * Chatbot Assistant Styles
 * Warm Neon Cantina Theme - Floating chat assistant
 */

/* ============================================
   CHATBOT BACKDROP
   ============================================ */

.chatbot-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chatbot-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   FLOATING CHAT BUTTON - Latin Border Style
   ============================================ */

.chat-assistant-button {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + 20px);
  right: 20px;
  background: var(--color-chulas-orange);
  color: var(--color-chulas-black);
  width: 56px;
  height: 56px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 4px 24px var(--color-chulas-orange-glow),
    0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 900;
  border: 3px solid var(--color-chulas-black);
}

/* Inner decorative border */
.chat-assistant-button::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border: 2px solid var(--color-chulas-black);
  border-radius: 3px;
  pointer-events: none;
}

/* Corner accents */
.chat-assistant-button::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  pointer-events: none;
  background:
    /* Top left */
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) 0 8px / 10px 3px no-repeat,
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) 8px 0 / 3px 10px no-repeat,
    radial-gradient(circle, var(--color-chulas-black) 50%, transparent 50%) 0 0 / 6px 6px no-repeat,
    /* Top right */
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) calc(100%) 8px / 10px 3px no-repeat,
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) calc(100% - 8px) 0 / 3px 10px no-repeat,
    radial-gradient(circle, var(--color-chulas-black) 50%, transparent 50%) calc(100%) 0 / 6px 6px no-repeat,
    /* Bottom left */
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) 0 calc(100% - 8px) / 10px 3px no-repeat,
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) 8px calc(100%) / 3px 10px no-repeat,
    radial-gradient(circle, var(--color-chulas-black) 50%, transparent 50%) 0 calc(100%) / 6px 6px no-repeat,
    /* Bottom right */
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) calc(100%) calc(100% - 8px) / 10px 3px no-repeat,
    linear-gradient(var(--color-chulas-black), var(--color-chulas-black)) calc(100% - 8px) calc(100%) / 3px 10px no-repeat,
    radial-gradient(circle, var(--color-chulas-black) 50%, transparent 50%) calc(100%) calc(100%) / 6px 6px no-repeat;
}

.chat-assistant-button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 8px 32px var(--color-chulas-orange-glow),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

.chat-assistant-button:active {
  transform: translateY(-1px) scale(0.97);
}

.chat-assistant-button .chat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.chat-assistant-button .chat-icon svg {
  width: 26px;
  height: 26px;
  fill: var(--color-chulas-black);
}

@keyframes chatPulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.15); }
}

/* ============================================
   CHATBOT BUTTON COLOR VARIANTS
   Background changes color based on page theme
   ============================================ */

/* Lime theme (home) */
body.theme-lime .chat-assistant-button {
  background: var(--color-chulas-lime);
  box-shadow:
    0 4px 24px var(--color-chulas-lime-glow),
    0 8px 32px rgba(0, 0, 0, 0.3);
}

body.theme-lime .chat-assistant-button:hover {
  box-shadow:
    0 8px 32px var(--color-chulas-lime-glow),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Purple theme (rewards) */
body.theme-purple .chat-assistant-button {
  background: var(--color-chulas-purple);
  box-shadow:
    0 4px 24px var(--color-chulas-purple-glow),
    0 8px 32px rgba(0, 0, 0, 0.3);
}

body.theme-purple .chat-assistant-button:hover {
  box-shadow:
    0 8px 32px var(--color-chulas-purple-glow),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

body.theme-purple .chat-assistant-button .chat-icon svg {
  fill: var(--color-chulas-white);
}

/* Red theme (valet) */
body.theme-red .chat-assistant-button {
  background: var(--color-chulas-red);
  box-shadow:
    0 4px 24px var(--color-chulas-red-glow),
    0 8px 32px rgba(0, 0, 0, 0.3);
}

body.theme-red .chat-assistant-button:hover {
  box-shadow:
    0 8px 32px var(--color-chulas-red-glow),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

body.theme-red .chat-assistant-button .chat-icon svg {
  fill: var(--color-chulas-white);
}

/* Teal theme (events) */
body.theme-teal .chat-assistant-button {
  background: var(--color-chulas-teal);
  box-shadow:
    0 4px 24px var(--color-chulas-teal-glow),
    0 8px 32px rgba(0, 0, 0, 0.3);
}

body.theme-teal .chat-assistant-button:hover {
  box-shadow:
    0 8px 32px var(--color-chulas-teal-glow),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

body.theme-teal .chat-assistant-button .chat-icon svg {
  fill: var(--color-chulas-white);
}

/* ============================================
   CHAT CONTAINER COLOR VARIANTS
   Container and header change based on theme
   ============================================ */

/* Lime theme (home) */
body.theme-lime .chat-assistant-container {
  border-color: var(--color-chulas-lime);
  box-shadow:
    0 0 40px rgba(214, 222, 35, 0.25),
    0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.theme-lime .chat-assistant-container::before {
  border-color: var(--color-chulas-lime);
}

body.theme-lime .chat-assistant-header {
  background: var(--color-chulas-lime);
}

/* Purple theme (rewards) */
body.theme-purple .chat-assistant-container {
  border-color: var(--color-chulas-purple);
  box-shadow:
    0 0 40px rgba(112, 96, 169, 0.25),
    0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.theme-purple .chat-assistant-container::before {
  border-color: var(--color-chulas-purple);
}

body.theme-purple .chat-assistant-header {
  background: var(--color-chulas-purple);
  color: var(--color-chulas-white);
}

body.theme-purple .chat-assistant-header::after {
  color: var(--color-chulas-white);
}

/* Red theme (valet) */
body.theme-red .chat-assistant-container {
  border-color: var(--color-chulas-red);
  box-shadow:
    0 0 40px rgba(240, 89, 96, 0.25),
    0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.theme-red .chat-assistant-container::before {
  border-color: var(--color-chulas-red);
}

body.theme-red .chat-assistant-header {
  background: var(--color-chulas-red);
  color: var(--color-chulas-white);
}

body.theme-red .chat-assistant-header::after {
  color: var(--color-chulas-white);
}

/* Teal theme (events) */
body.theme-teal .chat-assistant-container {
  border-color: var(--color-chulas-teal);
  box-shadow:
    0 0 40px rgba(0, 178, 156, 0.25),
    0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.theme-teal .chat-assistant-container::before {
  border-color: var(--color-chulas-teal);
}

body.theme-teal .chat-assistant-header {
  background: var(--color-chulas-teal);
  color: var(--color-chulas-white);
}

body.theme-teal .chat-assistant-header::after {
  color: var(--color-chulas-white);
}

/* ============================================
   CHAT CONTAINER - Latin Border Cantina Style
   ============================================ */

.chat-assistant-container {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + 20px);
  right: 12px;
  width: min(440px, 85vw);
  max-width: 85vw;
  max-height: calc(93vh - var(--tab-bar-height) - 40px);
  background: var(--color-background);
  border-radius: 6px;
  box-shadow:
    0 0 40px rgba(248, 160, 84, 0.25),
    0 0 80px rgba(248, 160, 84, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
  border: 4px solid var(--color-chulas-orange);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-family: 'Atrament', var(--font-display), sans-serif;
}

/* Inner decorative border */
.chat-assistant-container::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border: 3px solid var(--color-chulas-orange);
  border-radius: 3px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* Corner accents with teal dots */
.chat-assistant-container::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  pointer-events: none;
  z-index: 10;
  background:
    /* Top left */
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) 0 16px / 20px 4px no-repeat,
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) 16px 0 / 4px 20px no-repeat,
    linear-gradient(45deg, transparent 30%, var(--color-chulas-orange) 30%, var(--color-chulas-orange) 70%, transparent 70%) 0 0 / 12px 12px no-repeat,
    radial-gradient(circle, var(--color-chulas-teal) 50%, transparent 50%) 14px 14px / 6px 6px no-repeat,
    /* Top right */
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) calc(100%) 16px / 20px 4px no-repeat,
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) calc(100% - 16px) 0 / 4px 20px no-repeat,
    linear-gradient(45deg, transparent 30%, var(--color-chulas-orange) 30%, var(--color-chulas-orange) 70%, transparent 70%) calc(100%) 0 / 12px 12px no-repeat,
    radial-gradient(circle, var(--color-chulas-teal) 50%, transparent 50%) calc(100% - 14px) 14px / 6px 6px no-repeat,
    /* Bottom left */
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) 0 calc(100% - 16px) / 20px 4px no-repeat,
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) 16px calc(100%) / 4px 20px no-repeat,
    linear-gradient(45deg, transparent 30%, var(--color-chulas-orange) 30%, var(--color-chulas-orange) 70%, transparent 70%) 0 calc(100%) / 12px 12px no-repeat,
    radial-gradient(circle, var(--color-chulas-teal) 50%, transparent 50%) 14px calc(100% - 14px) / 6px 6px no-repeat,
    /* Bottom right */
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) calc(100%) calc(100% - 16px) / 20px 4px no-repeat,
    linear-gradient(var(--color-chulas-orange), var(--color-chulas-orange)) calc(100% - 16px) calc(100%) / 4px 20px no-repeat,
    linear-gradient(45deg, transparent 30%, var(--color-chulas-orange) 30%, var(--color-chulas-orange) 70%, transparent 70%) calc(100%) calc(100%) / 12px 12px no-repeat,
    radial-gradient(circle, var(--color-chulas-teal) 50%, transparent 50%) calc(100% - 14px) calc(100% - 14px) / 6px 6px no-repeat;
}

/* Force Atrament on all chatbot text */
.chat-assistant-container,
.chat-assistant-container *,
.chat-assistant-container p,
.chat-assistant-container span,
.chat-assistant-container div,
.chat-assistant-container li,
.chat-assistant-container strong,
.chat-assistant-container em {
  font-family: 'Atrament', var(--font-display), sans-serif;
}

.chat-assistant-container.minimized {
  max-height: 56px;
  width: 180px;
  bottom: calc(var(--tab-bar-height) + 20px);
  right: 20px;
  overflow: hidden;
}

.chat-assistant-container.minimized .chat-assistant-header::after {
  display: none;
}

.chat-assistant-container.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

/* ============================================
   CHAT HEADER - Hector Banner
   ============================================ */

.chat-assistant-header {
  background: var(--color-chulas-orange);
  color: var(--color-chulas-black);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 2px 2px 0 0;
  position: relative;
  flex-shrink: 0;
  z-index: 5;
  border-bottom: 3px solid var(--color-chulas-black);
}

/* Inner decorative border for header */
.chat-assistant-header::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border: 2px solid rgba(26, 22, 23, 0.25);
  pointer-events: none;
}

.chat-assistant-header::after {
  content: '★';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--color-chulas-black);
  opacity: 0.5;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.chat-header-title .chat-icon {
  font-size: 18px;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 1;
}

/* Accented header buttons - default orange to match Hector's theme */
.chat-header-button {
  background: var(--color-chulas-orange);
  border: 2px solid var(--color-chulas-black);
  color: var(--color-chulas-black);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  transition: all 0.2s ease;
  font-family: var(--font-display);
  position: relative;
}

/* Mini inner border */
.chat-header-button::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border: 1px solid var(--color-chulas-black);
  border-radius: 2px;
  pointer-events: none;
}

.chat-header-button:hover {
  box-shadow: 0 2px 8px rgba(248, 160, 84, 0.5);
}

.chat-header-button:active {
  transform: scale(0.9);
}

/* Theme-aware header buttons */
body.theme-lime .chat-header-button {
  background: var(--color-chulas-orange);
}

body.theme-lime .chat-header-button:hover {
  box-shadow: 0 2px 8px rgba(248, 160, 84, 0.5);
}

body.theme-purple .chat-header-button {
  background: var(--color-chulas-orange);
}

body.theme-purple .chat-header-button:hover {
  box-shadow: 0 2px 8px rgba(248, 160, 84, 0.5);
}

body.theme-red .chat-header-button {
  background: var(--color-chulas-orange);
}

body.theme-red .chat-header-button:hover {
  box-shadow: 0 2px 8px rgba(248, 160, 84, 0.5);
}

body.theme-teal .chat-header-button {
  background: var(--color-chulas-orange);
}

body.theme-teal .chat-header-button:hover {
  box-shadow: 0 2px 8px rgba(248, 160, 84, 0.5);
}

/* ============================================
   CHAT MESSAGES AREA
   ============================================ */

.chat-assistant-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--color-background);
  min-height: 200px;
  /* Hide scrollbar but keep scroll functionality */
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  z-index: 5;
  /* Ensure children are constrained to this width */
  width: 100%;
  box-sizing: border-box;
}

/* Hide scrollbar */
.chat-assistant-messages::-webkit-scrollbar {
  display: none;
}

.chat-assistant-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(248, 160, 84, 0.6);
}

/* ============================================
   ERROR BANNER
   ============================================ */

.chat-error-banner {
  background: rgba(240, 89, 96, 0.15);
  color: var(--color-chulas-red);
  padding: 12px 14px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  border: 1px solid rgba(240, 89, 96, 0.3);
}

.retry-button {
  background: var(--color-chulas-red);
  color: var(--color-chulas-white);
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-display);
  transition: all 0.2s ease;
}

.retry-button:hover {
  background: #d84a51;
  transform: translateY(-1px);
}

/* ============================================
   CHAT MESSAGE BUBBLES
   ============================================ */

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
  /* Explicit width constraint for nested scroll containers */
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.chat-message.assistant {
  align-items: flex-start;
}

.message-role {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(250, 248, 245, 0.5);
  padding: 0 6px;
}

.message-content {
  padding: 14px 16px;
  border-radius: 14px;
  max-width: 100%;
  line-height: 1.5;
  font-size: 18px;
  font-family: var(--font-display);
  position: relative;
  overflow: visible !important;
  max-height: none !important;
}

/* User messages - solid orange */
.chat-message.user .message-content {
  background: var(--color-chulas-orange);
  color: var(--color-chulas-black);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border-bottom-right-radius: 4px;
}

/* Assistant messages - glass morphism */
.chat-message.assistant .message-content {
  background: rgba(45, 40, 42, 0.85);
  color: var(--color-text);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
  overflow: visible !important;
  max-height: none !important;
}

/* Error messages */
.chat-message.error .message-content {
  background: rgba(240, 89, 96, 0.15);
  color: var(--color-chulas-red);
  border: 1px solid rgba(240, 89, 96, 0.3);
}

/* Message content typography */
.message-content p {
  margin: 0;
  word-wrap: break-word;
}

.message-content p + p {
  margin-top: 8px;
}

.message-content code {
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  font-size: 15px;
}

.chat-message.user .message-content code {
  background: rgba(0, 0, 0, 0.15);
}

.message-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

.message-content strong {
  font-weight: 600;
  color: var(--color-chulas-lime);
}

.chat-message.user .message-content strong {
  color: var(--color-chulas-black);
}

.message-timestamp {
  display: none;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-chulas-orange);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   CHAT INPUT AREA
   ============================================ */

.chat-assistant-input {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-secondary-background);
  border-top: 3px solid var(--color-chulas-orange);
  border-radius: 0 0 2px 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.chat-assistant-input textarea {
  flex: 1;
  background: rgba(26, 22, 23, 0.8);
  border: 2px solid rgba(248, 160, 84, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 18px;
  font-family: var(--font-display);
  color: var(--color-text);
  resize: none;
  outline: none;
  transition: all 0.2s ease;
  max-height: 120px;
  min-height: 48px;
  line-height: 1.4;
}

.chat-assistant-input textarea::placeholder {
  color: rgba(250, 248, 245, 0.4);
}

.chat-assistant-input textarea:focus {
  border-color: var(--color-chulas-orange);
  background: rgba(248, 160, 84, 0.05);
  box-shadow:
    0 0 0 3px rgba(248, 160, 84, 0.15),
    0 0 20px rgba(248, 160, 84, 0.1);
}

.chat-assistant-input textarea:disabled {
  background: rgba(26, 22, 23, 0.5);
  color: rgba(250, 248, 245, 0.3);
  cursor: not-allowed;
}

/* Send button - Latin border style */
.chat-send-button {
  background: var(--color-chulas-orange);
  color: var(--color-chulas-black);
  border: 2px solid var(--color-chulas-black);
  width: 40px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(248, 160, 84, 0.3);
  position: relative;
}

/* Inner border */
.chat-send-button::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border: 1.5px solid var(--color-chulas-black);
  border-radius: 3px;
  pointer-events: none;
}

.chat-send-button svg {
  position: relative;
  z-index: 1;
}

.chat-send-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(248, 160, 84, 0.4);
}

.chat-send-button:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-send-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* Voice input button - Latin border style */
.chat-voice-button {
  background: transparent;
  border: 2px solid rgba(248, 160, 84, 0.3);
  color: rgba(250, 248, 245, 0.6);
  width: 40px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
}

.chat-voice-button:hover:not(:disabled) {
  background: rgba(248, 160, 84, 0.1);
  border-color: var(--color-chulas-orange);
  color: var(--color-chulas-orange);
}

.chat-voice-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Voice button active/listening state - VERY VISIBLE */
.chat-voice-button.listening {
  background: var(--color-chulas-red);
  border: 3px solid var(--color-chulas-white);
  color: var(--color-chulas-white);
  transform: scale(1.15);
  box-shadow:
    0 0 0 4px rgba(240, 89, 96, 0.4),
    0 0 20px rgba(240, 89, 96, 0.6),
    0 0 40px rgba(240, 89, 96, 0.3);
  animation: voicePulse 0.8s ease-in-out infinite;
}

.chat-voice-button.listening svg {
  animation: micBounce 0.6s ease-in-out infinite;
}

/* Recording indicator dot */
.chat-voice-button.listening::before {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: var(--color-chulas-lime);
  border: 2px solid var(--color-chulas-black);
  border-radius: 50%;
  animation: recordingDot 0.5s ease-in-out infinite alternate;
  z-index: 1;
}

/* Inner glow ring */
.chat-voice-button.listening::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  pointer-events: none;
}

@keyframes voicePulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(240, 89, 96, 0.4),
      0 0 20px rgba(240, 89, 96, 0.6),
      0 0 40px rgba(240, 89, 96, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(240, 89, 96, 0.3),
      0 0 30px rgba(240, 89, 96, 0.8),
      0 0 60px rgba(240, 89, 96, 0.4);
  }
}

@keyframes micBounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

@keyframes recordingDot {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.6;
    transform: scale(0.8);
  }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 480px) {
  .chat-assistant-container {
    width: calc(100vw - 24px);
    max-width: 440px;
    right: 12px;
    bottom: calc(var(--tab-bar-height) + 16px);
    max-height: calc(93vh - var(--tab-bar-height) - 40px);
  }

  .chat-assistant-button {
    right: 16px;
    bottom: calc(var(--tab-bar-height) + 16px);
  }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-assistant-button,
  .chat-assistant-container {
    bottom: calc(var(--tab-bar-height) + 20px + env(safe-area-inset-bottom));
  }

  @media (max-width: 480px) {
    .chat-assistant-button,
    .chat-assistant-container {
      bottom: calc(var(--tab-bar-height) + 16px + env(safe-area-inset-bottom));
    }
  }
}

/* ============================================
   WELCOME MESSAGE SPECIAL STYLING
   ============================================ */

.chat-message.assistant.welcome .message-content {
  background: rgba(248, 160, 84, 0.12);
  border: 1px solid rgba(248, 160, 84, 0.25);
}

/* ============================================
   MENU ITEMS DISPLAY - Horizontal Scroll
   ============================================ */

/* Menu items container with scroll hints */
.chat-menu-items-wrapper {
  position: relative;
  margin-top: 12px;
  margin-left: -16px;
  margin-right: -16px;
  /* Use viewport calc to ensure proper width constraint */
  width: min(calc(440px - 32px + 32px), calc(85vw - 32px + 32px));
  max-width: calc(100% + 32px);
  overflow: visible;
}

/* Menu items scroll horizontally */
.chat-menu-items {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 16px 8px 16px;
  padding-right: 44px;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
  /* Explicit max-width to force overflow */
  max-width: 100%;
  box-sizing: border-box;
}

.chat-menu-items::-webkit-scrollbar {
  display: none;
}

/* Scroll hint arrows for chat menu items */
.chat-menu-scroll-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-chulas-orange);
  border: 2px solid var(--color-chulas-black);
  border-radius: 50%;
  color: var(--color-chulas-black);
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chat-menu-scroll-hint-right {
  right: 4px;
  animation: chatScrollHintRight 1.5s ease-in-out infinite;
}

.chat-menu-scroll-hint-left {
  left: 4px;
  animation: chatScrollHintLeft 1.5s ease-in-out infinite;
}

@keyframes chatScrollHintRight {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(3px); }
}

@keyframes chatScrollHintLeft {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(-3px); }
}

.chat-menu-item {
  background: rgba(45, 40, 42, 0.9);
  border-radius: 12px;
  overflow: hidden;
  /* Force fixed width to create overflow */
  flex: 0 0 160px;
  width: 160px;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
}

.chat-menu-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-menu-item:active {
  transform: scale(0.98);
}

.chat-menu-item:hover .chat-menu-item-add-hint {
  opacity: 1;
}

/* Add hint overlay - on the image only */
.chat-menu-item-add-hint {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.85));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  border-radius: 12px 12px 0 0;
}

.chat-menu-item-add-hint span {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-chulas-orange);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-menu-item-image {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  background: rgba(26, 22, 23, 0.8);
  flex-shrink: 0;
}

.chat-menu-item-info {
  padding: 12px;
  flex-shrink: 0;
}

.chat-menu-item-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-chulas-white);
  margin-bottom: 6px;
  line-height: 1.3;
}

.chat-menu-item-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-chulas-lime);
}

/* ============================================
   QUANTITY SELECTOR OVERLAY
   ============================================ */

.chat-menu-item.has-selector .chat-menu-item-add-hint {
  display: none;
}

.chat-menu-item-selector {
  position: absolute;
  inset: 0;
  background: rgba(26, 22, 23, 0.97);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  animation: selectorFadeIn 0.2s ease;
  z-index: 10;
}

@keyframes selectorFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.selector-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-chulas-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}

.selector-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.selector-close:hover {
  color: var(--color-chulas-white);
}

.selector-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.selector-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--color-chulas-orange);
  background: transparent;
  color: var(--color-chulas-orange);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.selector-btn:hover {
  background: var(--color-chulas-orange);
  color: var(--color-chulas-black);
}

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

.selector-qty {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-chulas-white);
  min-width: 32px;
  text-align: center;
}

.selector-add-btn {
  width: 100%;
  background: var(--color-chulas-orange);
  color: var(--color-chulas-black);
  border: none;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.selector-add-btn:hover {
  background: #f9b05a;
  transform: translateY(-1px);
}

.selector-add-btn:active {
  transform: translateY(0);
}
