/* Thread Tabs Component Styles - Vertical Sidebar Layout */

.thread-tabs {
  display: flex;
  flex-direction: column;
  background: var(--bs-gray-100, #f8f9fa);
  border-right: 1px solid var(--border-color, #e0e0e0);
  width: 200px;
  height: 100%;
  overflow: hidden;
  transition: width 0.2s ease;
}

/* Collapsed state */
.thread-tabs.collapsed {
  width: 60px;
}

.thread-tabs.collapsed .thread-title {
  display: none;
}

.thread-tabs.collapsed .thread-close {
  display: none;
}

.thread-tabs.collapsed .thread-unread {
  position: absolute;
  top: 2px;
  right: 2px;
}

.thread-tabs.collapsed .thread-new-btn span {
  display: none;
}

.thread-tabs.collapsed .thread-tab {
  justify-content: center;
  padding: 10px;
}

.thread-tabs.collapsed .participant-picker {
  left: 100%;
  margin-left: 8px;
  bottom: 0;
  border-radius: 8px;
}

/* Collapse button header */
.thread-tabs-header {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  flex-shrink: 0;
}

.thread-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--text-muted, #999);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.thread-collapse-btn:hover {
  background: var(--bs-gray-200, #e9ecef);
  color: var(--text-color, #333);
}

.thread-tabs-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  scrollbar-width: thin;
}

.thread-tabs-scroll::-webkit-scrollbar {
  width: 6px;
}

.thread-tabs-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.thread-tabs-scroll::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.thread-tabs-scroll::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

.thread-tab-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thread-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  position: relative;
  width: 100%;
  text-align: left;
}

.thread-tab:hover {
  background: var(--bs-gray-200, #e9ecef);
  border-color: var(--bs-gray-300, #dee2e6);
}

.thread-tab.active {
  background: white;
  border-color: var(--bs-primary, #0d6efd);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.thread-tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--bs-primary, #0d6efd);
  border-radius: 0 3px 3px 0;
}

/* Thread status indicator */
.thread-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted, #999);
  flex-shrink: 0;
}

.thread-status.running {
  background: var(--color-warning, #f0ad4e);
  animation: pulse 1.5s infinite ease-in-out;
}

.thread-status.idle {
  background: var(--color-success, #5cb85c);
}

.thread-status.failed {
  background: var(--color-error, #d9534f);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.9);
  }
}

/* Thread title */
.thread-title {
  flex: 1;
  min-width: 0;
  /* Use word wrap instead of truncating to show full persona names */
  overflow-wrap: break-word;
  word-break: break-word;
  /* Slightly smaller font to fit longer names */
  font-size: 0.8125rem; /* 13px instead of 14px */
  line-height: 1.3;
  font-weight: 500;
  color: var(--chat-text, #333);
  user-select: none;
  /* Limit to 2 lines max to prevent tabs from getting too tall */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread-tab.active .thread-title {
  font-weight: 600;
}

/* Thread title editing */
.thread-title-input {
  flex: 1;
  padding: 2px 4px;
  border: 1px solid var(--accent-color, #007bff);
  border-radius: 3px;
  font-size: 13px;
  outline: none;
  min-width: 60px;
}

/* Unread badge */
.thread-unread {
  background: var(--accent-color, #007bff);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Close button */
.thread-close {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  color: var(--text-muted, #999);
  font-size: 16px;
  line-height: 1;
  border-radius: 3px;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.thread-tab:hover .thread-close {
  opacity: 1;
}

.thread-close:hover {
  color: var(--color-error, #d9534f);
  background: rgba(217, 83, 79, 0.1);
}

/* New thread button container */
.thread-new-container {
  padding: 12px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-secondary, #f5f5f5);
  position: relative;
  flex-shrink: 0;
}

/* New thread button */
.thread-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-primary, #0d6efd);
  color: white;
  border: none;
  width: 100%;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.15s;
  gap: 6px;
}

.thread-new-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.thread-new-btn:active {
  transform: translateY(0);
}

.thread-new-btn svg {
  width: 16px;
  height: 16px;
}

/* Notification toast */
.thread-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e0e0e0);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  z-index: 10000;
  font-size: 14px;
  max-width: 300px;
}

.thread-notification.error {
  border-color: var(--color-error, #d9534f);
  background: #fff5f5;
}

.thread-notification.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

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

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

/* Dark mode support */
[data-bs-theme="dark"] .thread-tabs {
  background: var(--bs-dark-bg-subtle, #1b1f23);
  border-right-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .thread-tabs-header {
  border-bottom-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .thread-collapse-btn:hover {
  background: var(--bg-light);
  color: var(--text-color, #e0e0e0);
}

[data-bs-theme="dark"] .thread-new-container {
  background: var(--bs-dark-bg-subtle, #1b1f23);
  border-top-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .thread-tab:hover {
  background: var(--bg-light);
  border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .thread-tab.active {
  background: var(--bg-light);
  border-color: var(--bs-primary, #0d6efd);
}

[data-bs-theme="dark"] .thread-title {
  color: var(--text-color, #e0e0e0);
}

[data-bs-theme="dark"] .thread-notification {
  background: var(--bg-dark);
  border-color: var(--bs-border-color);
  color: var(--text-color, #e0e0e0);
}

[data-bs-theme="dark"] .thread-notification.error {
  background: #3d2020;
  border-color: var(--color-error, #d9534f);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .claude-chat-container.show {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "header"
      "body" !important;
  }

  .thread-tabs {
    display: none !important;
  }

  /* Could add mobile tabs toggle in header here if needed */
}

/* ========================================================================== */
/* Participant Picker Styles                                                   */
/* ========================================================================== */

.participant-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  margin-bottom: 4px;
  overflow: hidden;
}

.participant-picker-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #666);
  background: var(--bg-secondary, #f5f5f5);
  border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.participant-picker-loading {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted, #999);
  font-size: 13px;
}

.participant-picker-content {
  max-height: 400px;
  overflow-y: auto;
}

.participant-section {
  padding: 8px 0;
}

.participant-section:not(:last-child) {
  border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.participant-section-title {
  padding: 4px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #999);
  letter-spacing: 0.5px;
}

.participant-list {
  display: flex;
  flex-direction: column;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.participant-item:hover {
  background: var(--bg-hover, #f0f0f0);
}

.participant-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary, #e8e8e8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

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

.participant-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color, #333);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-tagline {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #666);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* Thread tab participant avatar */
.thread-participant-avatar {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Thread type indicators */
.thread-tab-ai_persona {
  border-left: 2px solid var(--color-purple, #9b59b6);
}

.thread-tab-user {
  border-left: 2px solid var(--color-blue, #3498db);
}

/* Dark mode for participant picker */
@media (prefers-color-scheme: dark) {
  .participant-picker {
    background: var(--bg-primary, #1e1e1e);
    border-color: var(--border-color, #444);
  }

  .participant-picker-header {
    background: var(--bg-secondary, #2d2d2d);
    border-color: var(--border-color, #444);
    color: var(--text-muted, #aaa);
  }

  .participant-section:not(:last-child) {
    border-color: var(--border-color, #444);
  }

  .participant-item:hover {
    background: var(--bg-hover, #333);
  }

  .participant-avatar {
    background: var(--bg-tertiary, #333);
  }

  .participant-name {
    color: var(--text-color, #e0e0e0);
  }

  .participant-tagline {
    color: var(--text-muted, #888);
  }
}

/* Responsive participant picker */
@media (max-width: 768px) {
  .participant-picker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: none;
    min-width: auto;
    border-radius: 16px 16px 0 0;
    margin-top: 0;
  }

  .participant-picker-content {
    max-height: 50vh;
  }
}
