/* ============ Gerenciador de vídeos — design system ============ */
:root {
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e5e5e0;
  --grid: #ecece8;
  --brand: #2a78d6;
  --brand-dark: #1c5cab;
  --brand-wash: #eaf2fc;
  --good: #0ca30c;
  --good-text: #006300;
  --warn: #b97900;
  --danger: #d03b3b;
  --danger-wash: #fdeeee;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 4px 16px rgba(11,11,11,.06);
  --shadow-lg: 0 8px 40px rgba(11,11,11,.18);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; font-size: inherit; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }
svg.lucide { width: 20px; height: 20px; flex: none; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: 230px; flex: none; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 16px 12px;
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 6px 10px 18px; }
.brand svg.lucide { color: var(--brand); width: 26px; height: 26px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none;
  font-weight: 600; border: none; background: none; cursor: pointer; width: 100%;
  transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-wash); color: var(--brand-dark); }
.nav-item svg.lucide { width: 22px; height: 22px; }
.sidebar .spacer { flex: 1; }
.main { flex: 1; min-width: 0; padding: 24px clamp(14px, 3vw, 36px) 96px; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; }

/* mobile */
.topbar { display: none; }
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-105%); transition: transform .22s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 14px;
  }
  .topbar .brand { padding: 0; font-size: 15px; }
  .main { padding: 16px 12px 120px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 650; cursor: pointer;
  transition: filter .12s, background .12s, transform .05s; text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.92); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.icon-only { padding: 10px; min-width: 44px; }
.btn .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards / tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.tile .t-label { color: var(--muted); font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.tile .t-label svg.lucide { width: 16px; height: 16px; }
.tile .t-value { font-size: 26px; font-weight: 700; }
.tile .t-sub { color: var(--ink-2); font-size: 13px; }

.hero-card {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 22px 24px; margin-bottom: 18px;
  background: linear-gradient(120deg, #fff 30%, var(--brand-wash));
}
.hero-card .h-label { color: var(--ink-2); font-weight: 650; }
.hero-card .h-value { font-size: 44px; font-weight: 750; line-height: 1.05; }
.hero-card .h-side { flex: 1; min-width: 200px; }
.hero-card .h-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart-card h3 { margin: 0 0 2px; font-size: 15px; }
.chart-card .c-sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  padding: 7px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .1s;
  z-index: 5;
}
.chart-tip b { font-weight: 700; }

/* ---------- explorer ---------- */
.explorer { display: flex; gap: 0; border-radius: var(--radius); overflow: hidden; min-height: 65dvh; }
.tree-pane {
  width: 250px; flex: none; border-right: 1px solid var(--line);
  padding: 12px 8px; overflow: auto; background: var(--surface-2);
}
.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 8px 8px; border-radius: 8px;
  cursor: pointer; color: var(--ink-2); font-weight: 550; font-size: 14px;
  border: 2px solid transparent;
}
.tree-row:hover { background: rgba(11,11,11,.05); }
.tree-row.active { background: var(--brand-wash); color: var(--brand-dark); }
.tree-row.droptarget { border-color: var(--brand); background: var(--brand-wash); }
.tree-row .twisty { width: 18px; height: 18px; flex: none; display: grid; place-items: center; border-radius: 4px; }
.tree-row .twisty:hover { background: rgba(11,11,11,.08); }
.tree-row .twisty svg.lucide { width: 15px; height: 15px; transition: transform .12s; }
.tree-row.expanded .twisty svg.lucide { transform: rotate(90deg); }
.tree-row svg.lucide.folder-ic { width: 17px; height: 17px; color: #eda100; }
.tree-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-kids { margin-left: 16px; }

.files-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crumbs { display: flex; align-items: center; gap: 2px; padding: 12px 16px 0; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 4px; padding: 6px 9px; border-radius: 8px; border: 2px solid transparent; background: none; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 14px; }
.crumb:hover { background: var(--surface-2); }
.crumb.here { color: var(--ink); }
.crumb.droptarget { border-color: var(--brand); background: var(--brand-wash); }
.crumb-sep { color: var(--muted); }
.files-toolbar { display: flex; gap: 8px; padding: 10px 16px; flex-wrap: wrap; align-items: center; }
.files-toolbar .search { flex: 1; min-width: 160px; position: relative; }
.files-toolbar .search input { width: 100%; padding: 10px 12px 10px 38px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface-2); min-height: 44px; }
.files-toolbar .search svg.lucide { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }

