/* ── Lens Companion ─────────────────────────────────────────────────── */

/* Floating bubble */
.companion-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #3b82f6;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: background 0.15s, transform 0.15s;
}

.companion-bubble:hover {
  background: #2563eb;
  transform: scale(1.05);
}

.companion-bubble--hidden {
  display: none;
}

/* Panel */
.companion-panel {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 380px;
  height: 60vh;
  min-height: 320px;
  max-height: 640px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.companion-panel--open {
  display: flex;
}

/* Hide panel when closed (override the flex from above) */
.companion-panel:not(.companion-panel--open) {
  display: none;
}

/* Header */
.companion-panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.companion-panel__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f5f9;
}

.companion-scope-chip {
  font-size: 0.72rem;
  background: #0f172a;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.companion-panel__close {
  margin-left: auto;
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}

.companion-panel__close:hover {
  color: #94a3b8;
}

/* Thread */
.companion-panel__thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.companion-empty {
  color: #475569;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 32px;
}

/* Messages */
.companion-message {
  display: flex;
  flex-direction: column;
}

.companion-message--user {
  align-items: flex-end;
}

.companion-message--agent {
  align-items: flex-start;
}

.companion-message__bubble {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.83rem;
  line-height: 1.5;
}

.companion-message__bubble p {
  margin: 0 0 6px;
}

.companion-message__bubble p:last-child {
  margin-bottom: 0;
}

.companion-message--user .companion-message__bubble {
  background: #3b82f6;
  color: #fff;
  border-bottom-right-radius: 2px;
}

.companion-message--agent .companion-message__bubble {
  background: #0f172a;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-bottom-left-radius: 2px;
}

/* Scope marker */
.companion-scope-marker {
  text-align: center;
  color: #475569;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.companion-scope-marker::before,
.companion-scope-marker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #334155;
}

/* Input row */
.companion-panel__input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #334155;
  flex-shrink: 0;
}

.companion-panel__input-row textarea {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 0.83rem;
  padding: 8px 10px;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
}

.companion-panel__input-row textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

.companion-panel__input-row textarea::placeholder {
  color: #475569;
}

.companion-panel__input-row input[type="submit"] {
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.83rem;
  padding: 0 14px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  align-self: flex-end;
}

.companion-panel__input-row input[type="submit"]:hover {
  background: #2563eb;
}

.companion-panel__input-row input[type="submit"]:disabled,
.companion-panel__input-row textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
