/* ===== AI Concierge — Floating Tab ===== */
.ai-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9998;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: linear-gradient(180deg, #2563eb, #6366f1);
  color: white;
  border: none;
  border-radius: 12px 0 0 12px;
  padding: 18px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.1em;
  box-shadow: -4px 4px 20px rgba(37,99,235,0.3);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1), box-shadow 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-tab:hover {
  transform: translateY(-50%) translateX(-4px);
  box-shadow: -8px 4px 32px rgba(37,99,235,0.45);
}
.ai-tab .ai-tab-icon {
  font-size: 1.2rem;
  writing-mode: horizontal-tb;
  text-orientation: initial;
}
.ai-tab.hidden { display: none; }

/* Overlay backdrop */
.ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 9998;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s;
}
.ai-overlay.open {
  display: block;
  opacity: 1;
}

/* Panel */
.ai-panel {
  position: fixed;
  right: -420px;
  top: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  z-index: 9999;
  background: #fff;
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  transition: right 0.4s cubic-bezier(0.16,1,0.3,1);
}
.ai-panel.open {
  right: 0;
}

/* Panel Header */
.ai-panel-header {
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}
.ai-panel-title .ai-logo {
  font-size: 1.4rem;
}
.ai-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.ai-close-btn:hover {
  background: rgba(255,255,255,0.3);
}

/* Context Badge */
.ai-context-badge {
  background: #eff6ff;
  border-bottom: 1px solid #dbeafe;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #2563eb;
  font-weight: 500;
  flex-shrink: 0;
}
.ai-context-badge svg {
  width: 14px; height: 14px; flex-shrink: 0;
}

/* Chat Messages */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.7;
  word-break: break-word;
}
.ai-msg.bot {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.ai-msg.user {
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.ai-msg.bot .msg-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}
.ai-msg.user .msg-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  margin-bottom: 4px;
  text-align: right;
}
.ai-msg .msg-text p { margin: 4px 0; }
.ai-msg .msg-text ul,
.ai-msg .msg-text ol { margin: 4px 0; padding-left: 20px; }
.ai-msg .msg-text strong { font-weight: 700; }

/* Typing indicator */
.ai-typing {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  align-self: flex-start;
}
.ai-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: aiTypingBounce 1.4s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTypingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions */
.ai-quick-actions {
  padding: 8px 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.ai-quick-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: #2563eb;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  font-family: inherit;
}
.ai-quick-btn:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

/* Input Area */
.ai-input-area {
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.ai-input {
  flex: 1;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}
.ai-input:focus {
  border-color: #3b82f6;
}
.ai-send-btn {
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: white;
  border: none;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.ai-send-btn:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}
.ai-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ai-send-btn svg {
  width: 18px; height: 18px;
}

/* Powered by */
.ai-powered {
  text-align: center;
  font-size: 0.68rem;
  color: #94a3b8;
  padding: 6px 20px 10px;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 768px) {
  .ai-panel {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }
  .ai-tab {
    top: auto;
    bottom: 20px;
    right: 12px;
    transform: none;
    writing-mode: horizontal-tb;
    text-orientation: initial;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 0;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,0.35);
  }
  .ai-tab .ai-tab-icon {
    font-size: 1.2rem;
    writing-mode: horizontal-tb;
  }
  .ai-tab span:not(.ai-tab-icon) {
    display: none;
  }
  .ai-tab:hover {
    transform: scale(1.05);
  }
}
