/* css/chat-assistant.css – AI Assistant chat widget styles */

/* ── Floating Action Button (FAB) ── */
.ai-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--gold);
  color: var(--gold);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s, border-color 0.28s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Slowly rotating glowing halo */
.ai-chat-trigger::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, rgba(217, 160, 54, 0) 50%, var(--gold) 100%);
  z-index: -1;
  animation: ai-spin-glow 8s linear infinite;
  opacity: 0.7;
  transition: opacity 0.28s, top 0.28s, left 0.28s, right 0.28s, bottom 0.28s;
}

.ai-chat-trigger i {
  font-size: 26px;
  transition: transform 0.28s ease;
  z-index: 2;
}

.ai-chat-trigger:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  border-color: var(--gold2);
}

.ai-chat-trigger:hover::before {
  opacity: 1;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
}

.ai-chat-trigger:hover i {
  transform: scale(1.05) rotate(5deg);
}

@keyframes ai-spin-glow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Pulsing Notification Badge */
.ai-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-base);
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* ── Collapsible Chat Panel ── */
.ai-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 360px;
  height: 500px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.ai-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Panel Header ── */
.ai-chat-header {
  padding: 14px 16px;
  background: rgba(17, 28, 48, 0.3);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(217, 160, 54, 0.15);
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

.ai-chat-avatar i {
  font-size: 18px;
}

.ai-chat-title-wrapper {
  display: flex;
  flex-direction: column;
}

.ai-chat-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--heading);
  letter-spacing: -0.2px;
}

.ai-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--green);
  font-weight: 500;
}

.ai-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--green);
  animation: ai-glow 1.5s ease-in-out infinite alternate;
}

@keyframes ai-glow {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

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

.ai-chat-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
}

.ai-chat-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ── Chat Messages Body ── */
.ai-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
}

/* Message Bubbles */
.ai-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: ai-fadeInUp 0.3s ease-out;
}

@keyframes ai-fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-msg.user {
  align-self: flex-end;
}

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

.ai-chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-chat-msg.user .ai-chat-msg-bubble {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark, #b8862e) 100%);
  color: #0d1b2a;
  font-weight: 500;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(217, 160, 54, 0.15);
}

.lm .ai-chat-msg.user .ai-chat-msg-bubble {
  color: #ffffff;
}

.ai-chat-msg.assistant .ai-chat-msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-bottom-left-radius: 2px;
}

.lm .ai-chat-msg.assistant .ai-chat-msg-bubble {
  background: rgba(0, 0, 0, 0.03);
}

.ai-chat-msg-bubble-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ai-chat-speak-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chat-speak-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(217, 160, 54, 0.08);
}

.ai-chat-speak-btn.speaking {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(217, 160, 54, 0.15);
  animation: ai-pulse-speak 1.5s infinite alternate;
}

@keyframes ai-pulse-speak {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

.ai-chat-msg-time {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  align-self: flex-end;
}

.ai-chat-msg.assistant .ai-chat-msg-time {
  align-self: flex-start;
}

/* Suggestion Chips */
.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px 16px;
  background: transparent;
}

.ai-chat-chip {
  padding: 6px 10px;
  border-radius: 20px;
  background: rgba(217, 160, 54, 0.08);
  border: 1px solid rgba(217, 160, 54, 0.2);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  font-family: var(--font);
}

.ai-chat-chip:hover {
  background: rgba(217, 160, 54, 0.18);
  border-color: var(--gold);
  color: var(--text-primary);
}

/* ── Panel Footer (Input Area) ── */
.ai-chat-footer {
  padding: 12px 16px;
  background: rgba(17, 28, 48, 0.2);
  border-top: 1.5px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-chat-input-wrapper {
  flex: 1;
  position: relative;
}

.ai-chat-input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.ai-chat-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(217, 160, 54, 0.12);
}

.ai-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--gold);
  border: none;
  color: #0d1b2a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
}

.ai-chat-send-btn i {
  font-size: 16px;
}

.ai-chat-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.ai-chat-send-btn:active:not(:disabled) {
  transform: translateY(0);
}

.ai-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Typing Animation ── */
.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 6px;
}

.ai-typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .ai-chat-panel {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
    bottom: 84px;
    height: 440px;
  }
}

/* ── Custom Scrollbars ── */
.ai-chat-body::-webkit-scrollbar,
.ai-chat-helper-body::-webkit-scrollbar {
  width: 5px;
}

.ai-chat-body::-webkit-scrollbar-track,
.ai-chat-helper-body::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-body::-webkit-scrollbar-thumb,
.ai-chat-helper-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.ai-chat-body::-webkit-scrollbar-thumb:hover,
.ai-chat-helper-body::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

.lm .ai-chat-body::-webkit-scrollbar-thumb,
.lm .ai-chat-helper-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}

