/* ═══════════════════════════════════════════════════════
   Chat Widget — Chef AI Assistant  v5
   Modern UI · Glass-morphism · Micro-interactions
   ═══════════════════════════════════════════════════════ */

/* ── Reset & Base ── */
#chat-widget-bubble,
#chat-widget-window,
#chat-widget-window * {
  box-sizing: border-box;
}

/* ═══════════════════════════════════════
   BUBBLE BUTTON
   ═══════════════════════════════════════ */
#chat-widget-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff6b56, #E74C3C, #C0392B);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow:
    0 6px 24px rgba(231, 76, 60, 0.45),
    0 0 0 0 rgba(231, 76, 60, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.35s cubic-bezier(.4,0,.2,1), box-shadow 0.35s ease;
  font-size: 28px;
  animation: bubble-float 3s ease-in-out infinite;
}
#chat-widget-bubble:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow:
    0 8px 32px rgba(231, 76, 60, 0.55),
    0 0 0 8px rgba(231, 76, 60, 0.08);
}
#chat-widget-bubble:active {
  transform: scale(0.96);
}
@keyframes bubble-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
#chat-widget-bubble:hover {
  animation: none;
}
#chat-widget-bubble .chat-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: #22C55E;
  border-radius: 50%;
  border: 2.5px solid #1a1615;
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

/* ═══════════════════════════════════════
   CHAT WINDOW
   ═══════════════════════════════════════ */
#chat-widget-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #1c1917;
  border-radius: 24px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.06);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#chat-widget-window.open {
  display: flex;
  animation: chatWindowOpen 0.4s cubic-bezier(.22,.61,.36,1);
}
@keyframes chatWindowOpen {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */
.chat-header {
  background: linear-gradient(145deg, #ff6b56, #E74C3C, #C0392B);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Decorative subtle pattern on header */
.chat-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.chat-header-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.chat-header-status {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid #C0392B;
}
.chat-header-info {
  flex: 1;
  z-index: 1;
}
.chat-header-title {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.chat-header-subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-header-subtitle::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #86efac;
  display: inline-block;
  animation: subtle-pulse 2s ease infinite;
}
@keyframes subtle-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.chat-close-btn {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: background 0.25s, transform 0.2s;
  z-index: 1;
}
.chat-close-btn:hover {
  background: rgba(255,255,255,0.28);
  transform: rotate(90deg);
}

/* ═══════════════════════════════════════
   MESSAGES AREA
   ═══════════════════════════════════════ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #1c1917;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}

/* ═══════════════════════════════════════
   MESSAGE WRAPPERS
   ═══════════════════════════════════════ */
.chat-msg-wrapper {
  display: flex;
  flex-direction: column;
  animation: msgFadeIn 0.35s ease;
}
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg-wrapper.user {
  align-items: flex-end;
}
.chat-msg-wrapper.assistant {
  align-items: flex-start;
}

/* Assistant avatar row */
.chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 88%;
}
.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3d3530, #2a2420);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 2px;
}

/* ═══════════════════════════════════════
   MESSAGE BUBBLES
   ═══════════════════════════════════════ */
.chat-msg {
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  word-wrap: break-word;
  position: relative;
}
.chat-msg.assistant {
  background: linear-gradient(145deg, #2a2725, #252220);
  color: #f0ece9;
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(145deg, #ff6b56, #E74C3C, #d63b2f);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 3px 12px rgba(231,76,60,0.3);
  max-width: 85%;
}

/* ── Timestamp ── */
.chat-msg-time {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  margin-top: 4px;
  padding: 0 4px;
}
.chat-msg-wrapper.user .chat-msg-time {
  text-align: right;
}

/* ═══════════════════════════════════════
   FORMATTED CONTENT (assistant bubbles)
   ═══════════════════════════════════════ */
.chat-msg.assistant p {
  margin: 0 0 8px 0;
}
.chat-msg.assistant p:last-child {
  margin-bottom: 0;
}
.chat-msg.assistant ul {
  margin: 6px 0 10px 0;
  padding-left: 4px;
  list-style: none;
}
.chat-msg.assistant ul:last-child {
  margin-bottom: 0;
}
.chat-msg.assistant li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
  line-height: 1.55;
}
.chat-msg.assistant li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #E74C3C;
}
.chat-msg.assistant strong {
  color: #fff;
  font-weight: 700;
}
.chat-msg.assistant em {
  font-style: italic;
  color: #d4ccc8;
}
.chat-msg.assistant .chat-price {
  color: #fbbf24;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.1);
  padding: 1px 6px;
  border-radius: 6px;
}

/* ═══════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════ */
.chat-typing-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.chat-typing-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3d3530, #2a2420);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 2px;
}
.chat-typing {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: linear-gradient(145deg, #2a2725, #252220);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
}
.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8a7e7a;
  animation: typing-wave 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-wave {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ═══════════════════════════════════════
   QUICK SUGGESTIONS
   ═══════════════════════════════════════ */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 12px;
  background: #1c1917;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.chat-suggestion-btn {
  background: rgba(231, 76, 60, 0.08);
  border: 1px solid rgba(231, 76, 60, 0.2);
  color: #f0ece9;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  line-height: 1.3;
}
.chat-suggestion-btn:hover {
  background: linear-gradient(145deg, #E74C3C, #d63b2f);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(231,76,60,0.25);
}
.chat-suggestion-btn:active {
  transform: translateY(0);
}

/* ═══════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════ */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #1c1917;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: #262220;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 11px 18px;
  color: #f0ece9;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.45;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-input::placeholder {
  color: #7a7068;
}
.chat-input:focus {
  border-color: rgba(231, 76, 60, 0.5);
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}
.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff6b56, #E74C3C);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(.4,0,.2,1);
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(231,76,60,0.3);
}
.chat-send-btn:hover {
  background: linear-gradient(145deg, #E74C3C, #C0392B);
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(231,76,60,0.4);
}
.chat-send-btn:active {
  transform: scale(0.92);
}
.chat-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.chat-send-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════
   POWERED BY
   ═══════════════════════════════════════ */
.chat-powered {
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.15);
  padding: 6px 0;
  background: #1c1917;
  letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════
   FEEDBACK BUTTONS
   ═══════════════════════════════════════ */
.chat-feedback {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding-left: 42px; /* aligned with message (avatar gap) */
  opacity: 0;
  animation: feedbackFadeIn 0.4s 0.2s ease forwards;
}
@keyframes feedbackFadeIn {
  to { opacity: 1; }
}
.chat-feedback-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 3px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.25s ease;
  opacity: 0.5;
  color: inherit;
}
.chat-feedback-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.06);
  border-color: rgba(231,76,60,0.4);
  transform: scale(1.08);
}
.chat-feedback-sent {
  font-size: 11px;
  color: #8a7e7a;
  padding: 3px 8px;
  animation: feedbackFadeIn 0.3s ease;
}

