/* ==========================================================================
   Fritto Misto - AI Concierge & Order Assistant Widget Styles
   ========================================================================== */

/* Floating Launcher Button */
.fm-ai-launcher {
  position: fixed;
  bottom: 86px;
  right: 24px;
  z-index: 2100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #d4af37 0%, #bd924d 100%);
  color: #02131e;
  border: none;
  border-radius: var(--radius-pill, 9999px);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(189, 146, 77, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.fm-ai-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 36px rgba(212, 175, 55, 0.55), 0 6px 16px rgba(0, 0, 0, 0.4);
}

.fm-ai-launcher:active {
  transform: translateY(0) scale(0.98);
}

.fm-ai-launcher.active-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

.fm-ai-launcher-icon-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fm-ai-launcher-icon {
  width: 24px;
  height: 24px;
  display: block;
}

.fm-ai-online-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  background: #10b981;
  border: 2px solid #02131e;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: fm-pulse-green 2s infinite ease-in-out;
}

@keyframes fm-pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.fm-ai-launcher-text {
  white-space: nowrap;
}

/* Chat Window Container */
.fm-ai-window {
  position: fixed;
  bottom: 86px;
  right: 24px;
  width: 410px;
  height: min(540px, calc(100vh - 110px));
  background: rgba(2, 19, 30, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(189, 146, 77, 0.32);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(189, 146, 77, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 2200;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.fm-ai-window.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header */
.fm-ai-header {
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(6, 43, 71, 0.9) 0%, rgba(2, 19, 30, 0.9) 100%);
  border-bottom: 1px solid rgba(189, 146, 77, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fm-ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fm-ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #bd924d, #062b47);
  border: 1.5px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(189, 146, 77, 0.35);
}

.fm-ai-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.fm-ai-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.fm-ai-header-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.fm-ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

.fm-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fm-ai-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fm-ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Chat Messages Area */
.fm-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.fm-ai-messages::-webkit-scrollbar {
  width: 6px;
}
.fm-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(189, 146, 77, 0.25);
  border-radius: 3px;
}

/* Message Bubble */
.fm-msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: fm-msg-slide 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fm-msg-slide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fm-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.fm-msg.assistant {
  align-self: flex-start;
}

.fm-msg-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: normal;
  overflow-wrap: break-word;
}

.fm-msg.user .fm-msg-bubble {
  background: linear-gradient(135deg, #bd924d 0%, #9a7332 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.fm-msg.assistant .fm-msg-bubble {
  background: rgba(6, 43, 71, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border-bottom-left-radius: 4px;
}

/* Markdown styling inside AI bubble */
.fm-msg-bubble p {
  margin-bottom: 8px;
}
.fm-msg-bubble p:last-child {
  margin-bottom: 0;
}
.fm-msg-bubble strong {
  color: #fff;
  font-weight: 700;
}
.fm-msg-bubble ul, .fm-msg-bubble ol {
  margin: 6px 0 8px 18px;
}
.fm-msg-bubble li {
  margin-bottom: 4px;
}

/* Responsive Table Container & Anti-Letter-Break Styling */
.fm-table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
  border-radius: 10px;
  border: 1px solid rgba(189, 146, 77, 0.28);
  background: rgba(2, 19, 30, 0.85);
  scrollbar-width: thin;
}

.fm-table-responsive::-webkit-scrollbar {
  height: 5px;
}
.fm-table-responsive::-webkit-scrollbar-thumb {
  background: rgba(189, 146, 77, 0.35);
  border-radius: 3px;
}

.fm-msg-bubble table {
  width: 100%;
  min-width: 290px;
  border-collapse: collapse;
  margin: 0;
  font-size: 12px;
}

.fm-msg-bubble th,
.fm-msg-bubble td {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: normal;
  word-break: keep-all; /* Prevents breaking words letter-by-letter */
  overflow-wrap: normal;
  hyphens: none;
}

.fm-msg-bubble th {
  background: rgba(189, 146, 77, 0.22);
  color: var(--accent-gold-light);
  font-weight: 700;
  white-space: nowrap;
}

/* Price, Weight, Qty columns - never break lines or wrap */
.fm-msg-bubble td:nth-child(2),
.fm-msg-bubble td:nth-child(3),
.fm-msg-bubble td:nth-child(4),
.fm-msg-bubble th:nth-child(2),
.fm-msg-bubble th:nth-child(3),
.fm-msg-bubble th:nth-child(4) {
  white-space: nowrap !important;
  min-width: max-content;
  text-align: right;
}

/* Product Cards Container inside AI response */
.fm-ai-card-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.fm-ai-dish-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(2, 19, 30, 0.85);
  border: 1px solid rgba(189, 146, 77, 0.3);
  border-radius: 12px;
  padding: 8px;
  transition: transform 0.2s, border-color 0.2s;
}

.fm-ai-dish-card:hover {
  transform: translateX(2px);
  border-color: var(--accent-gold);
}

.fm-ai-dish-img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: #001f35;
  flex-shrink: 0;
}

