/* ================================================================
   advisor.css – ModVision AI Advisor chat panel
   ================================================================ */

/* ── Floating toggle button ──────────────────────────────────── */
.advisor-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--c-border-mid);
  background: var(--c-surface-2);
  color: var(--c-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.advisor-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6);
  background: var(--c-surface-3);
}
.advisor-toggle svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Chat panel ──────────────────────────────────────────────── */
.advisor-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9001;
  width: 370px;
  height: 520px;
  display: flex;
  flex-direction: column;
  background: var(--c-surface-1);
  border: 1px solid var(--c-border-mid);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;

  /* closed state */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.advisor-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ──────────────────────────────────────────────────── */
.advisor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.advisor-header__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text);
  flex: 1;
}
.advisor-header__btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.advisor-header__btn:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

/* ── Messages area ───────────────────────────────────────────── */
.advisor-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* thin dark scrollbar */
.advisor-messages::-webkit-scrollbar { width: 5px; }
.advisor-messages::-webkit-scrollbar-track { background: transparent; }
.advisor-messages::-webkit-scrollbar-thumb {
  background: var(--c-surface-4);
  border-radius: 4px;
}
.advisor-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.15);
}

/* ── Message bubbles ─────────────────────────────────────────── */
.advisor-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.advisor-msg--user {
  align-self: flex-end;
  background: #0066FF;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.advisor-msg--ai {
  align-self: flex-start;
  background: var(--c-surface-3);
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}
.advisor-msg--error {
  align-self: center;
  background: rgba(248, 113, 113, 0.12);
  color: var(--c-error);
  border: 1px solid rgba(248, 113, 113, 0.2);
  font-size: 12.5px;
  text-align: center;
}

/* bold text inside AI messages */
.advisor-msg--ai b,
.advisor-msg--ai strong {
  color: #fff;
  font-weight: 600;
}

/* ── Typing indicator ────────────────────────────────────────── */
.advisor-typing {
  align-self: flex-start;
  display: none;
  gap: 5px;
  padding: 12px 18px;
  background: var(--c-surface-3);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  order: 9999;  /* always last in flex */
}
.advisor-typing.visible { display: flex; }

.advisor-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-text-3);
  animation: advisorPulse 1.4s ease-in-out infinite;
}
.advisor-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.advisor-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes advisorPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30%           { opacity: 1;   transform: scale(1); }
}

/* ── Input bar ───────────────────────────────────────────────── */
.advisor-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
  flex-shrink: 0;
}
.advisor-input__field {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--c-border-mid);
  background: var(--c-surface-1);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}
.advisor-input__field::placeholder {
  color: var(--c-text-3);
}
.advisor-input__field:focus {
  border-color: rgba(255,255,255,0.2);
}
.advisor-input__send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: #0066FF;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.advisor-input__send:hover:not(:disabled) {
  background: #0055DD;
}
.advisor-input__send:active:not(:disabled) {
  transform: scale(0.95);
}
.advisor-input__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.advisor-input__send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .advisor-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 80px;
    height: 60vh;
  }
  .advisor-toggle {
    right: 12px;
    bottom: 16px;
  }
}
