/* === LIBRARY ASSISTANT WIDGET — Navy/Gold, glass-morphism === */

/* ── FAB button ───────────────────────────────────────────── */
.la-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #1a2a4a 0%, #0d1b33 100%);
  color: #c9a84c;
  box-shadow: 0 4px 20px rgba(13, 27, 51, 0.7), 0 0 0 1px rgba(201, 168, 76, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.25s ease,
              background 0.25s ease;
  animation: la-entrance 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both;
}

.la-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(201, 168, 76, 0.25), 0 0 0 1px rgba(201, 168, 76, 0.4);
}

.la-fab:active { transform: scale(0.95); }

.la-fab svg { width: 24px; height: 24px; transition: transform 0.25s ease; }
.la-fab.open { background: linear-gradient(135deg, #0d1b33 0%, #050d1a 100%); }
.la-fab.open svg.icon-chat { display: none; }
.la-fab:not(.open) svg.icon-close { display: none; }

/* Gold pulse ring */
.la-fab::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(201, 168, 76, 0.35);
  animation: la-ping 2.5s ease-out infinite;
}
.la-fab.open::after { display: none; }

@keyframes la-ping {
  0% { transform: scale(1); opacity: 0.7; }
  80%, 100% { transform: scale(1.55); opacity: 0; }
}

@keyframes la-entrance {
  from { opacity: 0; transform: scale(0) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Chat panel ───────────────────────────────────────────── */
.la-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9998;
  width: 340px;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  background: rgba(8, 15, 30, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(201, 168, 76, 0.18);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(201, 168, 76, 0.06);
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.la-panel.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Header ───────────────────────────────────────────────── */
.la-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, rgba(13, 27, 51, 0.9) 0%, rgba(8, 15, 30, 0.8) 100%);
  border-bottom: 1px solid rgba(201, 168, 76, 0.12);
  flex-shrink: 0;
}

.la-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a2a4a, #0d1b33);
  border: 1px solid rgba(201, 168, 76, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.la-header-icon svg { width: 16px; height: 16px; color: #c9a84c; }

.la-header-text { flex: 1; min-width: 0; }
.la-header-text h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e8dfc0;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin: 0;
}
.la-header-text p {
  font-size: 0.68rem;
  color: rgba(201, 168, 76, 0.6);
  margin: 2px 0 0;
  line-height: 1;
}

.la-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}
.la-close-btn:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); }
.la-close-btn svg { width: 14px; height: 14px; }

/* ── Session counter badge ───────────────────────────────── */
.la-session-badge {
  font-size: 0.62rem;
  color: rgba(201, 168, 76, 0.5);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(201, 168, 76, 0.15);
  background: rgba(201, 168, 76, 0.05);
  white-space: nowrap;
  flex-shrink: 0;
}
.la-session-badge.low { color: rgba(239, 160, 80, 0.75); border-color: rgba(239, 160, 80, 0.2); }

/* ── Messages area ─────────────────────────────────────────── */
.la-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 76, 0.15) transparent;
}
.la-messages::-webkit-scrollbar { width: 4px; }
.la-messages::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.15);
  border-radius: 4px;
}

/* ── Message bubbles ──────────────────────────────────────── */
.la-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.55;
  animation: la-msg-in 0.18s ease;
}

@keyframes la-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.la-msg.user {
  background: linear-gradient(135deg, rgba(26, 42, 74, 0.9), rgba(13, 27, 51, 0.8));
  border: 1px solid rgba(201, 168, 76, 0.15);
  color: #e8dfc0;
  align-self: flex-end;
  border-radius: 10px 10px 2px 10px;
}

.la-msg.bot {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #d8d8d8;
  align-self: flex-start;
  border-radius: 2px 10px 10px 10px;
}

.la-msg.bot a {
  color: #c9a84c;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.la-msg.bot a:hover { color: #e8c870; }

.la-msg.bot strong { color: #e8dfc0; }

/* Streaming cursor */
.la-msg.bot.streaming .stream-cursor {
  display: inline-block;
  width: 2px;
  height: 0.85em;
  background: #c9a84c;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: la-blink 0.7s ease-in-out infinite;
}

@keyframes la-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* RUO tag inside bot messages */
.la-ruo-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: rgba(201, 168, 76, 0.45);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  text-transform: uppercase;
}

/* ── Suggested chips ──────────────────────────────────────── */
.la-chips {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.la-chip {
  font-size: 0.71rem;
  color: rgba(201, 168, 76, 0.8);
  background: rgba(201, 168, 76, 0.06);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 16px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.4;
}
.la-chip:hover {
  background: rgba(201, 168, 76, 0.12);
  border-color: rgba(201, 168, 76, 0.4);
  color: #e8c870;
}

/* ── Typing indicator ──────────────────────────────────────── */
.la-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 2px 10px 10px 10px;
  align-self: flex-start;
  max-width: 60px;
}
.la-typing span {
  width: 5px;
  height: 5px;
  background: rgba(201, 168, 76, 0.5);
  border-radius: 50%;
  animation: la-dot-bounce 1.2s ease-in-out infinite;
}
.la-typing span:nth-child(2) { animation-delay: 0.2s; }
.la-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes la-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Input area ──────────────────────────────────────────────── */
.la-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(201, 168, 76, 0.1);
  background: rgba(8, 15, 30, 0.6);
  flex-shrink: 0;
}

.la-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(201, 168, 76, 0.18);
  border-radius: 10px;
  color: #e8e8e8;
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 8px 12px;
  resize: none;
  max-height: 80px;
  outline: none;
  transition: border-color 0.15s;
}
.la-input::placeholder { color: rgba(255,255,255,0.25); }
.la-input:focus { border-color: rgba(201, 168, 76, 0.4); }

.la-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #1a2a4a, #0d1b33);
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: #c9a84c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}
.la-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #233560, #162448);
  border-color: rgba(201, 168, 76, 0.45);
}
.la-send-btn:disabled { opacity: 0.4; cursor: default; }
.la-send-btn svg { width: 16px; height: 16px; }

/* ── Footer disclaimer ──────────────────────────────────────── */
.la-footer {
  text-align: center;
  font-size: 0.62rem;
  color: rgba(255,255,255,0.18);
  padding: 0 12px 10px;
  flex-shrink: 0;
}

/* ── Mobile responsive ──────────────────────────────────────── */
@media (max-width: 480px) {
  .la-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 84px;
    max-height: calc(100dvh - 120px);
  }
  .la-fab {
    right: 16px;
    bottom: 16px;
  }
}