.fm-ai-dish-details {
  flex: 1;
  min-width: 0;
}

.fm-ai-dish-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fm-ai-dish-meta {
  font-size: 12px;
  color: var(--accent-gold-hover);
  font-weight: 600;
  margin-top: 2px;
}

.fm-ai-add-btn {
  background: rgba(189, 146, 77, 0.15);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold-light);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.fm-ai-add-btn:hover {
  background: var(--accent-gold);
  color: #02131e;
}

/* Order Confirmation Card */
.fm-ai-order-card {
  margin-top: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 43, 71, 0.8) 100%);
  border: 1.5px solid #10b981;
  border-radius: 14px;
}

.fm-ai-order-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: #34d399;
  margin-bottom: 6px;
}

.fm-ai-order-body {
  font-size: 12.5px;
  color: #e2e8f0;
  line-height: 1.45;
}

/* Quick Prompts Chips Area */
.fm-ai-chips-wrap {
  padding: 6px 14px 10px 14px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.fm-ai-chips-wrap::-webkit-scrollbar {
  display: none;
}

.fm-ai-chip {
  background: rgba(6, 43, 71, 0.7);
  border: 1px solid rgba(189, 146, 77, 0.3);
  color: var(--accent-gold-light);
  padding: 6px 12px;
  border-radius: var(--radius-pill, 9999px);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.fm-ai-chip:hover {
  background: rgba(189, 146, 77, 0.25);
  border-color: var(--accent-gold);
  color: #fff;
  transform: translateY(-1px);
}

/* Typing indicator */
.fm-ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(6, 43, 71, 0.6);
  border-radius: 14px;
  align-self: flex-start;
}

.fm-ai-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-gold);
  border-radius: 50%;
  animation: fm-bounce 1.4s infinite ease-in-out both;
}
.fm-ai-dot:nth-child(1) { animation-delay: -0.32s; }
.fm-ai-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes fm-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Footer & Input Bar */
.fm-ai-footer {
  padding: 10px 14px 12px 14px;
  background: rgba(2, 19, 30, 0.98);
  border-top: 1px solid rgba(189, 146, 77, 0.18);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fm-ai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 43, 71, 0.85);
  border: 1px solid rgba(189, 146, 77, 0.3);
  border-radius: var(--radius-pill, 9999px);
  padding: 4px 6px 4px 16px;
  transition: border-color 0.2s;
}

.fm-ai-input-row:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(189, 146, 77, 0.25);
}

.fm-ai-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  min-width: 0;
}

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

.fm-ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4af37 0%, #bd924d 100%);
  border: none;
  color: #02131e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.fm-ai-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.6);
}

.fm-ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.fm-ai-footnote {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.2px;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .fm-ai-launcher {
    bottom: 74px;
    right: 14px;
    padding: 8px 14px;
    font-size: 13px;
  }
  .fm-ai-launcher-text {
    display: inline;
  }
  .fm-ai-window {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 86vh;
    max-height: 86vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
}