.files-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px; padding: 8px 16px 20px; align-content: start; flex: 1;
}
.f-item {
  border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
  overflow: hidden; cursor: pointer; position: relative; transition: border-color .12s, box-shadow .12s;
}
.f-item:hover { box-shadow: var(--shadow); }
.f-item.selected { border-color: var(--brand); background: var(--brand-wash); }
.f-item.droptarget { border-color: var(--brand); background: var(--brand-wash); }
.f-item.dragging { opacity: .45; }
.f-item.busy { pointer-events: none; opacity: .6; }
.f-folder { display: flex; align-items: center; gap: 10px; padding: 14px 12px; }
.f-folder svg.lucide { width: 30px; height: 30px; color: #eda100; flex: none; }
.f-folder .name { font-weight: 650; font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.f-folder .meta { color: var(--muted); font-size: 12px; }
.f-thumb { aspect-ratio: 16/9; background: #dfe3e8 center/cover no-repeat; position: relative; }
.f-thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.75); color: #fff; font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; }
.f-thumb .status-chip { position: absolute; left: 6px; top: 6px; }
.f-thumb .play-ov { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .12s; background: rgba(0,0,0,.25); }
.f-item:hover .play-ov { opacity: 1; }
.play-ov .play-btn { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.95); display: grid; place-items: center; border: none; cursor: pointer; }
.play-ov .play-btn svg.lucide { color: var(--ink); margin-left: 2px; }
.f-body { padding: 9px 10px; }
.f-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.f-meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; margin-top: 4px; }
.f-check {
  position: absolute; left: 8px; top: 8px; z-index: 3; width: 24px; height: 24px;
  border-radius: 7px; border: 2px solid #fff; background: rgba(255,255,255,.85);
  display: grid; place-items: center; opacity: 0; transition: opacity .1s; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.f-check svg.lucide { width: 15px; height: 15px; color: #fff; display: none; }
.f-item:hover .f-check, .f-item.selected .f-check, .files-grid.selecting .f-check { opacity: 1; }
.f-item.selected .f-check { background: var(--brand); border-color: var(--brand); }
.f-item.selected .f-check svg.lucide { display: block; }
.f-menu-btn {
  position: absolute; right: 6px; top: 6px; z-index: 3; width: 30px; height: 30px; border-radius: 8px;
  border: none; background: rgba(255,255,255,.92); display: grid; place-items: center; cursor: pointer;
  opacity: 0; transition: opacity .1s; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.f-item:hover .f-menu-btn { opacity: 1; }
.f-menu-btn svg.lucide { width: 17px; height: 17px; }
.folder-menu-btn { position: static; opacity: 1; box-shadow: none; background: none; margin-left: auto; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; grid-column: 1/-1; }
.empty-state svg.lucide { width: 44px; height: 44px; margin-bottom: 8px; color: var(--line); }

.sel-bar {
  position: sticky; bottom: 12px; z-index: 20; margin: 0 16px 12px;
  display: flex; gap: 10px; align-items: center; padding: 10px 16px;
  background: var(--ink); color: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.sel-bar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; min-height: 38px; padding: 8px 14px; }
.sel-bar .btn:hover { background: rgba(255,255,255,.22); }

/* context menu */
.ctx-menu {
  position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); box-shadow: var(--shadow-lg); padding: 6px; min-width: 190px;
}
.ctx-menu button {
  display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px;
  border: none; background: none; border-radius: 8px; cursor: pointer; font-weight: 550; color: var(--ink);
}
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button svg.lucide { width: 17px; height: 17px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 650; font-size: 13.5px; color: var(--ink-2); }
.field input, .field select {
  padding: 11px 13px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface); min-height: 46px; width: 100%;
}
.field input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.field .hint { color: var(--muted); font-size: 12.5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- modal ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(11,11,11,.45); z-index: 70; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; max-height: 90dvh; display: flex; flex-direction: column;
  animation: pop .18s;
}
.modal.wide { max-width: 640px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.modal-head h2 { font-size: 17px; margin: 0; flex: 1; }
.modal-head svg.lucide { color: var(--brand); }
.modal-head.danger svg.lucide { color: var(--danger); }
.modal-body { padding: 14px 20px; overflow: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 4px 20px 18px; flex-wrap: wrap; }
.modal-foot .btn { flex: none; }
@media (max-width: 520px) { .modal-foot .btn { flex: 1; } }

/* player modal */
.player-modal { max-width: 900px; background: #000; }
.player-modal .ratio { aspect-ratio: 16/9; }
.player-modal iframe { width: 100%; height: 100%; border: 0; display: block; border-radius: var(--radius); }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 14px; right: 14px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 380px); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 13px 15px;
  background: var(--ink); color: #fff; border-radius: var(--radius-s); box-shadow: var(--shadow-lg);
  font-weight: 550; animation: slidein .2s; font-size: 14px;
}
@keyframes slidein { from { transform: translateY(-8px); opacity: 0; } }
.toast svg.lucide { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.toast.ok svg.lucide { color: #5ad45a; }
.toast.err { background: var(--danger); }
.toast.info svg.lucide { color: #86b6ef; }

/* ---------- upload dock ---------- */
.updock {
  position: fixed; right: 14px; bottom: 14px; z-index: 65; width: min(94vw, 380px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.updock-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ink); color: #fff; font-weight: 650; cursor: pointer; }
.updock-head .count { background: var(--brand); border-radius: 999px; padding: 1px 9px; font-size: 12.5px; }
.updock-head svg.lucide { width: 18px; height: 18px; }
.updock-body { max-height: 46dvh; overflow: auto; }
.up-item { padding: 12px 14px; border-top: 1px solid var(--line); }
.up-item .u-row { display: flex; gap: 10px; align-items: center; }
.up-item .u-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .u-stat { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 10px; }
.up-item .u-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.up-item .u-btn:hover { background: var(--surface-2); }
.up-item .u-btn svg.lucide { width: 16px; height: 16px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.progress.done > div { background: var(--good); }
.progress.paused > div { background: var(--warn); }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; }
.chip svg.lucide { width: 13px; height: 13px; }
.chip.ok { background: #e4f6e4; color: var(--good-text); }
.chip.warn { background: #fdf3dd; color: var(--warn); }
.chip.err { background: var(--danger-wash); color: var(--danger); }
.chip.info { background: var(--brand-wash); color: var(--brand-dark); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--muted); font-size: 12.5px; font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 18px; background: linear-gradient(160deg, var(--page), var(--brand-wash)); }
.login-card { width: 100%; max-width: 390px; padding: 30px 28px; }
.login-card .brand { justify-content: center; padding-bottom: 8px; font-size: 19px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; }

/* ---------- skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, #eef0f3 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-s); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.mt { margin-top: 16px; }
.hidden { display: none !important; }
.admin-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.lib-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.lib-card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.lib-card h3 svg.lucide { color: var(--brand); }
.lib-card .lc-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 13.5px; }
.lib-card .lc-meta b { font-size: 15px; }
.lib-card .lc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.dragghost {
  position: fixed; z-index: 999; pointer-events: none; background: var(--ink); color: #fff;
  padding: 8px 14px; border-radius: 10px; font-weight: 650; font-size: 13.5px;
  box-shadow: var(--shadow-lg); display: flex; gap: 8px; align-items: center;
}

@media (max-width: 700px) {
  .explorer { flex-direction: column; min-height: 0; }
  .tree-pane { display: none; }
  .files-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 8px 10px 16px; }
  .hero-card .h-value { font-size: 34px; }
}
