/**
 * Task History Sidebar Styles
 * Cline-style task history interface
 */

.task-history-sidebar {
  height: 100%;
  overflow-y: auto;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* Filters Section */
.task-filters {
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.task-filters h6 {
  font-weight: 600;
  color: #212529;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.task-filters input,
.task-filters select {
  font-size: 0.875rem;
}

/* Task List */
.task-list {
  flex: 1;
  overflow-y: auto;
}

/* Task Item */
.task-item {
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.task-item:hover {
  background-color: #f8f9fa;
}

.task-item.task-running {
  background: linear-gradient(90deg, #e7f3ff 0%, #fff 100%);
  border-left: 3px solid #0d6efd;
}

.task-item.task-running::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #0d6efd 0%, transparent 100%);
  animation: pulse 2s ease-in-out infinite;
}

/* Task Header */
.task-header {
  cursor: pointer;
  user-select: none;
}

.task-header:hover {
  background-color: #f1f3f5;
}

.task-header:active {
  background-color: #e9ecef;
}

/* Task Description */
.task-description {
  font-size: 0.875rem;
  color: #495057;
  line-height: 1.4;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* Task Details */
.task-details {
  border-top: 1px solid #dee2e6;
}

.task-details .bg-light {
  background-color: #f8f9fa !important;
}

/* Chevron Animation */
.task-chevron {
  transition: transform 0.2s ease;
  font-size: 0.875rem;
  color: #6c757d;
}

.task-chevron.rotated {
  transform: rotate(180deg);
}

/* Badges */
.task-item .badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25em 0.5em;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.task-item .badge i {
  font-size: 0.875em;
}

/* Action Buttons */
.task-details .btn {
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
}

.task-details .btn i {
  font-size: 0.875rem;
}

/* Alert in Details */
.task-details .alert {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0;
}

.task-details .alert i {
  margin-right: 0.25rem;
}

/* Collapse Animation */
.collapsing {
  transition: height 0.2s ease;
}

/* Empty State */
.task-list .text-muted {
  color: #adb5bd !important;
}

.task-list .bi-inbox {
  color: #dee2e6;
}

/* Scrollbar Styling */
.task-list::-webkit-scrollbar,
.task-history-sidebar::-webkit-scrollbar {
  width: 6px;
}

.task-list::-webkit-scrollbar-track,
.task-history-sidebar::-webkit-scrollbar-track {
  background: #f1f3f5;
}

.task-list::-webkit-scrollbar-thumb,
.task-history-sidebar::-webkit-scrollbar-thumb {
  background: #adb5bd;
  border-radius: 3px;
}

.task-list::-webkit-scrollbar-thumb:hover,
.task-history-sidebar::-webkit-scrollbar-thumb:hover {
  background: #868e96;
}

/* Skeleton Loading States */
.skeleton {
  animation: skeleton-loading 1.5s infinite;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  border-radius: 4px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.task-skeleton {
  pointer-events: none;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: inherit;
}

.loading-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* Progress Bar Animations */
.progress-bar-animated {
  animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
  0% { background-position: 1rem 0; }
  100% { background-position: 0 0; }
}

/* Mobile: Stack task history vertically */
@media (max-width: 768px) {
  .task-history-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 40vh;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: max-height 0.3s ease;
  }

  .task-history-sidebar.collapsed {
    max-height: 60px;
  }

  .task-filters {
    padding: 0.75rem !important;
  }

  .task-item {
    font-size: 0.9rem;
  }

  .task-header {
    padding: 0.75rem !important;
  }
  
  .task-details .btn {
    margin-top: 0.5rem;
    width: 100%;
  }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 992px) {
  .task-history-sidebar {
    max-width: 300px;
  }
}

/* Dark Mode Support */
body[data-theme="dark"] .task-history-sidebar {
  background: var(--bg-primary);
}

body[data-theme="dark"] .task-filters {
  background: var(--bg-secondary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body[data-theme="dark"] .task-filters h6 {
  color: var(--text-primary);
}

body[data-theme="dark"] .task-item:hover {
  background-color: var(--hover-bg);
}

body[data-theme="dark"] .task-item.task-running {
  background: linear-gradient(90deg, rgba(13, 110, 253, 0.15) 0%, var(--bg-primary) 100%);
}

body[data-theme="dark"] .task-header:hover {
  background-color: var(--bg-tertiary);
}

body[data-theme="dark"] .task-header:active {
  background-color: var(--hover-bg);
}

body[data-theme="dark"] .task-description {
  color: var(--text-secondary);
}

body[data-theme="dark"] .task-details {
  border-top-color: var(--border);
}

body[data-theme="dark"] .task-details .bg-light {
  background-color: var(--bg-secondary) !important;
}

body[data-theme="dark"] .task-chevron {
  color: var(--text-muted);
}

body[data-theme="dark"] .task-list::-webkit-scrollbar-track,
body[data-theme="dark"] .task-history-sidebar::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

body[data-theme="dark"] .task-list::-webkit-scrollbar-thumb,
body[data-theme="dark"] .task-history-sidebar::-webkit-scrollbar-thumb {
  background: var(--text-muted);
}

body[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
}

body[data-theme="dark"] .task-item.loading::after {
  background: rgba(0, 0, 0, 0.6);
}

/* Loading State */
.task-item.loading {
  opacity: 0.6;
  pointer-events: none;
}

.task-item.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast Container Override */
.toast-container .toast {
  min-width: 250px;
}

.toast-container .toast .toast-body {
  font-size: 0.875rem;
}

/* Status-specific styles */
.task-item[data-status="completed"] {
  border-left-color: #198754;
}

.task-item[data-status="failed"] {
  border-left-color: #dc3545;
}

.task-item[data-status="analyzing"] {
  border-left-color: #0dcaf0;
}

.task-item[data-status="executing"] {
  border-left-color: #0d6efd;
}

.task-item[data-status="merging"] {
  border-left-color: #ffc107;
}

/* Smooth height transitions */
.task-item,
.task-details {
  transition: all 0.2s ease;
}

/* Better spacing for small text */
.task-header small {
  font-size: 0.75rem;
  line-height: 1.2;
}

/* Icon colors */
.bi-clock {
  color: #6c757d;
}

.bi-person {
  color: #0d6efd;
}

.bi-file-code {
  color: #198754;
}
