/* ==========================================
   GLOBAL QUEUE SYSTEM STYLES
   ========================================== */

/* Queue Widget (Navbar Badge) */
.queue-widget {
  background: var(--background-body);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.queue-widget.hidden {
  display: none;
}

.queue-widget.has-tasks {
  border-color: var(--primary-color, #3b82f6);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.queue-widget.has-ready {
  border-color: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.queue-widget.has-failed {
  border-color: #ef4444;
}

.queue-widget-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  user-select: none;
}

.queue-widget-icon {
  position: relative;
  font-size: 20px;
  color: var(--text-primary, #f1f5f9);
}

/* Queue Badge (on navbar button) */
.queue-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--primary-color, #3b82f6);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  animation: none;
}

.queue-badge.pulse {
  animation: badgePulse 1s ease;
}

.queue-badge.blinking {
  animation: badgeBlink 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); background: #10b981; }
}

@keyframes badgeBlink {
  0%, 100% {
    background: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }
  50% {
    background: #2563eb;
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
  }
}

.queue-widget-label {
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
}

.queue-widget-status {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  padding-left: 32px;
}

.queue-widget-status .status-ready {
  color: #10b981;
  font-weight: 500;
}

.queue-widget-status .status-processing {
  color: #3b82f6;
}

.queue-widget-status .status-queued {
  color: #f59e0b;
}

.queue-widget-status .status-failed {
  color: #ef4444;
  margin-left: 8px;
}

/* Queue Panel Overlay */
.queue-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.queue-panel-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Queue Panel */
.queue-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 480px;
  max-width: 100%;
  background: var(--background-body);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.queue-panel.open {
  transform: translateX(0);
}

/* Panel Header */
.queue-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--background-body);
  border-bottom: 1px solid var(--border-color, #1e293b);
}

.queue-panel-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text-primary, #f1f5f9);
  display: flex;
  align-items: center;
  gap: 10px;
}

.queue-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-clear-all-completed {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-clear-all-completed:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.queue-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.queue-panel-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #f1f5f9);
}

/* Panel Filters */
.queue-panel-filters {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
}

.queue-panel-filters select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-primary, #f1f5f9);
  font-size: 14px;
  cursor: pointer;
}

/* Panel Tasks List */
.queue-panel-tasks {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.queue-loading,
.queue-empty,
.queue-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #94a3b8);
}

.queue-loading i,
.queue-empty i,
.queue-error i {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.queue-empty p {
  margin: 8px 0 0;
}

/* Task Group */
.task-group {
  margin-bottom: 24px;
}

.task-group-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
}

/* Task Card */
.task-card {
  background: var(--background-card);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}


.task-card.task-queued {
  border-left-color: #f59e0b;
}

.task-card.task-processing {
  border-left-color: #3b82f6;
}

.task-card.task-ready {
  border-left-color: #10b981;
}

.task-card.task-completed {
  border-left-color: #6b7280;
}

.task-card.task-failed {
  border-left-color: #ef4444;
}

/* Task Card Header */
.task-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.task-status-icon {
  font-size: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

.task-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.4;
  margin: 0;
}

/* Task Badges */
.task-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  padding-left: 26px;
}

.task-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.task-badge.badge-type {
  background: var(--primary-color, #3b82f6);
  color: white;
}

.task-badge.badge-id {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.task-badge.badge-source,
.task-badge.badge-format,
.task-badge.badge-quality {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary, #94a3b8);
  border: 1px solid var(--border-color, #334155);
}

/* Task Time Meta */
.task-time-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-left: 26px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
}

.task-time-meta i {
  margin-right: 4px;
  font-size: 11px;
}

.time-duration {
  color: var(--text-primary, #f1f5f9);
  font-weight: 500;
}

/* Task Progress */
.task-progress {
  margin-bottom: 10px;
  padding-left: 26px;
}

.progress-bar {
  height: 8px;
  background: var(--border-color, #334155);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 4px;
  transition: width 0.3s ease;
  animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
}

/* Task Messages */
.task-message {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 10px;
  margin-left: 26px;
}

.task-ready-message {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.task-error-message {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  margin-left: 26px;
}

/* Task Actions */
.task-actions {
  display: flex;
  gap: 8px;
  padding-left: 26px;
}

.task-actions .btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border-color, #334155);
  background: var(--background-card, #1e293b);
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  transition: all 0.2s;
}

.task-actions .btn-sm:hover {
  background: var(--card-hover-bg, #283548);
  border-color: var(--primary-color, #3b82f6);
}

.task-actions .btn-sm.btn-primary {
  background: var(--primary-color, #3b82f6);
  border-color: var(--primary-color, #3b82f6);
  color: white;
}

.task-actions .btn-sm.btn-primary:hover {
  background: #2563eb;
}

.task-actions .btn-sm.btn-retry {
  background: #f59e0b;
  border-color: #f59e0b;
  color: white;
}

.task-actions .btn-sm.btn-retry:hover {
  background: #d97706;
}

.task-actions .btn-sm.btn-cancel {
  color: #ef4444;
}

.task-actions .btn-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* Task Notifications */
.task-notifications-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.task-notification {
  background: var(--background-card, #1e293b);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  min-width: 360px;
  max-width: 420px;
  pointer-events: all;
  transform: translateX(450px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.task-notification.show {
  transform: translateX(0);
  opacity: 1;
}

.task-notification.fade-out {
  opacity: 0;
  transform: translateX(100px);
}

.notification-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}

.notification-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.notification-body {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-message {
  font-size: 14px;
  color: var(--text-secondary, #94a3b8);
}

.notification-close {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.notification-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #f1f5f9);
}

.notification-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-color, #334155);
  padding-top: 12px;
  margin-top: 0;
}

.notification-actions .btn-sm {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 4px;
  border: 1px solid var(--border-color, #334155);
  background: var(--bg-primary, #0f172a);
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  transition: all 0.2s;
}

.notification-actions .btn-sm:hover {
  background: var(--card-hover-bg, #283548);
}

.notification-actions .btn-sm.btn-primary {
  background: var(--primary-color, #3b82f6);
  border-color: var(--primary-color, #3b82f6);
  color: white;
}

.notification-actions .btn-sm.btn-primary:hover {
  background: #2563eb;
}

/* Color Utilities */
.text-yellow { color: #f59e0b; }
.text-blue { color: #3b82f6; }
.text-green { color: #10b981; }
.text-red { color: #ef4444; }
.text-gray { color: #6b7280; }

/* Responsive */
@media (max-width: 768px) {
  .queue-panel {
    width: 100%;
  }

  .task-notification {
    min-width: 300px;
    max-width: calc(100vw - 40px);
  }

  .task-notifications-container {
    left: 20px;
    right: 20px;
  }

  .task-card-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-actions {
    width: 100%;
    justify-content: stretch;
  }

  .task-actions .btn-sm {
    flex: 1;
  }
}
