/* ── Component: Image/video/file attachments and document cards in chat ──
 * Class prefix: sv- (sv-attach-, sv-user-image, sv-doc-card, etc.)
 */

/* ── Multimodal Chat: Attachments, Document Cards, Call, Typing ────────────── */

/* ── Attach Button ─────────────────────────────────────────────────────────── */
.sv-attach-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.sv-attach-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
}
.sv-attach-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Attachment Preview Strip (above input bar) ────────────────────────────── */
.sv-attach-strip {
  display: none;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  flex-wrap: nowrap;
  align-items: center;
}
.sv-attach-strip.has-files {
  display: flex;
}

.sv-attach-preview {
  position: relative;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  overflow: visible; /* Allow remove button to overflow */
}
.sv-attach-preview--image {
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 8px;
}
.sv-attach-preview--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}
.sv-attach-preview--file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  max-width: 160px;
}
.sv-attach-preview--file .sv-file-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.sv-attach-preview--file .sv-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-attach-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.3);
  background: rgba(255, 60, 60, 0.9);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  transition: transform 0.1s;
}
.sv-attach-remove:hover {
  transform: scale(1.15);
}

/* ── User Images in Chat ───────────────────────────────────────────────────── */
.sv-user-image-row {
  display: flex;
  justify-content: flex-end;
  padding: 2px 16px;
}
.sv-user-image {
  max-width: 260px;
  max-height: 220px;
  border-radius: 12px;
  object-fit: contain;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  transition: opacity 0.2s;
}
.sv-user-image:hover {
  opacity: 0.9;
}

/* ── User File Chip in Chat ────────────────────────────────────────────────── */
.sv-user-file-row {
  display: flex;
  justify-content: flex-end;
  padding: 2px 16px;
}
.sv-user-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  max-width: 200px;
}
.sv-user-file-chip .sv-file-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.sv-user-file-chip .sv-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Document Download Card (in chat) ──────────────────────────────────────── */
.sv-doc-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 320px;
  margin-top: 8px;
}
.sv-doc-card-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}
.sv-doc-card-info {
  flex: 1;
  min-width: 0;
}
.sv-doc-card-title {
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sv-doc-card-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}
.sv-doc-card-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(99, 179, 237, 0.15);
  color: #63b3ed;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}
.sv-doc-card-download:hover {
  background: rgba(99, 179, 237, 0.25);
}

/* ── Workflow Card (in chat) ────────────────────────────────────────────────── */
.sv-workflow-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 320px;
  margin-top: 8px;
}
.sv-workflow-card-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}
.sv-workflow-card-info {
  flex: 1;
  min-width: 0;
}
.sv-workflow-card-title {
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sv-workflow-card-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}
.sv-workflow-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.sv-workflow-card-btn:hover {
  background: rgba(167, 139, 250, 0.25);
}

/* ── Call Button ───────────────────────────────────────────────────────────── */
.sv-call-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(72, 187, 120, 0.15);
  color: #48bb78;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.sv-call-btn:hover:not(:disabled) {
  background: rgba(72, 187, 120, 0.25);
  color: #68d391;
  transform: scale(1.05);
}
.sv-call-btn:disabled {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
  cursor: not-allowed;
}
.sv-call-btn svg {
  width: 17px;
  height: 17px;
}

/* Active call state — red with pulse */
.sv-call-btn--active {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  animation: call-pulse 1.5s ease-in-out infinite;
}
.sv-call-btn--active:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #fc8181;
}

@keyframes call-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ── Chain-of-Thought Progress UI ──────────────────────────────────────────── */
.sv-cot-row {
  transition: opacity 0.35s ease-out;
}
.sv-cot-row--done {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}
.sv-cot-bubble {
  padding: 10px 16px !important;
  min-height: auto !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}
.sv-cot-steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
}

