/* Chat View - Message view with glassmorphism */
/* Supports both subpage mode (mobile) and panel mode (desktop) */

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: transparent;
  overflow: hidden;
}

/* Panel mode: contained within .chat-panel */
.chat-view-panel {
  height: 100%;
  min-height: 0; /* Critical: enables flex shrinking and internal scrolling */
  position: relative; /* Needed for absolute positioning of child elements */
}

/* ==== Header ==== */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  min-height: 77px;
  border-radius: 64px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  position: fixed;
  top: calc(var(--header-base-h) + 16px);
  left: 16px;
  right: 16px;
  z-index: 50;
  transition: transform 0.3s ease-in-out;
}

/* iOS safe area adjustment */
@supports (padding: env(safe-area-inset-top)) {
  .chat-header {
    top: calc(var(--header-base-h) + env(safe-area-inset-top) + 16px);
  }
}

.chat-header.hidden-scroll {
  transform: translateY(calc(-100% - 16px));
}

/* Panel mode: header is relative, not fixed */
.chat-view-panel .chat-header {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  border-radius: 8px;
  margin: 0;
  flex-shrink: 0; /* Don't shrink header */
}

.chat-view-panel .chat-header.hidden-scroll {
  transform: none; /* No hide on scroll in panel mode */
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-user-info.clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
  margin: -4px;
  transition: background-color 0.2s ease;
}

.chat-user-info.clickable:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.chat-user-info.clickable:active {
  transform: scale(0.98);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  overflow: visible; /* Allow indicators to extend outside */
  flex-shrink: 0;
  /* No background - avatar is rendered by avatarGenerator.js */
}

.chat-user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-user-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #fff);
}

.chat-user-status {
  font-size: 12px;
  color: var(--text-secondary, #aaa);
}

/* ==== Messages ==== */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  /* Bottom padding: 160px (jobs max-height) + 20px (breathing room) */
  padding: 96px 20px 180px 20px;
  position: relative;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.messages-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Panel mode: messages container adapts to relative layout */
.chat-view-panel .chat-messages {
  /* Bottom padding: 120px (jobs max-height) + 20px (breathing room) */
  padding: 20px 20px 140px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* Critical: allows flex item to be scrollable */
}

/* Message Group */
.message-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

/* Date Divider */
.date-divider {
  align-self: stretch;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #aaa);
  padding: 8px 0;
  margin: 12px 0;
  position: relative;
}

.date-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 0;
}

.date-divider::after {
  content: attr(data-date);
  background: var(--surface-bg, #1a1a1a);
  padding: 4px 12px;
  border-radius: 12px;
  position: relative;
  z-index: 1;
}

/* Message Bubbles */
.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

.message-bubble:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Alignment */
.message-bubble.align-left {
  align-self: flex-start;
}

.message-bubble.align-right {
  align-self: flex-end;
}

.message-bubble.align-center {
  align-self: center;
}

/* Bubble colors */
.bubble-fan {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #fff);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bubble-manual {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(37, 99, 235, 0.3));
  color: #fff;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.bubble-ai {
  background: linear-gradient(135deg, rgba(107, 70, 245, 0.3), rgba(168, 85, 247, 0.3));
  color: #fff;
  border: 1px solid rgba(107, 70, 245, 0.4);
}

/* Deleted message - placeholder */
.bubble-deleted {
  opacity: 0.5;
}

.bubble-deleted .deleted-message-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bubble-deleted .deleted-message-text {
  font-style: italic;
  font-size: 13px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.5));
}

.bubble-deleted .rbtn {
  opacity: 0.7;
  flex-shrink: 0;
}

.bubble-deleted .rbtn:hover {
  opacity: 1;
}

/* Deleted message - revealed (original content shown with dashed border) */
.bubble-deleted-revealed {
  opacity: 0.6;
  border-style: dashed !important;
  border-width: 1.5px !important;
}

.bubble-system {
  background: transparent;
  color: var(--text-secondary, #aaa);
  border: 1px solid rgba(245, 158, 11, 0.5);
  align-self: center !important;
  text-align: center;
  font-size: 13px;
  max-width: 80%;
}

/* Reply Preview in Bubble */
.reply-preview-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--primary, #6b46f5);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary, #aaa);
}

