/* ==========================================================================
   TransitDrop — Gaya UI. Bersih, minimal, responsif (PC + HP), mendukung
   mode terang & gelap otomatis (prefers-color-scheme).
   ========================================================================== */

:root {
  --text: #2C2C2B;
  --text-2: #7D7A75;
  --canvas: #FFFFFF;
  --surface: #F9F8F7;
  --surface-2: #F0EFED;
  --border: #E6E5E3;
  --blue: #2783DE;
  --blue-soft: #E5F2FC;
  --green: #46A171;
  --green-soft: #E8F1EC;
  --orange: #D5803B;
  --orange-soft: #FBEBDE;
  --red: #E56458;
  --red-soft: #FCE9E7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #FFFFFF;
    --text-2: rgba(255,255,255,0.65);
    --canvas: #191919;
    --surface: #202020;
    --surface-2: #383836;
    --border: rgba(255,255,255,0.20);
    --blue: #5E9FE8;
    --blue-soft: rgba(94,159,232,0.12);
    --green: #72BC8F;
    --green-soft: rgba(114,188,143,0.12);
    --orange: #DE9255;
    --orange-soft: rgba(222,146,85,0.12);
    --red: #E97366;
    --red-soft: rgba(233,115,102,0.12);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* pastikan atribut hidden mengalahkan display flex */
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 12px; }
.muted { color: var(--text-2); font-size: 0.95rem; }
code {
  font-family: Menlo, Consolas, monospace;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ------------------------- Tombol ------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter .15s, background .15s, border-color .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { filter: brightness(0.94); }
.btn:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 40px; min-height: 40px;
  cursor: pointer;
  font-size: 1rem;
}
.icon-btn:hover { background: var(--surface-2); }

/* ------------------------- Field ------------------------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field input[type=text], .field input[type=password], .field input[type=number],
.field textarea, .field input[type=file] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--text);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

/* ------------------------- Login ------------------------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--surface);
}
.login-card {
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 1.8rem;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 1.5rem; }
.login-sub { color: var(--text-2); font-size: 0.95rem; margin-bottom: 24px; }
.login-card .field { text-align: left; }
.login-hint { font-size: 0.85rem; color: var(--text-2); text-align: left; margin: -8px 0 16px; }
.login-error {
  background: var(--red-soft); color: var(--red);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 0.9rem; margin-bottom: 16px; text-align: left;
}

/* ------------------------- App shell ------------------------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: var(--canvas);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--blue-soft); color: var(--blue);
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; min-width: 0; overflow: hidden; }
.crumb { color: var(--blue); text-decoration: none; white-space: nowrap; }
.crumb.current { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); display: inline-block; }
.dot.on { background: var(--green); }

.content { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px; }
.footer {
  text-align: center; color: var(--text-2); font-size: 0.85rem;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

.loading { color: var(--text-2); padding: 48px 0; text-align: center; }

/* ------------------------- Page head ------------------------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h2 { margin-bottom: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------- Empty state ------------------------- */
.empty {
  text-align: center; padding: 64px 24px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.empty-ic { font-size: 3rem; margin-bottom: 12px; }
.empty h3 { margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* ------------------------- Folder grid ------------------------- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.folder-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--canvas); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s;
}
.folder-card:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.folder-main { display: flex; gap: 12px; padding: 16px; text-decoration: none; color: inherit; }
.folder-ic { font-size: 1.8rem; }
.folder-info { min-width: 0; flex: 1; }
.folder-name { font-weight: 700; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-desc { font-size: 0.9rem; color: var(--text-2); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.folder-meta { display: flex; gap: 8px; font-size: 0.85rem; color: var(--text-2); }
.folder-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface);
}
.folder-actions { display: flex; gap: 6px; }

/* ------------------------- Badge / tags ------------------------- */
.badge {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--orange-soft); color: var(--orange); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }
.origin { font-size: 0.8rem; color: var(--text-2); white-space: nowrap; }

