/* ============================================================
   ANALYSIS PAGE — image upload panel + chat panel
   ============================================================ */

/* ── Two-panel layout ───────────────────────────────────────── */
.panels {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Left: Image upload panel ───────────────────────────────── */
.img-panel {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}

.panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-label svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ── Drop Zone ──────────────────────────────────────────────── */
.drop-zone {
  flex: 1;
  min-height: 260px;
  border: 2px dashed #cbd5e1;
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ease);
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 20px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--teal);
  background: var(--teal-bg);
}

.drop-zone.drag-over { transform: scale(1.01); }

.dz-icon {
  width: 52px;
  height: 52px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.dz-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--teal);
  fill: none;
  stroke-width: 2;
}

.dz-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.dz-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.dz-browse {
  padding: 7px 18px;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ease);
}

.dz-browse:hover { background: var(--teal-dark); }

/* ── Preview image (overlays the drop zone) ─────────────────── */
#img-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--r) - 2px);
  display: none;
}

.dz-change-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--r) - 2px);
}

.drop-zone:hover .dz-change-overlay.visible { display: flex; }

.dz-change-overlay span {
  color: white;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0,0,0,.5);
  padding: 7px 16px;
  border-radius: 20px;
}

/* ── File Info Badge ────────────────────────────────────────── */
.file-badge {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.file-badge.show { display: flex; }

.file-badge-icon {
  width: 18px;
  height: 18px;
  stroke: var(--teal);
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
}

.file-badge-info { flex: 1; min-width: 0; }

.file-badge-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-badge-size {
  font-size: 11px;
  color: var(--ink-soft);
}

/* ── Right: Chat panel ──────────────────────────────────────── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-2);
}

/* ── Chat header ────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-avatar svg { width: 20px; height: 20px; fill: white; }

.chat-header-info h3 { font-size: 14px; font-weight: 700; color: var(--ink); }
.chat-header-info p  { font-size: 11px; color: var(--green); font-weight: 500; }

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

/* ── Empty / welcome state ──────────────────────────────────── */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  text-align: center;
  color: var(--ink-soft);
}

.chat-empty svg {
  width: 52px;
  height: 52px;
  opacity: .18;
  fill: var(--ink);
}

.chat-empty h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.chat-empty p {
  font-size: 13px;
  max-width: 240px;
  line-height: 1.6;
}

/* ── Suggestion chips ───────────────────────────────────────── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin-top: 8px;
}

.chip {
  padding: 6px 13px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: var(--ease);
}

.chip:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-bg);
}

/* ── Message rows ───────────────────────────────────────────── */
.msg-row {
  display: flex;
  gap: 8px;
  animation: msg-in .2s ease;
}

.msg-row.user { flex-direction: row-reverse; }

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

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-avatar.ai { background: var(--teal); }
.msg-avatar.ai svg { width: 16px; height: 16px; fill: white; }
.msg-avatar.user { background: var(--ink-mid); color: white; font-size: 12px; font-weight: 700; }

.msg-body { display: flex; flex-direction: column; }
.msg-row.user .msg-body { align-items: flex-end; }

.bubble {
  max-width: 340px;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.bubble.ai {
  background: var(--surface);
  color: var(--ink);
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow);
}

.bubble.user {
  background: var(--teal);
  color: white;
  border-radius: 16px 4px 16px 16px;
}

.msg-time {
  font-size: 10px;
  color: var(--ink-soft);
  margin-top: 3px;
  padding: 0 3px;
}

/* ── Typing indicator ───────────────────────────────────────── */
.typing-row {
  display: flex;
  gap: 8px;
  animation: msg-in .2s ease;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: td-bounce 1.2s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }

@keyframes td-bounce {
  0%,60%,100% { transform: translateY(0);   opacity: .35; }
  30%          { transform: translateY(-5px); opacity: 1;   }
}

/* ── Chat input bar ─────────────────────────────────────────── */
.chat-input-bar {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 28px;
  padding: 7px 7px 7px 18px;
  transition: var(--ease);
}

.input-row:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,.10);
}

#chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}

#chat-input::placeholder { color: var(--ink-soft); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ease);
  flex-shrink: 0;
}

.send-btn:hover { background: var(--teal-dark); transform: scale(1.06); }
.send-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }
.send-btn svg { width: 15px; height: 15px; fill: white; }

.input-hint {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 8px;
}

/* ── Detection Report Card ──────────────────────────────────── */
.bubble-report {
  padding: 0;
  overflow: hidden;
  max-width: 420px;
  background: var(--surface);
}

.detection-report {
  display: flex;
  flex-direction: column;
}

.report-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--teal-bg);
  border-bottom: 1px solid var(--border);
}

.report-title svg {
  width: 15px;
  height: 15px;
  fill: var(--teal);
  flex-shrink: 0;
}

.report-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bbox-hint {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-size: 10px;
  color: var(--ink-soft);
  opacity: .7;
}

/* confidence row */
.det-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.det-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  width: 110px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}

.conf-bar-wrap {
  flex: 1;
  height: 7px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.conf-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .5s ease;
}

.conf-bar.organ        { background: var(--teal); }
.conf-bar.finding-high { background: #ef4444; }
.conf-bar.finding-mid  { background: #f59e0b; }
.conf-bar.finding-low  { background: #22c55e; }

.conf-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-mid);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* annotated image */
.report-img-wrap {
  border-bottom: 1px solid var(--border);
}

.report-img-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ink-soft);
  padding: 10px 16px 6px;
}

.report-img-wrap img {
  width: 100%;
  display: block;
  max-height: 300px;
  object-fit: contain;
  background: #000;
}

/* no abnormalities indicator */
.report-no-findings {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #16a34a;
}

.report-no-findings svg {
  width: 16px;
  height: 16px;
  stroke: #16a34a;
  fill: none;
  stroke-width: 2.5;
  flex-shrink: 0;
}

/* summary footer */
.report-summary {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.report-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .panels { flex-direction: column; }

  .img-panel {
    width: 100%;
    max-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .drop-zone { min-height: 160px; }
}

@media (max-width: 480px) {
  .bubble { max-width: 240px; }
  .chip-row { gap: 5px; }
}
