/* ============================================================
   TV Sim Player — painel "master control"
   ============================================================ */

:root {
  --green: #1ac984;
  --green-soft: rgba(26, 201, 132, 0.14);
  --bg: #0b0e0c;
  --panel: #111512;
  --panel-2: #161b17;
  --line: rgba(240, 244, 241, 0.09);
  --text: #eef2ef;
  --muted: rgba(238, 242, 239, 0.55);
  --amber: #e8b332;
  --red: #e85555;
  --font: 'Archivo', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(26, 201, 132, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

em { font-style: normal; color: var(--green); }

.mark-tri {
  display: inline-block;
  width: 0; height: 0;
  border-left: 16px solid var(--green);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  filter: drop-shadow(0 0 10px rgba(26, 201, 132, 0.5));
}
.mark-tri.small { border-left-width: 11px; border-top-width: 7px; border-bottom-width: 7px; }

/* ---------------- botões ---------------- */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(240, 244, 241, 0.22); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #05130c;
}
.btn.primary:hover { background: #22de95; border-color: #22de95; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(232, 85, 85, 0.4); color: var(--red); background: transparent; }
.btn.danger:hover { background: rgba(232, 85, 85, 0.08); }
.btn.sm { padding: 7px 12px; font-size: 12px; }
.linklike {
  background: none; border: 0; color: var(--green);
  font: inherit; cursor: pointer; text-decoration: underline;
}

input[type="text"], input[type="search"], input[type="password"], select {
  font-family: var(--font);
  font-size: 13.5px;
  background: #0d110e;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  border-color: rgba(26, 201, 132, 0.5);
  box-shadow: 0 0 0 3px rgba(26, 201, 132, 0.12);
}

/* ---------------- login ---------------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 38px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.login-mark { display: flex; justify-content: center; margin-bottom: 2px; }
.login h1 { font-size: 19px; letter-spacing: 0.24em; font-weight: 800; }
.login-sub { font-size: 11.5px; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 10px; }
.login-err { color: var(--red); font-size: 12.5px; }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 12, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.22em;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.top-search { flex: 1; max-width: 420px; }
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.stat { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------- dropzone ---------------- */
.dropzone {
  margin: 20px clamp(16px, 3vw, 32px) 0;
  border: 1.5px dashed rgba(26, 201, 132, 0.35);
  border-radius: 16px;
  background: rgba(26, 201, 132, 0.04);
  padding: 30px;
  transition: background 0.15s, border-color 0.15s;
}
.dropzone.dragover {
  background: rgba(26, 201, 132, 0.1);
  border-color: var(--green);
}
.drop-inner { text-align: center; }
.drop-title { font-size: 16px; font-weight: 700; }
.drop-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.drop-form {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drop-form label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; font-weight: 600; letter-spacing: 0.04em; }
.drop-file {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  background: #0d110e;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drop-actions { display: flex; justify-content: flex-end; gap: 10px; }
.progress { display: flex; align-items: center; gap: 12px; }
.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(240, 244, 241, 0.1);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar div {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.2s;
  box-shadow: 0 0 12px rgba(26, 201, 132, 0.5);
}
.progress span { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 40px; text-align: right; }

/* ---------------- biblioteca ---------------- */
.library { padding: 24px clamp(16px, 3vw, 32px) 60px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  border-color: rgba(26, 201, 132, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}
.card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05130c center/cover no-repeat;
}
.card-thumb.noposter {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(26, 201, 132, 0.3);
  font-size: 30px;
}
.card-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(4, 6, 5, 0.85);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
}
.card-progressbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(240, 244, 241, 0.12);
}
.card-progressbar div { height: 100%; background: var(--amber); transition: width 0.4s; }
.card-body { padding: 12px 14px 13px; }
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}
.card-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  font-size: 10.5px;
  color: var(--muted);
}
.card-id { font-family: var(--mono); }

.badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.ready { color: var(--green); background: var(--green-soft); }
.badge.processing { color: var(--amber); background: rgba(232, 179, 50, 0.13); animation: pulse 1.6s ease-in-out infinite; }
.badge.queued { color: var(--muted); background: rgba(240, 244, 241, 0.08); }
.badge.error { color: var(--red); background: rgba(232, 85, 85, 0.12); }
.badge.vis { color: var(--muted); background: rgba(240, 244, 241, 0.07); }
@keyframes pulse { 50% { opacity: 0.45; } }

.empty { text-align: center; padding: 90px 20px; color: var(--muted); }
.empty p:first-child { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty code { font-family: var(--mono); font-size: 12px; color: var(--green); }

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 4, 0.75);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px;
  overflow-y: auto;
}
.modal {
  width: min(980px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-body {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0;
}
@media (max-width: 780px) { .modal-body { grid-template-columns: 1fr; } }
.m-player { position: relative; background: #060807; }
.m-player iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.m-processing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: #060807;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 13px;
}
.m-info { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 12px; border-left: 1px solid var(--line); }
@media (max-width: 780px) { .m-info { border-left: 0; border-top: 1px solid var(--line); } }
.m-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.8; }
.m-meta b { color: var(--text); font-weight: 600; }
.m-field { font-size: 11.5px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 5px; letter-spacing: 0.04em; }

.m-links { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.m-links-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 6px 0 2px;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.link-row .link-label { font-size: 11px; color: var(--muted); width: 52px; flex: none; font-weight: 600; }
.link-row input {
  font-family: var(--mono);
  font-size: 11px;
  padding: 7px 9px;
  color: rgba(238, 242, 239, 0.8);
}
.link-row button { flex: none; }

.m-token-row { display: flex; gap: 8px; align-items: center; }
.m-token-row select { width: auto; flex: 1; }

.m-danger {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--panel-2);
  border: 1px solid rgba(26, 201, 132, 0.4);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(232, 85, 85, 0.5); }
