/**
 * Get4All - Torrent Cloud Task Manager & Debrid Styles
 */

.feed-filter-btn.filter-torrents {
  position: relative;
  font-weight: 700;
}

.feed-filter-btn.filter-torrents .filter-count-badge {
  background: var(--primary, #3b82f6);
  color: #ffffff;
}

.torrent-feed-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow-y: auto;
  padding: 12px 16px 24px;
  box-sizing: border-box;
}

/* Sub-Toolbar */
.torrent-sub-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: var(--bg-root, #0b0f19);
  z-index: 5;
}

.torrent-sub-filters {
  display: flex;
  align-items: center;
  gap: 6px;
}

.torrent-sub-btn {
  background: var(--bg-card, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #94a3b8);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-xs, 4px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.torrent-sub-btn:hover {
  background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
  color: var(--text-primary, #ffffff);
}

.torrent-sub-btn.active {
  background: var(--primary, #3b82f6);
  color: #ffffff;
  border-color: var(--primary, #3b82f6);
}

.torrent-badge-count {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  font-family: var(--font-mono, monospace);
}

.btn-torrent-refresh {
  background: transparent;
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.08));
  color: var(--text-muted, #94a3b8);
  font-size: 11.5px;
  font-family: var(--font-mono, monospace);
  padding: 5px 10px;
  border-radius: var(--radius-xs, 4px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-torrent-refresh:hover {
  color: var(--text-primary, #ffffff);
  border-color: var(--border-focus, #3b82f6);
}

.btn-torrent-refresh.spinning svg {
  animation: torrentRefreshSpin 0.6s linear infinite;
}

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

/* Stream List */
.torrent-cards-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.torrent-card-item {
  background: var(--bg-card, #111827);
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-sm, 6px);
  padding: 14px 16px;
  position: relative;
  transition: border-color 0.15s ease;
}

.torrent-card-item:hover {
  border-color: var(--border-focus, rgba(59, 130, 246, 0.4));
}

.torrent-card-item.is-mine {
  border-left: 3px solid var(--primary, #3b82f6);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.04) 0%, var(--bg-card, #111827) 100%);
}

.torrent-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.torrent-card-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 8px;
}

.torrent-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.badge-torrent-mine {
  background: rgba(37, 99, 235, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(37, 99, 235, 0.4);
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-torrent-requester {
  background: var(--bg-card-hover, rgba(255, 255, 255, 0.06));
  color: var(--text-muted, #94a3b8);
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.08));
  font-size: 10.5px;
  font-family: var(--font-mono, monospace);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-torrent-status {
  font-size: 10.5px;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-torrent-status.completed {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-torrent-status.downloading {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.badge-torrent-status.queued {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Progress bar */
.torrent-card-progress {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.08));
  overflow: hidden;
  margin: 10px 0;
}

.torrent-card-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--primary, #3b82f6);
  transition: width 0.3s ease;
}

.torrent-card-progress-bar.completed {
  background: #10b981;
}

/* Telemetry meta */
.torrent-card-telemetry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted, #94a3b8);
}

/* Actions bar */
.torrent-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
  flex-wrap: wrap;
}

.btn-torrent-accordion {
  background: transparent;
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #e2e8f0);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-xs, 4px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-torrent-accordion:hover {
  background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
  color: var(--text-primary, #ffffff);
}

.btn-torrent-permalink {
  color: var(--text-muted, #94a3b8);
  font-size: 11.5px;
  font-family: var(--font-mono, monospace);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-torrent-permalink:hover {
  color: var(--primary, #3b82f6);
  text-decoration: underline;
}

/* Multi-file Accordion Drawer */
.torrent-files-drawer {
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-root, #0a0e17);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: var(--radius-xs, 4px);
  max-height: 260px;
  overflow-y: auto;
}

.torrent-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 12px;
}

.torrent-file-row:last-child {
  border-bottom: none;
}

.torrent-file-name-block {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.torrent-file-name-text {
  font-family: var(--font-mono, monospace);
  color: var(--text-primary, #ffffff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.btn-generate-torrent-file {
  background: var(--primary, #3b82f6);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-xs, 4px);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-generate-torrent-file:hover {
  background: #2563eb;
}

.btn-generate-torrent-file.ready {
  background: #10b981;
}

.btn-generate-torrent-file.ready:hover {
  background: #059669;
}

.btn-generate-torrent-file.loading {
  opacity: 0.7;
  pointer-events: none;
}

.torrent-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted, #94a3b8);
}

/* ==========================================================================
   Light Theme Crisp High-Contrast Overrides
   ========================================================================== */
body.theme-light .torrent-sub-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
}

body.theme-light .torrent-sub-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
}

body.theme-light .torrent-sub-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

body.theme-light .torrent-sub-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

body.theme-light .btn-torrent-refresh {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
}

body.theme-light .btn-torrent-refresh:hover {
  border-color: #0284c7;
  color: #0284c7;
}

body.theme-light .torrent-card-item {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.theme-light .torrent-card-item:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

body.theme-light .torrent-card-item.is-mine {
  border-left: 3px solid #0284c7;
  background: linear-gradient(90deg, #eff6ff 0%, #ffffff 100%);
}

body.theme-light .torrent-card-name {
  color: #0f172a !important;
  font-weight: 700;
}

body.theme-light .torrent-card-progress {
  background: #e2e8f0;
}

body.theme-light .torrent-card-telemetry {
  color: #475569;
}

body.theme-light .torrent-card-telemetry strong {
  color: #0f172a;
}

body.theme-light .btn-torrent-accordion {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
}

body.theme-light .btn-torrent-accordion:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

body.theme-light .btn-torrent-permalink {
  color: #0284c7;
  font-weight: 600;
}

body.theme-light .btn-torrent-permalink:hover {
  color: #0369a1;
  text-decoration: underline;
}

body.theme-light .torrent-files-drawer {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

body.theme-light .torrent-file-row {
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .torrent-file-name-text {
  color: #0f172a;
}

body.theme-light .btn-generate-torrent-file {
  background: #0284c7;
  color: #ffffff;
}

body.theme-light .btn-generate-torrent-file:hover {
  background: #0369a1;
}

body.theme-light .btn-generate-torrent-file.ready {
  background: #10b981;
}

body.theme-light .btn-generate-torrent-file.ready:hover {
  background: #059669;
}

body.theme-light .badge-torrent-mine {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

body.theme-light .badge-torrent-requester {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

body.theme-light .badge-torrent-status.completed {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

body.theme-light .badge-torrent-status.downloading {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

body.theme-light .badge-torrent-status.queued {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* Expiry Alert on Completed Torrent Cards */
.torrent-card-expiry-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-xs, 4px);
  padding: 6px 10px;
  margin: 10px 0 4px;
  font-size: 11.5px;
  color: #fbbf24;
}

body.theme-light .torrent-card-expiry-alert {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.torrent-countdown {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  color: #f59e0b;
}

body.theme-light .torrent-countdown {
  color: #b45309;
}

/* Cluster Limit Badge */
.torrent-cluster-limit-badge {
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs, 4px);
  background: rgba(56, 189, 248, 0.1);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

body.theme-light .torrent-cluster-limit-badge {
  background: #eff6ff;
  color: #0284c7;
  border-color: #bae6fd;
}

/* Magnet Support Badge in Composer Toolbar */
.badge-magnet-support {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs, 4px);
  background: rgba(14, 165, 233, 0.1);
  color: #0ea5e9;
  border: 1px solid rgba(14, 165, 233, 0.25);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.badge-magnet-support:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.45);
  transform: translateY(-1px);
}

.badge-magnet-support .magnet-icon {
  flex-shrink: 0;
  stroke: currentColor;
}

.badge-magnet-support .magnet-pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  flex-shrink: 0;
  display: inline-block;
  animation: pulseMagnetDot 2s infinite;
}

@keyframes pulseMagnetDot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

body.theme-light .badge-magnet-support {
  background: #f0f9ff;
  color: #0284c7;
  border-color: #bae6fd;
}

body.theme-light .badge-magnet-support:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

@media (max-width: 900px) {
  .shortcut-hint {
    display: none;
  }
}

@media (max-width: 480px) {
  .badge-magnet-support {
    display: none;
  }
}