/* ═══════════════════════════════════════
   STREAMING CURSOR
   ═══════════════════════════════════════ */
.chat-cursor {
  animation: blink-cursor 0.75s ease-in-out infinite;
  color: #E74C3C;
  font-weight: bold;
  margin-left: 1px;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.chat-msg.streaming {
  min-height: 20px;
}

/* ═══════════════════════════════════════
   DISH CARDS
   ═══════════════════════════════════════ */
.chat-dish-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0 2px 42px;
  animation: msgFadeIn 0.4s ease;
}
.chat-dish-card {
  background: linear-gradient(145deg, #2e2a28, #252120);
  border: 1px solid rgba(231, 76, 60, 0.12);
  border-radius: 14px;
  padding: 10px 14px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-dish-card:hover {
  border-color: rgba(231, 76, 60, 0.35);
  box-shadow: 0 2px 12px rgba(231, 76, 60, 0.1);
}
.chat-dish-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-dish-emoji {
  font-size: 20px;
  flex-shrink: 0;
}
.chat-dish-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #f0ece9;
  line-height: 1.3;
}
.chat-dish-price {
  font-size: 13px;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  padding: 2px 8px;
  border-radius: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}
.chat-dish-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.chat-dish-action {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #b8b0ab;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}
.chat-dish-action:hover {
  background: rgba(231, 76, 60, 0.12);
  border-color: rgba(231, 76, 60, 0.3);
  color: #f0ece9;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 480px) {
  #chat-widget-window {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  #chat-widget-window.open {
    animation: chatMobileOpen 0.3s ease;
  }
  @keyframes chatMobileOpen {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }
  #chat-widget-bubble {
    bottom: 20px;
    right: 20px;
    width: 58px;
    height: 58px;
    font-size: 26px;
  }
  .chat-header {
    padding: 18px 16px;
    border-radius: 0;
  }
  .chat-msg.user {
    max-width: 88%;
  }
  .chat-feedback {
    padding-left: 40px;
  }
  .chat-msg-row {
    max-width: 92%;
  }
  .chat-dish-cards {
    padding-left: 38px;
  }
}