/* ── Asking Helper Templates Panel ── */
.ai-chat-helper-panel {
  position: absolute;
  top: 61px;
  left: 0;
  right: 0;
  background: rgba(13, 23, 42, 0.96);
  border-bottom: 1.5px solid var(--border);
  z-index: 900;
  height: calc(100% - 61px);
  display: flex;
  flex-direction: column;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

.ai-chat-helper-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.ai-chat-helper-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
}

.ai-chat-helper-header span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gold);
  font-family: var(--heading);
}

.ai-chat-helper-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.ai-chat-helper-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.ai-chat-helper-body {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}

.ai-chat-helper-category {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-chat-helper-cat-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 2px;
}

.ai-chat-helper-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.ai-chat-helper-item:hover {
  background: rgba(217, 160, 54, 0.06);
  border-color: var(--gold);
  color: var(--text-primary);
  transform: translateX(4px);
}

/* Clickable suggestion links */
.ai-chat-suggested-query {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(217, 160, 54, 0.05);
  border: 1px solid rgba(217, 160, 54, 0.15);
  color: var(--gold);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font);
}

.ai-chat-suggested-query:hover {
  background: rgba(217, 160, 54, 0.12);
  border-color: var(--gold);
  transform: translateX(4px);
}

/* Light Theme overrides */
.lm.ai-chat-panel, .lm .ai-chat-panel {
  background: rgba(255, 255, 255, 0.94) !important;
  border-color: rgba(4, 30, 99, 0.15) !important;
  box-shadow: 0 10px 30px rgba(4, 30, 99, 0.1) !important;
}

.lm .ai-chat-header {
  background: rgba(4, 30, 99, 0.04) !important;
  border-bottom: 1.5px solid rgba(4, 30, 99, 0.1) !important;
}

.lm .ai-chat-title {
  color: #041E63 !important;
}

.lm .ai-chat-status {
  color: #2ecc71 !important;
}

.lm .ai-chat-avatar {
  background: rgba(228, 167, 14, 0.1) !important;
  border-color: #e4a70e !important;
  color: #e4a70e !important;
}

.lm .ai-chat-chip {
  background: rgba(4, 30, 99, 0.04) !important;
  border-color: rgba(4, 30, 99, 0.1) !important;
  color: #4f5d75 !important;
}

.lm .ai-chat-chip:hover {
  background: rgba(228, 167, 14, 0.1) !important;
  border-color: #e4a70e !important;
  color: #e4a70e !important;
}

.lm .ai-chat-msg.user .ai-chat-msg-bubble {
  background: linear-gradient(135deg, #e4a70e 0%, #b8862e 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(228, 167, 14, 0.15) !important;
}

.lm .ai-chat-msg.assistant .ai-chat-msg-bubble {
  background: #f4f6fc !important;
  border: 1px solid rgba(4, 30, 99, 0.08) !important;
  color: #333333 !important;
}

.lm .ai-chat-speak-btn {
  border-color: rgba(4, 30, 99, 0.1) !important;
  color: #6c757d !important;
}

.lm .ai-chat-speak-btn:hover {
  color: #e4a70e !important;
  border-color: #e4a70e !important;
  background: rgba(228, 167, 14, 0.06) !important;
}

.lm .ai-chat-speak-btn.speaking {
  color: #e4a70e !important;
  border-color: #e4a70e !important;
  background: rgba(228, 167, 14, 0.12) !important;
}

.lm .ai-chat-footer {
  background: rgba(4, 30, 99, 0.03) !important;
  border-top: 1.5px solid rgba(4, 30, 99, 0.1) !important;
}

.lm .ai-chat-input {
  background: #ffffff !important;
  border: 1.5px solid rgba(4, 30, 99, 0.15) !important;
  color: #333333 !important;
}

.lm .ai-chat-input:focus {
  border-color: #e4a70e !important;
  box-shadow: 0 0 0 3px rgba(228, 167, 14, 0.15) !important;
}

.lm .ai-chat-send-btn {
  background: #e4a70e !important;
  color: #ffffff !important;
}

.lm .ai-chat-suggested-query {
  background: rgba(228, 167, 14, 0.04);
  border-color: rgba(228, 167, 14, 0.2);
  color: #e4a70e;
}

.lm .ai-chat-suggested-query:hover {
  background: rgba(228, 167, 14, 0.08);
  border-color: #e4a70e;
}

.lm .ai-chat-helper-panel {
  background: rgba(255, 255, 255, 0.98);
  border-bottom-color: rgba(4, 30, 99, 0.1);
}

.lm .ai-chat-helper-header {
  background: rgba(4, 30, 99, 0.03);
  border-bottom-color: rgba(4, 30, 99, 0.08);
}

.lm .ai-chat-helper-header span {
  color: #e4a70e;
}

.lm .ai-chat-helper-item {
  background: #ffffff;
  border-color: rgba(4, 30, 99, 0.1);
  color: #4f5d75;
}

.lm .ai-chat-helper-item:hover {
  background: rgba(228, 167, 14, 0.06);
  border-color: #e4a70e;
  color: #e4a70e;
}