/* ------------------------- Stats row ------------------------- */
.stat-row {
  display: flex; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 24px;
}
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 100px; }
.stat-label { font-size: 0.8rem; color: var(--text-2); }
.stat-val { font-weight: 700; font-size: 1.1rem; }
.view-toggle-wrap { margin-left: auto; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.vt-btn {
  font: inherit; font-size: 0.85rem; font-weight: 600;
  border: none; background: var(--canvas); color: var(--text-2);
  padding: 8px 12px; cursor: pointer; min-height: 40px;
}
.vt-btn.active { background: var(--blue); color: #fff; }

/* ------------------------- Section title (subfolder / file) ------------- */
.section-title { font-size: 0.95rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }
.empty.small { padding: 24px; text-align: left; }
.row-desc { font-size: 0.82rem; color: var(--text-2); margin-top: 2px; }
.row-link { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
.row-link:hover .row-name { color: var(--blue); }
.c-count { color: var(--text-2); font-size: 0.9rem; }

/* ------------------------- Thumbnail / pratinjau ------------------------- */
.file-thumb {
  width: 100%; height: 120px; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb.sm { width: 40px; height: 40px; flex: 0 0 40px; }
.file-ic.sm { font-size: 1.4rem; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.row-thumb { display: inline-flex; vertical-align: middle; margin-right: 8px; }

/* ------------------------- File grid ------------------------- */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.file-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; background: var(--canvas);
  display: flex; flex-direction: column; gap: 8px;
}
.file-card.is-done { background: var(--green-soft); border-color: var(--green); }
.file-ic { font-size: 2.4rem; }
.file-name { font-weight: 600; font-size: 0.9rem; word-break: break-word; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.file-sub { font-size: 0.8rem; color: var(--text-2); }
.file-badge { margin: 2px 0; }
.file-actions { display: flex; gap: 6px; justify-content: center; margin-top: auto; }

/* ------------------------- File table (list) ------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.file-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.file-table th, .file-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.file-table thead th { background: var(--surface); font-size: 0.8rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }
.file-table tbody tr:last-child td { border-bottom: none; }
.file-table tr.is-done { background: var(--green-soft); }
.row-ic { margin-right: 6px; }
.row-name { font-weight: 600; }
.c-name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.c-act { text-align: right; }

/* ------------------------- Overlay / modal ------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.overlay-card {
  background: var(--canvas); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 600; }
.switch-row input { width: 20px; height: 20px; }

/* segmented control (asal transfer) */
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn {
  flex: 1; font: inherit; font-weight: 600; font-size: 0.9rem;
  border: none; background: var(--canvas); color: var(--text-2);
  padding: 10px; cursor: pointer; min-height: 44px;
}
.seg-btn.active { background: var(--blue); color: #fff; }

/* progress */
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progress-bar { height: 100%; width: 0; background: var(--blue); transition: width .1s linear; }

/* verifikasi & kotak pesan */
.verify-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.verify-table th, .verify-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.92rem; }
.verify-table th { color: var(--text-2); font-size: 0.8rem; }
.verify-table td.good { color: var(--green); font-weight: 700; }
.verify-table td.bad { color: var(--red); font-weight: 700; }
.warn-box { background: var(--orange-soft); color: var(--orange); border-radius: var(--radius-sm); padding: 12px; font-size: 0.9rem; margin: 8px 0; }
.ok-box { background: var(--green-soft); color: var(--green); border-radius: var(--radius-sm); padding: 12px; font-size: 0.9rem; margin: 8px 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--canvas);
  padding: 12px 20px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow); z-index: 200; opacity: 0;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: var(--orange); color: #fff; }

/* ------------------------- Responsif (HP) ------------------------- */
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .brand span:not(.brand-mark) { display: none; }
  .content { padding: 20px 16px; }
  .page-head { flex-direction: column; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .view-toggle-wrap { margin-left: 0; width: 100%; }
  .stat-row { gap: 16px; }
  .stat { min-width: 45%; }
  .btn { padding: 10px 12px; }
}

/* ===== Daftar Transfer & progres realtime ===== */
.progress.sm { height: 8px; }
.tcount { display:inline-flex; min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:#E56458; color:#fff; font-size:11px; font-weight:700; align-items:center; justify-content:center; margin-left:4px; }
.tr-list { display:flex; flex-direction:column; gap:12px; }
.tr-item { display:flex; gap:12px; align-items:flex-start; padding:14px 16px; border:1px solid rgba(44,44,43,0.12); border-radius:12px; background:rgba(255,255,255,0.02); }
.tr-ic { font-size:22px; line-height:1; }
.tr-body { flex:1; min-width:0; }
.tr-top { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:6px; }
.tr-name { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tr-badge { font-size:12px; padding:2px 8px; border-radius:999px; white-space:nowrap; }
.tr-badge.active { background:rgba(39,131,222,0.15); color:#2783DE; }
.tr-badge.ok { background:rgba(70,161,113,0.15); color:#46A171; }
.tr-badge.err { background:rgba(229,100,88,0.15); color:#E56458; }
.tr-badge.warn { background:rgba(213,128,59,0.15); color:#D5803B; }
.tr-meta { font-size:12px; opacity:0.75; margin-top:6px; }
.progress-sub { font-size:13px; opacity:0.75; margin:4px 0 0; min-height:16px; }
.overlay-actions { margin-top:14px; display:flex; justify-content:flex-end; }

/* ===== Tombol navigasi (Beranda & Kembali) ===== */
.nav-btns { display:inline-flex; gap:8px; align-items:center; }
.btn-nav { white-space:nowrap; }
@media (max-width: 560px) {
  .topbar-left { flex-wrap:wrap; gap:8px 10px; }
  .nav-btns { order:3; }
  .crumbs { order:4; width:100%; }
}

/* ===== Kontrol transfer (Pause/Stop/Cancel/Retry) ===== */
.btn-xs { min-height: 30px; padding: 4px 9px; font-size: 0.8rem; border-radius: 8px; }
.tr-ctl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ===== Rapikan tampilan HP: grid 2 kolom + tombol kecil ===== */
@media (max-width: 640px) {
  .folder-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .file-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .folder-main { gap: 8px; padding: 12px; }
  .folder-ic { font-size: 1.4rem; }
  .folder-name { font-size: 0.9rem; }
  .folder-desc { font-size: 0.8rem; -webkit-line-clamp: 1; margin-bottom: 4px; }
  .folder-meta { font-size: 0.75rem; gap: 6px; flex-wrap: wrap; }
  .folder-foot { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .folder-actions { gap: 6px; flex-wrap: wrap; }
  .file-card { padding: 10px; gap: 6px; }
  .file-thumb { height: 84px; }
  .file-ic { font-size: 1.8rem; }
  .file-name { font-size: 0.82rem; }
  .file-sub { font-size: 0.72rem; }
  .file-actions { gap: 6px; flex-wrap: wrap; }
  .badge { font-size: 0.68rem; padding: 2px 7px; }
  .btn { padding: 8px 10px; font-size: 0.85rem; }
  .btn-sm { min-height: 34px; padding: 6px 9px; font-size: 0.8rem; }
  .btn-xs { min-height: 30px; padding: 4px 8px; font-size: 0.76rem; }
  .icon-btn { width: 36px; height: 36px; }
  .head-actions { gap: 6px; }
  .tr-item { padding: 12px; gap: 10px; }
  .tr-ctl { gap: 6px; }
  .tr-ctl .btn { flex: 1 1 auto; }
}

/* Layar sangat sempit: kartu tetap 2 kolom, teks lebih ringkas */
@media (max-width: 380px) {
  .folder-grid, .file-grid { gap: 8px; }
  .file-thumb { height: 72px; }
}
