/* ==========================================================================
   Panel — design tokens (shared palette with Freeflix for continuity)
   ========================================================================== */
:root {
  --bg: #08080a;
  --bg-elevated: #0f0f13;
  --surface: #17171c;
  --surface-2: #1f1f26;
  --surface-hover: #26262f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f6;
  --text-dim: #a6a6b3;
  --text-faint: #6d6d7a;
  --red: #e50914;
  --red-bright: #ff2b3a;
  --red-glow: rgba(229, 9, 20, 0.4);
  --violet: #8b2fc9;
  --violet-bright: #b25cf0;
  --violet-glow: rgba(139, 47, 201, 0.35);
  --accent-grad: linear-gradient(135deg, var(--red) 0%, var(--violet) 100%);
  --green: #2ead20;
  --amber: #f5b301;
  --blue: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 12px 28px -12px rgba(0, 0, 0, 0.65);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 62px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(229, 9, 20, 0.1), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(139, 47, 201, 0.08), transparent 55%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--red); color: #fff; }

/* ==========================================================================
   Navbar
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: rgba(8, 8, 10, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, var(--red-bright), var(--violet-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-links a {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.nav-links a:hover { color: #fff; background: var(--surface); }
.nav-links a.active { color: #fff; background: var(--surface-2); }

.nav-spacer { flex: 1; }

.disk-widget {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.disk-pill {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 92px;
}

.disk-pill-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.disk-pill-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.disk-pill-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent-grad);
  transition: width 0.4s var(--ease);
}

.disk-pill-bar-fill.warn { background: linear-gradient(135deg, var(--amber), var(--red)); }
.disk-pill-bar-fill.critical { background: var(--red-bright); }

.disk-pill-text {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.logout-btn {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.logout-btn:hover { color: #fff; border-color: var(--border-strong); background: var(--surface); }

/* ==========================================================================
   Layout
   ========================================================================== */
