/* Aria2 WebUI Stylesheet */
:root {
  --webui-bg: #0d1117;
  --webui-card: rgba(22, 27, 34, 0.85);
  --webui-border: rgba(240, 246, 252, 0.1);
  --webui-border-focus: #58a6ff;
  --webui-text: #f0f6fc;
  --webui-text-muted: #8b949e;
  --webui-primary: #58a6ff;
  --webui-success: #2ea043;
  --webui-warning: #d29922;
  --webui-danger: #f85149;
  --webui-cyan: #39c5cf;
  --webui-glow: rgba(88, 166, 255, 0.15);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --webui-bg: #f6f8fa;
  --webui-card: #ffffff;
  --webui-border: rgba(0, 0, 0, 0.12);
  --webui-border-focus: #0969da;
  --webui-text: #1f2328;
  --webui-text-muted: #656d76;
  --webui-primary: #0969da;
  --webui-success: #1a7f37;
  --webui-warning: #9a6700;
  --webui-danger: #cf222e;
  --webui-cyan: #059669;
  --webui-glow: rgba(9, 105, 218, 0.1);
}

.webui-page-wrapper {
  max-width: 1280px;
  margin: 6.5rem auto 5rem;
  padding: 0 1.5rem;
}

/* HERO SECTION */
.webui-header {
  text-align: center;
  margin-bottom: 2rem;
}

.webui-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #0056d2 0%, #39c5cf 50%, #6b21a8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.webui-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

/* RPC CONNECTION BAR */
.rpc-config-bar {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.rpc-inputs-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.rpc-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rpc-input-wrap label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rpc-input-field {
  background: var(--bg-color);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rpc-input-field:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 2px rgba(0, 86, 210, 0.15);
}

.rpc-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--surface-border);
}

.rpc-status-pill.connected {
  background: rgba(46, 160, 67, 0.15);
  color: #2ea043;
  border-color: rgba(46, 160, 67, 0.3);
}

.rpc-status-pill.disconnected {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.3);
}

.rpc-status-pill.connecting {
  background: rgba(210, 153, 34, 0.15);
  color: #d29922;
  border-color: rgba(210, 153, 34, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.pulse {
  animation: pulse 1.5s infinite;
}

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

/* STATS DASHBOARD */
.webui-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-icon-wrap.dl { background: rgba(57, 197, 207, 0.15); color: #39c5cf; }
.stat-icon-wrap.ul { background: rgba(88, 166, 255, 0.15); color: #58a6ff; }
.stat-icon-wrap.active { background: rgba(46, 160, 67, 0.15); color: #2ea043; }
.stat-icon-wrap.waiting { background: rgba(210, 153, 34, 0.15); color: #d29922; }

.stat-info .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-info .stat-val {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ACTION TOOLBAR & TABS */
.webui-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.task-tabs {
  display: flex;
  gap: 0.5rem;
}

.task-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.task-tab-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.task-tab-btn.active {
  background: var(--bg-color);
  color: var(--neon-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.tab-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface-border);
  color: var(--text-primary);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-webui {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-webui-primary {
  background: linear-gradient(135deg, #0056d2, #6b21a8);
  color: #ffffff;
}

.btn-webui-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-webui-outline {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.btn-webui-outline:hover {
  background: var(--surface-hover);
}

/* TASK CARDS / LIST */
.task-list-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 200px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.task-card:hover {
  border-color: var(--surface-border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.task-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.task-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.task-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.task-action-btn {
  background: var(--bg-color);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.task-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.task-action-btn.btn-danger:hover {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.3);
}

.task-progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--surface-border);
  border-radius: 4px;
  overflow: hidden;
}

.task-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #39c5cf, #58a6ff);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.task-progress-bar-fill.complete {
  background: #2ea043;
}

.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.empty-task-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px dashed var(--surface-border);
  border-radius: 12px;
}

.empty-task-placeholder svg {
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* MODAL DIALOGS */
.webui-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.webui-modal-overlay.open {
  display: flex;
}

.webui-modal-card {
  background: var(--bg-color);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.webui-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.webui-modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}

.webui-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.webui-modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.webui-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--surface-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--surface);
}

/* QUICK DAEMON HELPER BOX */
.daemon-helper-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 3rem;
}

.daemon-helper-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.code-snippet-box {
  background: var(--terminal-bg);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--neon-blue);
  overflow-x: auto;
  gap: 1rem;
}
