/* =============================================================
   css/chatbot.css
   Blue Economy Virtual Assistant — styles
   Additive only. Does not override or redefine any selector used
   by the existing site stylesheet (style.css). All rules are
   scoped under the "beva-" (Blue Economy Virtual Assistant) prefix
   to avoid any collision with existing site CSS.
   Colors match the existing site palette:
     navy   #022a5e   saffron #ff9933   blue #0077b6   bg #f5f9ff
   ============================================================= */

#beva-root, #beva-root * {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

/* ---------- Floating button ---------- */
.beva-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #022a5e, #034078);
  border: 3px solid #ff9933;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99998;
  box-shadow: 0 6px 18px rgba(2, 42, 94, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.beva-fab:hover, .beva-fab:focus-visible {
  transform: scale(1.07);
  box-shadow: 0 8px 22px rgba(2, 42, 94, 0.45);
  outline: none;
}
.beva-fab:focus-visible {
  outline: 3px solid #ff9933;
  outline-offset: 3px;
}
.beva-fab svg { width: 28px; height: 28px; }

.beva-fab-pulse {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #ff9933;
  animation: beva-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes beva-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.55); opacity: 0; }
}

.beva-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff9933;
  color: #022a5e;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #ffffff;
}

/* ---------- Chat window ---------- */
.beva-window {
  position: fixed;
  right: 22px;
  bottom: 96px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(2, 42, 94, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  border: 1px solid #dfe9f5;
  transition: height 0.2s ease, opacity 0.15s ease, transform 0.15s ease;
}
.beva-window[hidden] { display: none; }
.beva-window.beva-minimized { height: 58px; }
.beva-window.beva-maximized {
  width: min(560px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 40px));
}

/* Header */
.beva-header {
  background: linear-gradient(120deg, #022a5e, #034078);
  color: #ffffff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 3px solid #ff9933;
}
.beva-header-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 16px;
}
.beva-header-logo img { width: 100%; height: 100%; object-fit: cover; }
.beva-header-text { flex: 1; min-width: 0; }
.beva-header-title {
  font-size: 13.5px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.beva-header-subtitle {
  font-size: 10.5px;
  color: #dce8f7;
  margin: 0;
  line-height: 1.3;
}
.beva-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.beva-icon-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.9;
}
.beva-icon-btn:hover { background: rgba(255,255,255,0.15); opacity: 1; }
.beva-icon-btn:focus-visible { outline: 2px solid #ff9933; outline-offset: 1px; }
.beva-icon-btn svg { width: 16px; height: 16px; }

/* Language toggle */
.beva-lang-toggle {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
}
.beva-lang-toggle:hover { background: rgba(255,255,255,0.28); }

/* Body / message list */
.beva-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f5f9ff;
}
.beva-window.beva-minimized .beva-body,
.beva-window.beva-minimized .beva-suggestions,
.beva-window.beva-minimized .beva-inputbar {
  display: none;
}

.beva-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.beva-messages:focus { outline: none; }

.beva-msg-row { display: flex; flex-direction: column; max-width: 86%; }
.beva-msg-row.beva-user { align-self: flex-end; align-items: flex-end; }
.beva-msg-row.beva-bot  { align-self: flex-start; align-items: flex-start; }

.beva-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.beva-user .beva-bubble {
  background: #ff9933;
  color: #022a5e;
  border-bottom-right-radius: 3px;
}
.beva-bot .beva-bubble {
  background: #ffffff;
  color: #022a5e;
  border: 1px solid #dfe9f5;
  border-bottom-left-radius: 3px;
}
.beva-bot .beva-bubble a {
  color: #0077b6;
  font-weight: 700;
  text-decoration: underline;
}

.beva-result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.beva-result-link {
  display: block;
  background: #f5f9ff;
  border: 1px solid #dfe9f5;
  border-left: 3px solid #0077b6;
  border-radius: 4px;
  padding: 6px 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: #0077b6 !important;
  text-decoration: none !important;
}
.beva-result-link:hover, .beva-result-link:focus-visible {
  background: #eaf3fc;
  outline: none;
}
.beva-result-meta {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #666;
  margin-top: 2px;
}

.beva-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 10px;
  color: #7d8ea3;
}
.beva-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #7d8ea3;
  font-size: 10px;
  padding: 1px 4px;
  text-decoration: underline;
}
.beva-copy-btn:hover { color: #0077b6; }

/* Typing indicator */
.beva-typing {
  display: inline-flex;
  gap: 4px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #dfe9f5;
  border-radius: 12px;
  border-bottom-left-radius: 3px;
  width: fit-content;
}
.beva-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #0077b6;
  animation: beva-blink 1.2s infinite ease-in-out;
}
.beva-typing span:nth-child(2) { animation-delay: 0.2s; }
.beva-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes beva-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Suggestions */
.beva-suggestions {
  padding: 8px 12px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid #dfe9f5;
  background: #ffffff;
  flex-shrink: 0;
}
.beva-chip {
  background: #f5f9ff;
  border: 1px solid #0077b6;
  color: #022a5e;
  border-radius: 14px;
  padding: 5px 11px;
  font-size: 11.5px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.beva-chip:hover, .beva-chip:focus-visible { background: #0077b6; color: #ffffff; outline: none; }

/* Input bar */
.beva-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #dfe9f5;
  background: #ffffff;
  flex-shrink: 0;
}
.beva-textarea {
  flex: 1;
  resize: none;
  max-height: 90px;
  min-height: 36px;
  border: 1px solid #c7d9ec;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
  font-family: inherit;
}
.beva-textarea:focus-visible { outline: 2px solid #0077b6; outline-offset: 1px; }

.beva-send-btn {
  background: #022a5e;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.beva-send-btn:hover { background: #034078; }
.beva-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.beva-send-btn:focus-visible { outline: 2px solid #ff9933; outline-offset: 2px; }
.beva-send-btn svg { width: 17px; height: 17px; }

/* Footer strip */
.beva-footer-strip {
  font-size: 9.5px;
  color: #94a3b8;
  text-align: center;
  padding: 4px 8px 6px;
  background: #ffffff;
  flex-shrink: 0;
}

/* Toolbar under header: clear / restart / download */
.beva-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  background: #eef5ff;
  border-bottom: 1px solid #dfe9f5;
  flex-shrink: 0;
}
.beva-toolbar-btn {
  background: none;
  border: 1px solid #c7d9ec;
  color: #022a5e;
  font-size: 10.5px;
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.beva-toolbar-btn:hover { background: #dfe9f5; }
.beva-toolbar-btn:focus-visible { outline: 2px solid #0077b6; }
.beva-window.beva-minimized .beva-toolbar { display: none; }

/* Screen-reader only utility (consistent with common a11y pattern; scoped locally) */
.beva-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Responsive: full-screen sheet on small/mobile viewports */
@media (max-width: 480px) {
  .beva-window {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    height: calc(100vh - 96px);
    max-height: none;
  }
  .beva-window.beva-maximized { width: auto; }
  .beva-fab { right: 14px; bottom: 14px; }
}

/* High-contrast / forced-colors compatibility */
@media (forced-colors: active) {
  .beva-fab, .beva-send-btn, .beva-chip, .beva-toolbar-btn { border: 1px solid CanvasText; }
  .beva-bubble { border: 1px solid CanvasText; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .beva-fab-pulse, .beva-typing span { animation: none; }
  .beva-fab, .beva-window { transition: none; }
}