.content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-heading {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.page-heading::before {
  content: "";
  width: 4px;
  height: 1.1em;
  background: var(--accent-grad);
  border-radius: 2px;
}

/* ==========================================================================
   Forms
   ========================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}

.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 8px 22px -8px var(--red-glow); }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary:active { filter: brightness(0.9); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }

.btn-danger { background: transparent; color: var(--red-bright); border: 1px solid rgba(229, 9, 20, 0.35); }
.btn-danger:hover { background: rgba(229, 9, 20, 0.12); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.error-banner {
  background: rgba(229, 9, 20, 0.12);
  border: 1px solid rgba(229, 9, 20, 0.35);
  color: #ffb4b9;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

/* ==========================================================================
   Cards / tables
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.result-list, .job-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.2rem;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

.result-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.result-score {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  background: conic-gradient(var(--red) calc(var(--pct) * 1%), var(--surface-2) 0);
  position: relative;
}

.result-score::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--surface);
}

.result-score span { position: relative; z-index: 1; }

.result-main { flex: 1; min-width: 0; }

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.tag.seeders-good { color: #8fe28a; border-color: rgba(46, 173, 32, 0.35); }
.tag.seeders-low { color: #f0a5a5; border-color: rgba(229, 9, 20, 0.3); }
.tag.lang-match { color: #c9a5f5; border-color: rgba(139, 47, 201, 0.35); }

.tag.tag-remux {
  color: #fff;
  background: rgba(229, 9, 20, 0.3);
  border-color: rgba(229, 9, 20, 0.55);
  font-weight: 700;
  cursor: help;
}

.score-breakdown {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--text-faint);
}

.score-bar {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.score-bar-fill { height: 100%; background: var(--accent-grad); }

/* ==========================================================================
   Job list
   ========================================================================== */
.job-card { padding: 1rem 1.2rem; }

.job-card-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.job-title { font-weight: 700; font-size: 0.95rem; }
.job-release { font-size: 0.78rem; color: var(--text-faint); margin-top: 0.15rem; }

.state-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.state-badge .dot { width: 6px; height: 6px; border-radius: 50%; }

.state-QUEUED { background: var(--surface-2); color: var(--text-dim); }
.state-QUEUED .dot { background: var(--text-faint); }
.state-ADDING_TORRENT, .state-DOWNLOADING { background: rgba(59, 130, 246, 0.14); color: #93c5fd; }
.state-ADDING_TORRENT .dot, .state-DOWNLOADING .dot { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.state-DOWNLOAD_COMPLETE, .state-PROBING, .state-TRANSCODING { background: rgba(139, 47, 201, 0.14); color: #d6b3f7; }
.state-DOWNLOAD_COMPLETE .dot, .state-PROBING .dot, .state-TRANSCODING .dot { background: var(--violet-bright); box-shadow: 0 0 6px var(--violet-glow); }
.state-PUBLISHING { background: rgba(245, 179, 1, 0.14); color: #fcd34d; }
.state-PUBLISHING .dot { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.state-DONE { background: rgba(46, 173, 32, 0.14); color: #8fe28a; }
.state-DONE .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.state-FAILED { background: rgba(229, 9, 20, 0.14); color: #f0a5a5; }
.state-FAILED .dot { background: var(--red-bright); box-shadow: 0 0 6px var(--red-glow); }
.state-CANCELLED { background: var(--surface-2); color: var(--text-faint); }
.state-CANCELLED .dot { background: var(--text-faint); }

/* Transmission torrent-manager tab status badges — separate palette from
   job states above since they're a different vocabulary (Transmission's
   own status codes, not the panel's pipeline states). */
.tr-badge.tr-stopped { background: var(--surface-2); color: var(--text-faint); }
.tr-badge.tr-stopped .dot { background: var(--text-faint); }
.tr-badge.tr-waiting { background: rgba(245, 179, 1, 0.14); color: #fcd34d; }
.tr-badge.tr-waiting .dot { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.tr-badge.tr-active { background: rgba(59, 130, 246, 0.14); color: #93c5fd; }
.tr-badge.tr-active .dot { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.tr-badge.tr-seeding { background: rgba(46, 173, 32, 0.14); color: #8fe28a; }
.tr-badge.tr-seeding .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }

.add-torrent-form {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.job-progress-label {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.job-progress-bar {
  margin-top: 0.35rem;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.job-progress-fill {
  height: 100%;
  background: var(--accent-grad);
  transition: width 0.5s var(--ease);
}

.job-actions { display: flex; gap: 0.5rem; margin-left: auto; flex-shrink: 0; }

.job-detail {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-dim);
}

.job-file-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

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

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-faint);
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vh 1.5rem;
  background: rgba(4, 4, 6, 0.75);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-backdrop[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  padding: 1.75rem;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.modal-backdrop.open .modal-card { transform: translateY(0) scale(1); opacity: 1; }

.modal-card h2 { margin: 0 0 1.25rem; font-size: 1.2rem; }

.modal-card-wide { max-width: 640px; }

.release-title-full {
  font-size: 0.85rem;
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.4;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  margin: 1rem 0;
  padding: 0.9rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.info-item-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.info-item-value {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.15rem;
  word-break: break-word;
}

.score-breakdown-full {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  padding: 0 0.2rem;
}

.score-breakdown-full .score-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.score-breakdown-full .score-item-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
}

.score-breakdown-full .score-bar { width: 100%; height: 5px; }

.file-selection-summary {
  font-weight: 400;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
}

.file-picker-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.file-picker-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.file-picker-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.file-picker-row:last-child { border-bottom: none; }
.file-picker-row:hover { background: var(--surface-hover); }

.file-picker-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--red);
}

.file-picker-row-path {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker-row-path.is-video { color: var(--text); font-weight: 600; }
.file-picker-row-path.is-other { color: var(--text-faint); }

.file-picker-row-size {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.drive-picker { display: flex; gap: 0.6rem; }

.drive-option {
  flex: 1;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.drive-option.selected { border-color: var(--red); background: rgba(229, 9, 20, 0.08); }
.drive-option-name { font-weight: 700; font-size: 0.88rem; }
.drive-option-free { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.2rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* ==========================================================================
   Login page
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 2.25rem;
  text-align: center;
}

.login-card .brand { font-size: 1.6rem; display: block; margin-bottom: 0.3rem; }
.login-card p.subtitle { color: var(--text-faint); font-size: 0.85rem; margin: 0 0 1.75rem; }
.login-card form { text-align: left; }
.login-card .btn { width: 100%; margin-top: 0.5rem; }

/* ==========================================================================
   Misc
   ========================================================================== */
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.section-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-row input[type="text"] { flex: 1; }

@media (max-width: 720px) {
  .navbar-inner { padding: 0 1rem; gap: 1rem; }
  .disk-widget { display: none; }
  .result-card { flex-wrap: wrap; }
  .job-card-top { flex-wrap: wrap; }
  .job-actions { width: 100%; justify-content: flex-end; margin-left: 0; margin-top: 0.5rem; }
}
