/* lloyd.css — Lloyd AI analyst chat panel */

#lloyd-fab {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 9000;
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.125rem; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #fff; font: 600 0.9375rem Inter, system-ui, sans-serif;
  cursor: pointer; box-shadow: 0 6px 24px rgba(6, 182, 212, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#lloyd-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(6, 182, 212, 0.45); }
#lloyd-fab.lloyd-fab-open { display: none; }
.lloyd-fab-icon { font-size: 1.125rem; }

#lloyd-panel {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 9001;
  width: min(430px, calc(100vw - 2rem));
  height: min(640px, calc(100vh - 4rem));
  display: flex; flex-direction: column;
  background: var(--surface, #161b26);
  border: 1px solid var(--border, #2d3748);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
}
#lloyd-panel.hidden { display: none; }

.lloyd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border, #2d3748);
  background: var(--surface2, #1e2535);
}
.lloyd-title { display: flex; align-items: center; gap: 0.625rem; }
.lloyd-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.lloyd-name { font-weight: 700; font-size: 0.9375rem; color: var(--text, #f1f5f9); }
.lloyd-sub  { font-size: 0.6875rem; color: var(--text-dim, #64748b); }
.lloyd-header-actions { display: flex; gap: 0.375rem; }
.lloyd-hbtn {
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-sec, #94a3b8);
  font-size: 0.875rem; cursor: pointer;
}
.lloyd-hbtn:hover { background: var(--surface3, #273044); color: var(--text, #f1f5f9); }

.lloyd-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}

.lloyd-msg { max-width: 92%; font-size: 0.875rem; line-height: 1.55; }
.lloyd-msg-user {
  align-self: flex-end;
  background: #06b6d4; color: #04222a;
  padding: 0.625rem 0.875rem; border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap; word-wrap: break-word; font-weight: 500;
}
.lloyd-msg-lloyd {
  align-self: flex-start; width: 92%;
  background: var(--surface2, #1e2535); color: var(--text, #e2e8f0);
  padding: 0.75rem 0.9375rem; border-radius: 14px 14px 14px 4px;
}
.lloyd-msg-body p { margin: 0 0 0.5em; }
.lloyd-msg-body p:last-child { margin-bottom: 0; }
.lloyd-msg-body h3, .lloyd-msg-body h4, .lloyd-msg-body h5, .lloyd-msg-body h6 {
  margin: 0.75em 0 0.375em; color: var(--text, #f1f5f9); font-size: 0.9375rem;
}
.lloyd-msg-body ul, .lloyd-msg-body ol { margin: 0.375em 0 0.625em; padding-left: 1.25em; }
.lloyd-msg-body li { margin: 0.2em 0; }
.lloyd-msg-body code {
  background: rgba(6, 182, 212, 0.12); color: #67e8f9;
  padding: 0.1em 0.35em; border-radius: 4px;
  font: 0.8125em 'JetBrains Mono', monospace;
}
.lloyd-msg-body pre {
  background: #0f1117; border: 1px solid var(--border, #2d3748);
  border-radius: 8px; padding: 0.625rem; overflow-x: auto; margin: 0.5em 0;
}
.lloyd-msg-body pre code { background: none; padding: 0; color: #cbd5e1; }
.lloyd-msg-body a { color: #22d3ee; }
/* Tables shrink and wrap to fit the panel width — no sideways scrolling. */
.lloyd-table-wrap { margin: 0.5em 0; max-width: 100%; }
.lloyd-table-wrap table {
  border-collapse: collapse; width: 100%; table-layout: auto;
  font-size: 0.6875rem; line-height: 1.35;
}
.lloyd-table-wrap th, .lloyd-table-wrap td {
  border: 1px solid var(--border, #2d3748); padding: 0.25rem 0.375rem; text-align: left;
  white-space: normal; overflow-wrap: anywhere; vertical-align: top;
}
.lloyd-table-wrap th { background: var(--surface3, #273044); color: var(--text, #f1f5f9); }

.lloyd-toolnote {
  font-size: 0.6875rem; color: var(--text-dim, #64748b);
  margin-bottom: 0.375rem; font-family: 'JetBrains Mono', monospace;
}
.lloyd-error {
  margin-top: 0.5rem; font-size: 0.8125rem; color: #f87171;
  background: rgba(248, 113, 113, 0.08); border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 8px; padding: 0.5rem 0.625rem;
}

.lloyd-empty { text-align: center; padding: 2rem 1rem 1rem; }
.lloyd-empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.lloyd-empty-title { font-weight: 700; font-size: 1.0625rem; color: var(--text, #f1f5f9); margin-bottom: 0.375rem; }
.lloyd-empty-sub { font-size: 0.8125rem; color: var(--text-sec, #94a3b8); margin-bottom: 1.25rem; line-height: 1.5; }
.lloyd-suggestions { display: flex; flex-direction: column; gap: 0.5rem; }
.lloyd-sug {
  background: var(--surface2, #1e2535); border: 1px solid var(--border, #2d3748);
  color: var(--text-sec, #cbd5e1); border-radius: 10px; padding: 0.5625rem 0.75rem;
  font-size: 0.8125rem; text-align: left; cursor: pointer;
  font-family: inherit;
}
.lloyd-sug:hover { border-color: #06b6d4; color: var(--text, #f1f5f9); }

.lloyd-status {
  min-height: 0; padding: 0 1rem; font-size: 0.75rem; color: #22d3ee;
  transition: min-height 0.15s ease;
}
.lloyd-status.active { min-height: 1.375rem; padding-bottom: 0.25rem; }
.lloyd-status.active::before {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; background: #22d3ee; animation: lloyd-pulse 1.1s ease infinite;
  vertical-align: 1px;
}
@keyframes lloyd-pulse { 50% { opacity: 0.25; } }

.lloyd-inputbar {
  display: flex; align-items: flex-end; gap: 0.5rem;
  padding: 0.75rem; border-top: 1px solid var(--border, #2d3748);
  background: var(--surface2, #1e2535);
}
#lloyd-input {
  flex: 1; resize: none; border: 1px solid var(--border, #2d3748);
  background: var(--surface, #161b26); color: var(--text, #f1f5f9);
  border-radius: 10px; padding: 0.5625rem 0.75rem; font: 0.875rem Inter, system-ui, sans-serif;
  outline: none; max-height: 120px;
}
#lloyd-input:focus { border-color: #06b6d4; }
#lloyd-send {
  width: 38px; height: 38px; border: none; border-radius: 10px;
  background: #06b6d4; color: #fff; font-size: 0.9375rem; cursor: pointer; flex-shrink: 0;
}
#lloyd-send:disabled { opacity: 0.45; cursor: default; }

@media (max-width: 640px) {
  /* Bottom SHEET, not a giant full-screen takeover (Joey 7/13 — it was pulling
     up massive/unusable). Anchored to the bottom, ~84% of the visible height
     (100dvh so iOS Safari's toolbar doesn't crop it), rounded top, with a
     sliver of the app still showing above so it reads as a modal sheet. Input
     clears the home indicator. */
  #lloyd-fab { bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
  #lloyd-panel {
    /* Anchor by left/right (NOT width:100vw — that can exceed the visual
       viewport and cut off the right edge). Contained ~68% sheet, not a
       fullscreen takeover. */
    top: auto !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: auto !important; max-width: none !important;
    height: 68vh !important; height: 68dvh !important; max-height: 68dvh !important;
    box-sizing: border-box; overflow: hidden;
    border-radius: 18px 18px 0 0; border: none;
    border-top: 1px solid var(--border, #2d3748);
  }
  .lloyd-inputbar { padding-bottom: calc(0.75rem + env(safe-area-inset-bottom)); }
  /* iOS auto-zooms the whole page when a focused input's font is < 16px —
     that's the "everything huge and cut off at the right" bug (Joey 7/21).
     16px on mobile keeps focus zoom-free; desktop stays 14px. */
  #lloyd-input { font-size: 16px; }
}