.reply-preview-bubble svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.6;
}

.reply-preview-bubble span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Message Media */
.message-media {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  margin-bottom: 8px;
  display: block;
  object-fit: cover;
}

.message-media.message-gif {
  max-height: 300px;
}

/* Video in messages */
video.message-media {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

/* Message Text */
.message-text {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 4px;
  white-space: pre-wrap;
}

/* Message Footer */
.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  position: relative;
}

.message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.message-status svg {
  width: 14px;
  height: 14px;
  color: rgba(255, 255, 255, 0.5);
}

/* ==== Jobs Zone ==== */

.chat-jobs {
  position: fixed;
  /* Bottom: 16px (footer margin) + 64px (footer height) + 8px (gap) = 88px */
  bottom: 88px;
  left: 16px;
  right: 16px;
  z-index: 45;
  padding: 10px 12px;
  background: transparent; /* Transparent background */
  backdrop-filter: none; /* No blur */
  border-radius: 16px;
  border: none; /* No border */
  box-shadow: none; /* No shadow */
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 160px;
  overflow-x: auto;
  overflow-y: auto;
  transition: transform 0.3s ease-in-out;
}

.chat-jobs::-webkit-scrollbar {
  height: 4px;
  width: 4px;
}

.chat-jobs::-webkit-scrollbar-track {
  background: transparent;
}

.chat-jobs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.chat-jobs.hidden {
  display: none;
}

/* iOS safe area adjustment */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-jobs {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

.chat-jobs.hidden-scroll {
  transform: translateY(calc(100% + 32px));
}

/* Panel mode: jobs zone stays floating but positioned relative to .chat-panel */
.chat-view-panel .chat-jobs {
  position: absolute;
  /* Bottom: 64px (footer height) + 8px (gap) = 72px */
  bottom: 72px;
  left: 16px;
  right: 16px;
  margin: 0;
  flex-shrink: 0;
  max-height: 120px;
  z-index: 45;
}

.chat-view-panel .chat-jobs.hidden-scroll {
  transform: none; /* No hide on scroll in panel mode */
}

/* Job items styles are now in css/components/jobItem.css */

/* ==== Footer ==== */

.chat-footer {
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 50;
  transition: transform 0.3s ease-in-out;
}

/* iOS safe area adjustment */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-footer {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

.chat-footer.hidden-scroll {
  transform: translateY(calc(100% + 32px));
}

/* Panel mode: footer is relative, not fixed */
.chat-view-panel .chat-footer {
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
  border-radius: 8px;
  margin: 0;
  flex-shrink: 0; /* Don't shrink footer */
}

.chat-view-panel .chat-footer.hidden-scroll {
  transform: none; /* No hide on scroll in panel mode */
}

/* Locked Footer - Integrated in chat-footer, same height as input-row */
.locked-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-secondary, #aaa);
}

.locked-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.locked-info svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--warning, #f59e0b);
}