/* ── Individual step ────────────────────────────────────────────────────────── */
.sv-cot-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  animation: cot-step-enter 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: left center;
}
@keyframes cot-step-enter {
  from {
    opacity: 0;
    transform: translateX(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.sv-cot-icon {
  font-size: 14px;
  line-height: 1;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sv-cot-label {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.8);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Spinner (active step) ──────────────────────────────────────────────────── */
.sv-cot-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: cot-spin 0.8s linear infinite;
  flex-shrink: 0;
  display: none;
}
.sv-cot-step--active .sv-cot-spinner {
  display: block;
}
.sv-cot-step--active .sv-cot-label {
  color: rgba(255, 255, 255, 0.95);
}
@keyframes cot-spin {
  to { transform: rotate(360deg); }
}

/* ── Completed step — checkmark replaces spinner ────────────────────────────── */
.sv-cot-step--done .sv-cot-spinner {
  display: block;
  border: none;
  animation: none;
  width: auto;
  height: auto;
  font-size: 13px;
  line-height: 1;
  color: rgba(100, 220, 140, 0.85);
}
.sv-cot-step--done .sv-cot-spinner::after {
  content: '\2713'; /* checkmark */
}
.sv-cot-step--done .sv-cot-label {
  color: rgba(255, 255, 255, 0.4);
}
.sv-cot-step--done .sv-cot-icon {
  opacity: 0.5;
}

/* ── Pulse glow on the active step icon ─────────────────────────────────────── */
.sv-cot-step--active .sv-cot-icon {
  animation: cot-icon-pulse 2s ease-in-out infinite;
}
@keyframes cot-icon-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

/* ── History attachment indicators ─────────────────────────────────────────── */
.sv-history-attachments {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.sv-history-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  /* Workflow cards — fluid width */
  .sv-workflow-card {
    max-width: min(90vw, 320px);
    padding: 10px 12px;
    gap: 10px;
  }
  .sv-workflow-card-icon {
    font-size: 24px;
  }
  .sv-workflow-card-title {
    font-size: 12.5px;
  }
  .sv-workflow-card-btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Attach button — 44px touch target */
  .sv-attach-btn {
    width: 44px;
    height: 44px;
  }
  .sv-attach-btn svg {
    width: 20px;
    height: 20px;
  }

  /* Attachment strip — tighter on mobile */
  .sv-attach-strip {
    padding: 6px 10px;
    gap: 6px;
  }

  /* User images — fluid width */
  .sv-user-image {
    max-width: min(85vw, 260px);
    max-height: 200px;
  }
  .sv-user-image-row {
    padding: 2px 10px;
  }

  /* User file chips */
  .sv-user-file-row {
    padding: 2px 10px;
  }
  .sv-user-file-chip {
    max-width: min(85vw, 200px);
    padding: 8px 12px;
    font-size: 12px;
  }

  /* Doc download cards — fluid width */
  .sv-doc-card {
    max-width: min(90vw, 320px);
    padding: 10px 12px;
    gap: 10px;
  }
  .sv-doc-card-icon {
    font-size: 24px;
  }
  .sv-doc-card-title {
    font-size: 12.5px;
  }
  .sv-doc-card-download {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Call button — 44px touch target */
  .sv-call-btn {
    width: 44px;
    height: 44px;
  }
  .sv-call-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Chain-of-thought — prevent horizontal scroll */
  .sv-cot-steps {
    min-width: auto;
    max-width: 100%;
  }
  .sv-cot-bubble {
    padding: 8px 12px !important;
  }
  .sv-cot-label {
    font-size: 12px;
  }

  /* History attachment chips */
  .sv-history-attachment-chip {
    font-size: 10px;
    padding: 2px 6px;
  }
}

@media (max-width: 375px) {
  .sv-user-image {
    max-width: min(80vw, 220px);
    max-height: 180px;
  }

  .sv-doc-card {
    max-width: min(85vw, 280px);
    padding: 8px 10px;
  }
  .sv-doc-card-icon {
    font-size: 22px;
  }
  .sv-doc-card-download {
    font-size: 11px;
  }

  .sv-attach-preview--image {
    width: 48px;
    height: 48px;
  }
  .sv-attach-preview--file {
    max-width: 130px;
    font-size: 11px;
  }
}

/* ── Sent-Message Card ─────────────────────────────────────────────────
   Surfaces the actual body the Mini sent through a messaging tool
   (whatsapp / imessage / email / social) when chatting in the browser.
   Without this, the user only saw the model's narration.
*/
.sv-sent-msg-card {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sv-sent-msg-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}
.sv-sent-msg-card-icon {
  font-size: 16px;
  line-height: 1;
}
.sv-sent-msg-card-meta strong {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}
.sv-sent-msg-card-to {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 400;
}
.sv-sent-msg-card-subject {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sv-sent-msg-card-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.82);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 360px;
  overflow-y: auto;
}

@media (max-width: 720px) {
  .sv-sent-msg-card {
    max-width: min(90vw, 480px);
    padding: 10px 12px;
  }
  .sv-sent-msg-card-body {
    font-size: 13px;
  }
}
