/* ==================================================================
   TorBox Manager — visual system
   A calm, modern "media console": deep charcoal canvas, a single
   indigo→violet accent, soft elevation, restrained motion.
   ================================================================== */
:root {
  --bg: #0a0c10;
  --bg-glow: #141a2e;
  --surface: #12161d;
  --surface-2: #171c26;
  --surface-3: #1d2430;
  --border: #262d3a;
  --border-soft: #1e2530;
  --text: #eef2f7;
  --muted: #9aa4b2;
  --faint: #6b7484;

  --accent: #7c83ff;
  --accent-2: #b06bf5;
  --accent-grad: linear-gradient(135deg, #7c83ff 0%, #b06bf5 100%);
  --accent-soft: rgba(124, 131, 255, 0.14);

  --green: #43c463;
  --amber: #e0a637;
  --red: #fb5a4c;
  --blue: #5aa9ff;
  --violet: #cf9bff;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --ring: 0 0 0 3px var(--accent-soft);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100vh;
  background-image: radial-gradient(900px 500px at 50% -8%, var(--bg-glow) 0%, rgba(20, 26, 46, 0) 65%);
  background-attachment: fixed;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); }

::selection { background: var(--accent-soft); }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 15px;
  transition: transform .12s ease, background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
button:hover { background: var(--surface-3); border-color: #333c4d; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary {
  background: var(--accent-grad);
  border: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(124, 131, 255, 0.28);
}
button.primary:hover { filter: brightness(1.07); box-shadow: 0 6px 20px rgba(124, 131, 255, 0.36); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.small { padding: 6px 11px; font-size: 12px; }
button.danger { color: var(--red); border-color: transparent; background: transparent; }
button.danger:hover { background: rgba(251, 90, 76, 0.12); border-color: transparent; }

/* ---------- Inputs ---------- */
input, textarea, select {
  font-family: inherit; font-size: 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 42px; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 560px at 50% -6%, #1b2340 0%, var(--bg) 62%);
  padding: 20px;
}
.gate-card {
  background: linear-gradient(180deg, var(--surface) 0%, #0f131a 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px;
  width: 100%; max-width: 430px;
  animation: rise .35s ease both;
}
.gate-card h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -0.02em; }
.gate .field { position: relative; display: flex; gap: 8px; margin: 20px 0 12px; }
.gate .field input { padding-right: 44px; }
.gate #gate-toggle { position: absolute; right: 5px; top: 5px; border: none; background: transparent; }
.gate .primary { width: 100%; padding: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(12, 15, 21, 0.82);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-weight: 700; font-size: 15.5px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
}
.brand .logo {
  width: 26px; height: 26px; border-radius: 8px; display: block;
  box-shadow: 0 3px 10px rgba(124, 131, 255, 0.4);
}
.brand span.name { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.account { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 4px 12px; font-size: 12px; color: var(--muted);
}
.chip b { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { width: auto; accent-color: var(--accent); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 2px;
  padding: 14px 22px 0;
  border-bottom: 1px solid var(--border-soft);
}
.tab {
  border: none; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 13.5px;
  padding: 9px 15px; border-radius: 9px 9px 0 0;
  position: relative; margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px;
  background: var(--accent-grad); border-radius: 2px;
}
.tab .count {
  background: var(--surface-3); color: var(--muted);
  border-radius: 999px; padding: 1px 8px; font-size: 11px; margin-left: 7px; font-weight: 600;
}
.tab.active .count { background: var(--accent-soft); color: var(--violet); }

/* ---------- Add panel + toolbar ---------- */
.add-panel { padding: 20px 22px 6px; }
.add-form { display: flex; flex-direction: column; gap: 12px; animation: fade .25s ease both; }
.add-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.filebtn {
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 9px 15px; font-size: 13px; color: var(--muted); cursor: pointer; transition: .15s;
}
.filebtn:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

.search-row { display: flex; gap: 10px; }
.search-row #search-input { flex: 1; font-size: 15px; padding: 12px 15px; }
.search-row button { white-space: nowrap; padding-left: 22px; padding-right: 22px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: center;
  padding: 12px 14px; margin-top: 2px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
}
.filter-group { display: flex; align-items: center; gap: 11px; font-size: 13px; color: var(--muted); }
.filter-group label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.filter-group input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.filter-label { font-weight: 600; color: var(--text); }
.mini-num { width: 66px; padding: 6px 9px; }
.bulkbar { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.bulkbar .hint { font-size: 12px; color: var(--faint); }

.toolbar { display: flex; gap: 12px; padding: 16px 22px 6px; }
.toolbar #search { flex: 1; }
.toolbar select { width: auto; }

/* ---------- Lists ---------- */
main { padding: 14px 22px 72px; }
.list { display: none; flex-direction: column; gap: 11px; }
.list.active { display: flex; }

.card {
  background: linear-gradient(180deg, var(--surface) 0%, #10141b 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px 17px;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.card:hover { border-color: #2f3849; box-shadow: var(--shadow-sm); }
.card-top { display: flex; align-items: flex-start; gap: 13px; }
.card-name { font-weight: 600; font-size: 14.5px; word-break: break-word; flex: 1; letter-spacing: -0.01em; }
.card-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 7px; font-size: 12px; color: var(--muted); }
.card-meta b { color: var(--text); font-weight: 600; }
.card-actions { display: flex; gap: 7px; flex-shrink: 0; }

.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; letter-spacing: 0.01em; }
.badge.done { background: rgba(67, 196, 99, 0.15); color: var(--green); }
.badge.active { background: rgba(90, 169, 255, 0.15); color: var(--blue); }
.badge.warn { background: rgba(224, 166, 55, 0.15); color: var(--amber); }
.badge.err { background: rgba(251, 90, 76, 0.15); color: var(--red); }

.progress { height: 6px; background: var(--surface-3); border-radius: 999px; margin-top: 12px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-grad); border-radius: 999px; transition: width .5s ease; }
.progress.done > span { background: var(--green); }

.empty {
  text-align: center; color: var(--muted);
  padding: 64px 24px; font-size: 14px;
  border: 1px dashed var(--border-soft); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.01);
}

/* ---------- Search result badges ---------- */
.result-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--muted);
}
.tag.res { color: var(--text); }
.tag.res.uhd { color: var(--violet); border-color: rgba(207, 155, 255, 0.4); background: rgba(207, 155, 255, 0.08); }
.tag.res.fhd { color: var(--blue); border-color: rgba(90, 169, 255, 0.35); }
.tag.cached { color: var(--green); border-color: rgba(67, 196, 99, 0.5); background: rgba(67, 196, 99, 0.08); }
.tag.seed { color: var(--green); }
.tag.junk { color: var(--red); border-color: rgba(251, 90, 76, 0.5); }
.tag.src { color: var(--amber); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 8, 12, 0.66);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .18s ease both;
}
.modal-card {
  background: linear-gradient(180deg, var(--surface) 0%, #0f131a 100%);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 620px; max-height: 82vh; display: flex; flex-direction: column;
  animation: rise .22s ease both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 21px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.modal-actions { padding: 13px 21px; border-bottom: 1px solid var(--border-soft); }
.modal-files { overflow-y: auto; padding: 8px 21px 21px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.file-row:last-child { border-bottom: none; }
.file-name { flex: 1; word-break: break-word; font-size: 13px; }
.file-size { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 12px 20px; border-radius: 11px; z-index: 120; max-width: 90vw; font-size: 13.5px;
  animation: toastin .25s ease both;
}
.toast.err { border-color: rgba(251, 90, 76, 0.6); }
.toast.ok { border-color: rgba(67, 196, 99, 0.6); }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; }
  .account { order: 3; width: 100%; }
  .card-top { flex-direction: column; }
  .card-actions { width: 100%; }
  .search-row { flex-direction: column; }
  .filters { gap: 12px 18px; }
}
