/* ===== R2 Dashboard — Professional Theme (ala Streamwish / Streamtape) ===== */
:root {
  --bg: #0b0e16;
  --bg-2: #11151f;
  --panel: #141927;
  --panel-2: #1a2133;
  --border: #263048;
  --border-2: #334061;
  --text: #eef1f8;
  --muted: #8d99b5;
  --accent: #6d5ef2;
  --accent-2: #a78bfa;
  --accent-3: #7c3aed;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0,0,0,.45);
  --grad: linear-gradient(135deg, var(--accent), var(--accent-3));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Aturan WAJIB: jangan sampai dihapus — mencegah modal tampil saat load */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1000px 420px at 85% -10%, rgba(109,94,242,.16), transparent 60%),
    radial-gradient(800px 380px at -10% 0%, rgba(124,58,237,.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--accent-2); text-decoration: none; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #232c44; border-color: var(--border-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(109,94,242,.35); }
.btn-primary:hover { background: linear-gradient(135deg, #7d6ff5, #8b5cf6); }
.btn-danger { background: var(--red); border-color: transparent; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-lg { padding: 11px 20px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-icon { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 15px; border-radius: 10px; font-size: 13px; }
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); color: #fcd34d; }

.warnings { max-width: 1200px; margin: 18px auto 0; display: grid; gap: 8px; padding: 0 20px; }

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(109,94,242,.28), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px; background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: 18px; padding: 40px 34px;
  box-shadow: var(--shadow); text-align: center;
}
.login-logo {
  width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 16px;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; box-shadow: 0 8px 24px rgba(109,94,242,.4);
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 13px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; outline: none; transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }

/* ---------- Layout: sidebar + konten ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  flex: 0 0 240px; width: 240px;
  background: linear-gradient(180deg, var(--bg-2), #0d1120);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 60;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 700;
}
.side-brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-brand-name b { color: var(--accent-2); }
.side-brand .brand-ver { flex: 0 0 auto; }

.side-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 14px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border-radius: 10px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 600;
  text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 18px rgba(109,94,242,.4);
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.side-footer { padding: 14px 12px; border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  background: rgba(13,16,24,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.page-title { font-size: 19px; font-weight: 700; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; box-shadow: 0 4px 16px rgba(109,94,242,.4);
}
.brand-ver {
  font-size: 11px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-weight: 400;
}
.topbar-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; flex-wrap: wrap; }

/* ---------- Konten & view ---------- */
.content { padding: 24px 24px 48px; width: 100%; }
.view { display: none; }
.view.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.hero {
  background: linear-gradient(120deg, rgba(109,94,242,.2), rgba(124,58,237,.05)), var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 28px; margin-bottom: 20px;
}
.hero h2 { font-size: 20px; font-weight: 800; }
.hero p { color: var(--muted); margin-top: 6px; max-width: 600px; }

.panel-body { padding: 24px; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px; margin-bottom: 0;
}
.stat-card {
  display: flex; align-items: center; gap: 15px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; transition: border-color .15s, transform .15s;
}
.stat-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.stat-icon {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(109,94,242,.16); color: var(--accent-2);
  border: 1px solid rgba(109,94,242,.25);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-info { min-width: 0; }
.stat-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 27px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-bucket { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Panel & search ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.panel-head h2 { font-size: 18px; font-weight: 700; }
.panel-sub { color: var(--muted); font-size: 12.5px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.search-wrap input {
  width: 320px; padding: 11px 38px 11px 36px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,242,.18); }
.search-clear {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1;
}
.search-clear:hover { color: var(--text); }

/* ---------- Tabel video (lurus, tanpa thumbnail) ---------- */
.table-wrap { overflow-x: auto; }
.vtable { width: 100%; border-collapse: collapse; }
.vtable th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 12px 20px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.vtable td {
  padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.vtable tbody tr:last-child td { border-bottom: none; }
.vtable tbody tr { transition: background .12s; }
.vtable tbody tr:hover { background: var(--panel-2); }

.col-file { width: 55%; }
.col-size, .col-date { width: 15%; white-space: nowrap; }
.col-actions { width: 15%; text-align: right; }

.file-name {
  font-weight: 600; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.file-name { color: var(--accent-2); text-decoration: none; }
a.file-name:hover { color: #e9d5ff; text-decoration: underline; }
.badge-size { font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 18px; }

/* ---------- Pager ---------- */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.pager-info { color: var(--muted); font-size: 12.5px; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,7,12,.75); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal {
  width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.modal-sm { width: 420px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer;
  line-height: 1; transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

.field { margin-bottom: 17px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input, .field textarea {
  width: 100%; padding: 11px 13px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text);
  font-size: 13px; outline: none; font-family: inherit; transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed var(--border-2); border-radius: var(--radius);
  padding: 40px 22px; text-align: center; cursor: pointer; transition: all .16s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); background: rgba(109,94,242,.08);
}
.dz-icon { font-size: 32px; color: var(--accent-2); }
.dropzone p { margin-top: 8px; font-size: 14px; }
.dz-note { font-size: 12px; color: var(--muted) !important; }

.upload-progress { margin-top: 18px; }
.up-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px; }
.up-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 75%; }
.progress-bar { height: 9px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill {
  height: 100%; width: 0; background: var(--grad);
  border-radius: 99px; transition: width .2s;
}
.progress-fill.indet {
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2), var(--accent-3));
  background-size: 200% 100%;
  animation: r2indet 1.2s linear infinite;
  width: 100%;
}
@keyframes r2indet {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* ---------- Upload tabs (Desktop / Remote URL) ---------- */
.up-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.up-tab {
  background: transparent; border: none; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.up-tab:hover { color: var(--text); }
.up-tab.active { color: var(--accent-2); border-bottom-color: var(--accent-2); }

.remote-form { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 980px; }
.remote-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
@media (max-width: 760px) { .remote-cols { grid-template-columns: 1fr; } }
.remote-col { display: flex; flex-direction: column; gap: 7px; }
.remote-col label { font-size: 12px; color: var(--muted); }
.remote-form input, .remote-form textarea {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px; outline: none;
  font-family: inherit; resize: vertical; width: 100%;
}
.remote-form textarea { flex: 1; min-height: 130px; }
.remote-form input:focus, .remote-form textarea:focus { border-color: var(--accent); }
.remote-actions { display: flex; align-items: center; gap: 12px; }
.remote-actions .btn { align-self: flex-start; }

/* ---------- Local Folder Upload ---------- */
.local-form { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 980px; }
.local-actions { display: flex; align-items: center; gap: 12px; }
.local-list-wrap { border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); overflow: hidden; }
.local-list-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.local-check-all { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; user-select: none; }
.local-check-all input { width: 15px; height: 15px; accent-color: var(--accent); }
.local-list { max-height: 380px; overflow-y: auto; }
.local-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); transition: background .12s; cursor: pointer; }
.local-row:hover { background: var(--panel); }
.local-row:last-child { border-bottom: none; }
.local-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.local-row .lname { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.local-row .lsize { font-size: 12px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }

/* Multi progress bar (local folder) */
.local-bar-row { margin-bottom: 12px; }
.local-bar-row:last-child { margin-bottom: 0; }
.l-pct { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }
.progress-fill.l-active { background: linear-gradient(90deg, var(--accent), var(--accent-2)); animation: lbar-pulse 1.5s ease-in-out infinite; }
@keyframes lbar-pulse { 0%,100% { opacity:1; } 50% { opacity:.75; } }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: grid; gap: 9px; max-width: 360px;
}
.toast {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 15px; font-size: 13px;
  box-shadow: var(--shadow); animation: slidein .2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .side-brand { padding: 12px 14px; border-bottom: none; flex: 0 0 auto; }
  .side-nav { flex-direction: row; flex: 1; padding: 8px 10px; overflow: visible; }
  .nav-item { white-space: nowrap; }
  .side-footer { border-top: none; border-left: 1px solid var(--border); padding: 8px 10px; flex: 0 0 auto; }
  .search-wrap input { width: 100%; }
  .search-wrap { flex: 1 1 100%; }
  .col-size, .col-date { display: none; }
  .col-file { width: auto; }
  .actions { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .stat-value { font-size: 22px; }
  .page-title { font-size: 16px; }
}