.locked-text {
  font-size: 13px;
  color: var(--text-tertiary, #888);
  white-space: nowrap;
}

.locked-operator {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.locked-operator-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.locked-operator-avatar-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary, #6b46f5), var(--accent, #d946ef));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.locked-operator-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.locked-footer > .rbtn {
  flex-shrink: 0;
  color: var(--text-tertiary, #888);
}

.locked-footer > .rbtn:hover {
  color: var(--warning, #f59e0b);
}

/* Reply Bar */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: rgba(107, 70, 245, 0.1);
  border-left: 3px solid var(--primary, #6b46f5);
  border-radius: 8px;
}

.reply-bar.hidden {
  display: none;
}

.reply-preview {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary, #aaa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Input Row */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  transition: all 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: var(--primary, #6b46f5);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(107, 70, 245, 0.1);
}

.input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary, #fff);
  font-size: 15px;
}

.input-wrapper input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* ==== Attached Media Thumbnail ==== */

.attach-container {
  display: flex;
  align-items: center;
}

.attached-media-thumbnail {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.attached-media-thumbnail:hover {
  border-color: var(--primary, #6b46f5);
  box-shadow: 0 0 0 3px rgba(107, 70, 245, 0.2);
}

.attached-media-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attached-media-placeholder {
  width: 24px;
  height: 24px;
  color: var(--text-secondary, #aaa);
  display: flex;
  align-items: center;
  justify-content: center;
}

.attached-media-placeholder svg {
  width: 100%;
  height: 100%;
}

.detach-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  transition: all 0.2s ease;
  padding: 4px !important;
}

.detach-btn svg {
  width: 14px;
  height: 14px;
  color: #fff;
}

.attached-media-thumbnail:hover .detach-btn {
  opacity: 1;
}

.detach-btn:hover {
  background: rgba(220, 38, 38, 0.9) !important;
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

.detach-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

/* Button sizes */
.chat-footer .rbtn,
.chat-header .rbtn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.rbtn.primary {
  background: linear-gradient(135deg, var(--primary, #6b46f5), var(--accent, #d946ef));
  color: #fff;
}

.rbtn.primary:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(107, 70, 245, 0.3);
}

.rbtn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ==== Empty & Loading States ==== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary, #aaa);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary, #aaa);
}

.loading-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes highlight-flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(107, 70, 245, 0.2); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==== Typing Indicator ==== */

.typing-indicator {
  color: var(--primary, #6b46f5);
  font-style: italic;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ==== Alt Text Editor ==== */

.message-alt {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 13px;
}

.message-alt.empty {
  opacity: 0.6;
}

/* Alt text collapsed state (toggle in footer controls .message-alt visibility) */
.message-bubble.alt-collapsed .message-alt {
  display: none;
}

.alt-toggle-btn {
  background: none;
  border: none;
  padding: 0;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

@media (hover: hover) {
  .alt-toggle-btn:hover {
    color: var(--primary, #6b46f5);
  }
}

.alt-toggle-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.message-bubble:not(.alt-collapsed) .alt-toggle-btn svg {
  transform: rotate(180deg);
}

.alt-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alt-text {
  flex: 1;
  color: var(--text-secondary, #aaa);
  font-style: italic;
}

.alt-editor {
  display: flex;
  align-items: center;
  gap: 6px;
}

.alt-editor.hidden,
.alt-display.hidden,
.alt-generating.hidden {
  display: none;
}

.alt-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-primary, #fff);
  font-size: 13px;
}

.alt-input:focus {
  outline: none;
  border-color: var(--primary, #6b46f5);
}

.alt-generating {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary, #6b46f5);
}

.alt-generating svg {
  width: 14px;
  height: 14px;
  animation: spin 1s linear infinite;
}

.rbtn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.rbtn-sm svg {
  width: 14px;
  height: 14px;
}

/* ==== Candidate Messages (Multi-bubble) ==== */

.candidate-messages-container {
  margin-top: 12px;
  padding: 4px;
  animation: candidateAppear 0.3s ease-out;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

@keyframes candidateAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.candidate-message-bubble {
  max-width: 70%;
  align-self: flex-end;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  overflow: hidden;
  backdrop-filter: blur(10px);
  background: transparent;
  border: 2px solid var(--accent, #D925D2);
  animation: candidateBorderPulse 2s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(217, 37, 210, 0.3);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.candidate-message-bubble.candidate-fade-out {
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
}

@keyframes candidateBorderPulse {
  0%, 100% {
    border-color: var(--accent, #D925D2);
    box-shadow: 0 0 20px rgba(217, 37, 210, 0.3);
  }
  50% {
    border-color: rgba(217, 37, 210, 0.6);
    box-shadow: 0 0 30px rgba(217, 37, 210, 0.5);
  }
}


.candidate-message-bubble .message-text {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
  color: #fff;
}

.candidate-message-bubble .message-media {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  margin-bottom: 8px;
  display: block;
  object-fit: cover;
}

.candidate-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  justify-content: flex-end;
  max-width: 70%;
  width: 100%;
}

.candidate-message-actions .rbtn-text {
  position: relative;
  overflow: hidden;
  padding: 8px 16px;
  white-space: nowrap;
}

.candidate-message-actions .rbtn-text.send-now {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.4);
  color: rgb(134, 239, 172);
}

.candidate-message-actions .rbtn-text.send-now:hover {
  background: rgba(34, 197, 94, 0.3);
  border-color: rgba(34, 197, 94, 0.6);
}

.candidate-message-actions .rbtn-text.cancel-send {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: rgb(252, 165, 165);
}

.candidate-message-actions .rbtn-text.cancel-send:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.6);
}

.candidate-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(34, 197, 94, 0.8);
  border-radius: 0 0 18px 18px;
  transition: width 0.3s linear;
  pointer-events: none;
}

/* ==== Responsive ==== */

@media (max-width: 767px) {
  .chat-messages {
    /* Keep same padding on mobile */
    padding: 96px 16px 180px 16px;
  }
  
  .message-bubble {
    max-width: 85%;
  }
  
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-footer {
    padding: 12px 16px;
  }
}

/* ==== ThinkingAgent System Message ==== */

.thinking-agent-message {
  align-self: center;
  max-width: 90%;
  margin: 8px 0;
}

.thinking-agent-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(107, 70, 245, 0.1);
  border: 1px solid rgba(107, 70, 245, 0.25);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.thinking-agent-header:hover {
  background: rgba(107, 70, 245, 0.15);
  border-color: rgba(107, 70, 245, 0.4);
}

.thinking-agent-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--primary, #6b46f5);
}

.thinking-agent-icon svg {
  width: 16px;
  height: 16px;
}

.thinking-agent-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary, #6b46f5);
  letter-spacing: 0.3px;
}

.thinking-agent-time {
  font-size: 11px;
  color: var(--text-secondary, #aaa);
  margin-left: auto;
}

.thinking-agent-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-secondary, #aaa);
  transition: transform 0.2s ease;
}

.thinking-agent-toggle svg {
  width: 14px;
  height: 14px;
}

.thinking-agent-toggle.rotated {
  transform: rotate(180deg);
}

.thinking-agent-content {
  margin-top: 8px;
  padding: 12px 16px;
  background: rgba(107, 70, 245, 0.05);
  border: 1px solid rgba(107, 70, 245, 0.15);
  border-radius: 12px;
  animation: thinkingContentAppear 0.2s ease-out;
}

.thinking-agent-content.hidden {
  display: none;
}

@keyframes thinkingContentAppear {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thinking-agent-instructions,
.thinking-agent-reasoning {
  margin-bottom: 12px;
}

.thinking-agent-instructions:last-child,
.thinking-agent-reasoning:last-child {
  margin-bottom: 0;
}

.thinking-section-title {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #aaa);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.thinking-agent-instructions .thinking-section-title {
  color: #10b981;
}

.thinking-agent-reasoning .thinking-section-title {
  color: var(--primary, #6b46f5);
}

.thinking-section-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary, #fff);
  white-space: pre-wrap;
  word-break: break-word;
}

.thinking-agent-instructions .thinking-section-content {
  padding: 10px 12px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 8px;
  border-left: 3px solid rgba(16, 185, 129, 0.5);
}

.thinking-agent-reasoning .thinking-section-content {
  padding: 10px 12px;
  background: rgba(107, 70, 245, 0.1);
  border-radius: 8px;
  border-left: 3px solid rgba(107, 70, 245, 0.5);
  max-height: 200px;
  overflow-y: auto;
}

.thinking-agent-reasoning .thinking-section-content::-webkit-scrollbar {
  width: 4px;
}

.thinking-agent-reasoning .thinking-section-content::-webkit-scrollbar-thumb {
  background: rgba(107, 70, 245, 0.3);
  border-radius: 2px;
}

/* Expanded state styling */
.thinking-agent-message.expanded .thinking-agent-header {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  border-bottom-color: transparent;
}

/* System message content styling (for payment, etc.) */
.system-message-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.system-message-content svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.system-message-payment svg {
  color: #10b981;
}

/* ==== AutoReply Agent System Message ==== */

.autoreply-agent-message {
  align-self: center;
  max-width: 95%;
  width: 100%;
  margin: 8px 0;
}

.autoreply-agent-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(107, 70, 245, 0.1);
  border: 1px solid rgba(107, 70, 245, 0.25);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
}

.autoreply-agent-header:hover {
  background: rgba(107, 70, 245, 0.15);
  border-color: rgba(107, 70, 245, 0.4);
}

.autoreply-agent-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--primary, #6b46f5);
}

.autoreply-agent-icon svg {
  width: 16px;
  height: 16px;
}

.autoreply-agent-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary, #6b46f5);
  letter-spacing: 0.3px;
}

.autoreply-agent-time {
  font-size: 11px;
  color: var(--text-secondary, #aaa);
  margin-left: auto;
}

.autoreply-agent-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-secondary, #aaa);
  transition: transform 0.2s ease;
}

.autoreply-agent-toggle svg {
  width: 14px;
  height: 14px;
}

.autoreply-agent-toggle.rotated {
  transform: rotate(180deg);
}

.autoreply-agent-content {
  margin-top: 8px;
  padding: 12px;
  background: rgba(20, 20, 30, 0.5);
  border: 1px solid rgba(107, 70, 245, 0.15);
  border-radius: 12px;
  animation: agentContentAppear 0.2s ease-out;
}

.autoreply-agent-content.hidden {
  display: none;
}

@keyframes agentContentAppear {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Agent Result Sections — compact layout */
.agent-result-section {
  margin-bottom: 6px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  border-left: 3px solid rgba(107, 70, 245, 0.5);
}

.agent-result-section:last-child {
  margin-bottom: 0;
}

.agent-result-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  min-height: 22px;
}

.agent-result-section.inline-section .agent-result-header {
  margin-bottom: 0;
}

.agent-result-section.inline-section .agent-result-body {
  display: inline;
  margin-left: 4px;
}

.agent-result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.8;
}

.agent-result-icon svg {
  width: 12px;
  height: 12px;
}

.agent-result-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary, #aaa);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.agent-result-meta {
  font-size: 10px;
  color: var(--text-tertiary, #666);
  margin-left: auto;
}

.agent-result-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
}

.agent-result-badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.agent-result-badge.forced {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.agent-result-body {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-primary, #fff);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Achievements section */
.agent-result-achievements {
  border-left-color: rgba(245, 158, 11, 0.5);
}

.agent-result-achievements .agent-result-icon {
  color: #f59e0b;
}

.agent-result-achievements .agent-result-title {
  color: #f59e0b;
}

.achievement-tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 1px 3px 1px 0;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  font-size: 11px;
  color: #fbbf24;
}

/* Intent section (forced) */
.agent-result-intent {
  border-left-color: rgba(249, 115, 22, 0.5);
}

.agent-result-intent .agent-result-icon {
  color: #f97316;
}

.agent-result-intent .agent-result-title {
  color: #f97316;
}

.agent-result-intent .intent-value {
  font-weight: 600;
  color: #f97316;
}

.agent-result-intent .intent-reason {
  font-size: 12px;
  opacity: 0.7;
  margin-left: 8px;
}

.agent-result-intent .intent-score {
  font-size: 12px;
  opacity: 0.7;
  margin-left: 4px;
}

.agent-result-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
  opacity: 0.6;
  margin-left: 8px;
}

/* Context analysis section */
.agent-result-context {
  border-left-color: rgba(59, 130, 246, 0.5);
}

.agent-result-context .agent-result-icon {
  color: #3b82f6;
}

.agent-result-context .agent-result-title {
  color: #3b82f6;
}

/* Thinking/Instructions section */
.agent-result-thinking {
  border-left-color: rgba(16, 185, 129, 0.5);
}

.agent-result-thinking .agent-result-icon {
  color: #10b981;
}

.agent-result-thinking .agent-result-title {
  color: #10b981;
}

/* Reasoning section */
.agent-result-reasoning {
  border-left-color: rgba(107, 70, 245, 0.5);
}

.agent-result-reasoning .agent-result-icon {
  color: var(--primary, #6b46f5);
}

.agent-result-reasoning .agent-result-title {
  color: var(--primary, #6b46f5);
}

.agent-result-reasoning-content {
  max-height: 120px;
  overflow-y: auto;
  font-size: 11px;
  opacity: 0.9;
}

.agent-result-reasoning-content::-webkit-scrollbar {
  width: 4px;
}

.agent-result-reasoning-content::-webkit-scrollbar-thumb {
  background: rgba(107, 70, 245, 0.3);
  border-radius: 2px;
}

/* Strategy memo section */
.agent-result-strategy {
  border-left-color: rgba(16, 185, 129, 0.35);
}

.agent-result-strategy .agent-result-icon {
  color: #10b981;
  opacity: 0.7;
}

.agent-result-strategy .agent-result-title {
  color: #10b981;
  opacity: 0.7;
}

.agent-result-strategy-content {
  max-height: 80px;
  overflow-y: auto;
  font-size: 11px;
  opacity: 0.9;
}

.agent-result-strategy-content::-webkit-scrollbar {
  width: 4px;
}

.agent-result-strategy-content::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.3);
  border-radius: 2px;
}

/* Redaction multi-messages */
.agent-result-redaction {
  border-left-color: rgba(217, 37, 210, 0.5);
}

.agent-result-redaction .agent-result-icon {
  color: #d925d2;
}

.agent-result-redaction .agent-result-title {
  color: #d925d2;
}

.agent-result-redaction-messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  white-space: normal;
}

.redaction-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(217, 37, 210, 0.08);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-primary, #fff);
}

.redaction-msg-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(217, 37, 210, 0.25);
  color: #d925d2;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Empty state */
.agent-result-empty {
  text-align: center;
  padding: 10px;
  color: var(--text-secondary, #aaa);
  font-size: 12px;
  font-style: italic;
}

/* Expanded state styling */
.autoreply-agent-message.expanded .autoreply-agent-header {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  border-bottom-color: transparent;
}

/* Note: Agent Trace styles moved to css/components/agentTraceRenderer.css */

/* ==== Message Context Menu Overlay ==== */

.chat-context-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 100;
  pointer-events: none;
  transition: background 0.25s ease;
}

.chat-context-overlay.active {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

/* Highlighted bubble during context menu */
.message-bubble.context-active {
  position: relative;
  z-index: 101;
  box-shadow: 0 0 0 3px rgba(107, 70, 245, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: scale(1.02);
}

/* ==== Export Modal ==== */

.export-modal .form-group {
  margin-bottom: 20px;
}

.export-modal .form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 10px;
}

.export-modal .form-label-sm {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 12px;
}

/* Radio and checkbox options */
.export-type-options,
.export-exclusions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-option,
.checkbox-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-option:hover,
.checkbox-option:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.radio-option:has(input:checked),
.checkbox-option:has(input:checked) {
  background: linear-gradient(135deg, rgba(73, 114, 243, 0.15), rgba(217, 37, 210, 0.12));
  border-color: rgba(73, 114, 243, 0.4);
}

.radio-option input,
.checkbox-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.radio-label,
.checkbox-label {
  font-size: 0.9rem;
  color: var(--text);
}

/* Window params */
.export-window-params {
  margin-top: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.export-window-params.hidden {
  display: none;
}

.export-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Export type description */
.export-type-desc {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Export Preview */
.export-preview {
  margin-top: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  min-height: 80px;
}

.export-preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.export-preview-loading svg {
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
}

.export-preview-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 12px;
}

.export-preview-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-preview-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.export-preview-range {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-preview-msg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
}

.export-preview-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 50px;
}

.export-preview-id {
  color: var(--primary);
  font-family: monospace;
  font-size: 0.75rem;
}

.export-preview-date {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.export-preview-text {
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Export Result Modal */
.export-result-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.export-result-url {
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
  max-height: 80px;
  overflow-y: auto;
}

.export-result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.export-result-actions .btn {
  flex: 1;
  max-width: 160px;
}

/* Responsive */
@media (max-width: 480px) {
  .export-range-inputs {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .export-type-options {
    flex-direction: column;
  }
  
  .export-preview-msg {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .export-result-actions {
    flex-direction: column;
  }
  
  .export-result-actions .btn {
    max-width: none;
  }
}

/* ==== Job Attention Warning ==== */
.job-attention-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 16px 0 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
  animation: fadeIn 0.3s ease;
}

.job-attention-icon {
  flex-shrink: 0;
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.job-attention-icon svg {
  width: 24px;
  height: 24px;
}

.job-attention-content {
  flex: 1;
  min-width: 0;
}

.job-attention-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f59e0b;
  margin-bottom: 2px;
}

.job-attention-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-word;
}

.job-attention-warning .rbtn {
  flex-shrink: 0;
  color: var(--text-muted);
}

.job-attention-warning .rbtn:hover {
  color: var(--primary);
}
