/* ================= RESET ================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px; color: #333; background: #fff;
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ================= LOGIN ================= */
.login-body {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #2c3e50, #1a252f); overflow: auto;
}
.login-card {
  background: #fff; padding: 36px 32px; border-radius: 6px; width: 320px; max-width: 92vw;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 19px; margin: 8px 0 4px; font-weight: 600; }
.login-sub { margin: 0 0 20px; color: #888; font-size: 12px; }
.login-card input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid #ccd3d9; border-radius: 3px;
}
.login-card input:focus { outline: 2px solid #1997c6; outline-offset: -1px; border-color: #1997c6; }
.login-card button {
  width: 100%; padding: 10px; background: #1997c6; color: #fff;
  border: 0; border-radius: 3px; cursor: pointer; font-weight: 600; margin-top: 6px;
}
.login-card button:hover { background: #1580a8; }
.login-err {
  background: #fdecea; color: #a33; border: 1px solid #f5c6c2;
  padding: 8px; border-radius: 3px; margin-bottom: 12px; font-size: 12px;
}

/* ================= TOPBAR ================= */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #2c3e50; color: #fff; padding: 0 14px; height: 42px; flex: 0 0 auto;
}
.brand { font-weight: 600; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.acting { font-size: 12px; color: #b8c6d1; display: flex; align-items: center; gap: 6px; }
.acting select {
  background: #22303d; color: #fff; border: 1px solid #43596d;
  border-radius: 3px; padding: 4px 6px;
}
.logout { color: #b8c6d1; text-decoration: none; font-size: 12px; }
.logout:hover { color: #fff; text-decoration: underline; }

/* ================= ACTION BAR ================= */
.actionbar {
  display: flex; align-items: center; gap: 2px; flex: 0 0 auto;
  background: #f4f6f8; border-bottom: 1px solid #d6dde3;
  padding: 5px 8px; overflow-x: auto; white-space: nowrap;
}
.ab {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  padding: 5px 9px; cursor: pointer; color: #445; white-space: nowrap;
}
.ab:hover { background: #e4eaef; border-color: #cfd8df; }
.ab:active { background: #d7e0e7; }
.ab[disabled] { opacity: .38; cursor: default; }
.ab[disabled]:hover { background: transparent; border-color: transparent; }
.ab i { font-style: normal; font-size: 14px; }
.ab-sep { width: 1px; height: 22px; background: #d6dde3; margin: 0 6px; flex: 0 0 auto; }
.ab-spacer { flex: 1 1 auto; }
.searchbox { display: flex; gap: 4px; }
.searchbox input {
  border: 1px solid #ccd3d9; border-radius: 3px; padding: 5px 8px; width: 190px;
}
.searchbox button {
  border: 1px solid #ccd3d9; background: #fff; border-radius: 3px;
  padding: 5px 10px; cursor: pointer;
}
.searchbox button:hover { background: #eef2f5; }
.chk { display: flex; align-items: center; gap: 5px; color: #667; margin-left: 12px; }

/* ================= BREADCRUMB ================= */
.crumbbar {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
  padding: 6px 10px; background: #fff; border-bottom: 1px solid #e2e8ed;
  overflow-x: auto; white-space: nowrap;
}
.crumb-nav {
  border: 1px solid #d6dde3; background: #fff; border-radius: 3px;
  min-width: 26px; height: 26px; padding: 0 8px; cursor: pointer;
  color: #1997c6; flex: 0 0 auto; white-space: nowrap;
}
.crumb-nav[disabled] { opacity: .4; cursor: default; }
.crumb-nav:hover { background: #eef2f5; }
.crumbs { display: flex; align-items: center; margin-left: 6px; }
.crumbs a {
  color: #1997c6; text-decoration: none; padding: 2px 5px; border-radius: 3px;
}
.crumbs a:hover { background: #e7f4fa; text-decoration: underline; }
.crumbs span.sep { color: #aab; padding: 0 1px; }
.crumbs .cur { color: #333; font-weight: 600; padding: 2px 5px; }
.crumb-info { margin-left: auto; color: #889; font-size: 12px; padding-left: 12px; }

/* ================= LAYOUT ================= */
.main { flex: 1 1 auto; display: flex; min-height: 0; }
.sidebar {
  width: 250px; flex: 0 0 auto; overflow: auto;
  background: #fafbfc; border-right: 1px solid #e2e8ed;
}
.side-head {
  padding: 7px 12px; font-weight: 600; color: #667;
  border-bottom: 1px solid #e2e8ed; background: #f4f6f8;
  position: sticky; top: 0;
}
.splitter { width: 4px; cursor: col-resize; background: transparent; flex: 0 0 auto; }
.splitter:hover { background: #cfe4ee; }
.content { flex: 1 1 auto; overflow: auto; position: relative; }

/* ================= TREE ================= */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; }
.tree li > .row {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; cursor: pointer; border-radius: 3px; user-select: none;
}
.tree li > .row:hover { background: #eaf1f6; }
.tree li > .row.active { background: #d6ebf5; font-weight: 600; }
.tree .tw {
  width: 13px; text-align: center; color: #8a97a3; flex: 0 0 auto; font-size: 10px;
}
.tree .tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= FILE LIST ================= */
.filelist { width: 100%; border-collapse: collapse; }
.filelist thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f4f6f8; border-bottom: 1px solid #d6dde3;
  text-align: left; padding: 7px 8px; font-weight: 600; color: #556; white-space: nowrap;
}
.filelist th.sortable { cursor: pointer; }
.filelist th.sortable:hover { background: #e9eef2; }
.filelist th.sortable::after { content: ''; }
.filelist th.sort-asc::after  { content: ' ▲'; font-size: 9px; color: #889; }
.filelist th.sort-desc::after { content: ' ▼'; font-size: 9px; color: #889; }
.c-chk { width: 30px; }
.c-size { width: 100px; }
.c-time { width: 160px; }
.c-perm { width: 70px; }
.c-own { width: 110px; }
.filelist tbody td {
  padding: 5px 8px; border-bottom: 1px solid #f0f3f5; white-space: nowrap;
}
.filelist tbody tr { cursor: default; user-select: none; }
.filelist tbody tr:hover { background: #f5f9fb; }
.filelist tbody tr.sel { background: #d6ebf5; }
.filelist tbody tr.sel:hover { background: #c8e4f2; }
.fname { display: flex; align-items: center; gap: 7px; }
.fname .ic { font-size: 15px; width: 18px; text-align: center; flex: 0 0 auto; }
.fname .tx { overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; color: #667; }
.empty, .loading {
  padding: 40px; text-align: center; color: #99a5ad;
}

/* ================= STATUS BAR ================= */
.statusbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 16px;
  background: #f4f6f8; border-top: 1px solid #d6dde3;
  padding: 5px 12px; color: #667; font-size: 12px;
}
.clip {
  background: #fff6d9; border: 1px solid #f0dfa8; color: #7a6420;
  padding: 2px 8px; border-radius: 3px;
}

/* ================= CONTEXT MENU ================= */
.ctxmenu {
  position: fixed; z-index: 900; min-width: 210px;
  background: #fff; border: 1px solid #c8d1d8; border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0,0,0,.18); padding: 4px 0;
}
.ctxmenu .it {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 14px; cursor: pointer; color: #334;
}
.ctxmenu .it:hover { background: #1997c6; color: #fff; }
.ctxmenu .it.dis { opacity: .38; pointer-events: none; }
.ctxmenu .it i { font-style: normal; width: 16px; text-align: center; }
.ctxmenu .sep { height: 1px; background: #e4e9ed; margin: 4px 0; }

/* ================= MODAL ================= */
.overlay {
  position: fixed; inset: 0; background: rgba(20,28,36,.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: #fff; border-radius: 5px; width: 480px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #e4e9ed; font-weight: 600;
}
.modal-x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: #99a5ad; }
.modal-x:hover { color: #445; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot {
  padding: 12px 16px; border-top: 1px solid #e4e9ed;
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-body label { display: block; margin-bottom: 6px; color: #556; }
.modal-body input[type=text], .modal-body select {
  width: 100%; padding: 8px 10px; border: 1px solid #ccd3d9; border-radius: 3px; margin-bottom: 12px;
}
.btn-primary {
  background: #1997c6; color: #fff; border: 0; border-radius: 3px;
  padding: 8px 16px; cursor: pointer; font-weight: 600;
}
.btn-primary:hover { background: #1580a8; }
.btn-danger { background: #c0392b; }
.btn-danger:hover { background: #a5301f; }
.btn-ghost {
  background: #fff; border: 1px solid #ccd3d9; border-radius: 3px;
  padding: 8px 16px; cursor: pointer; color: #556;
}
.btn-ghost:hover { background: #eef2f5; }

.path-hint { color: #667; margin: 0 0 12px; font-size: 13px; }
.movepath-row { display: flex; gap: 8px; align-items: stretch; }
.movepath-row input[type=text] { flex: 1; margin-bottom: 12px; }
.movepath-row #moveHomeBtn { flex: 0 0 auto; height: 38px; padding: 0 12px; margin-bottom: 12px; }

.prov-wrap { display: flex; gap: 14px; align-items: center; padding: 6px 0 2px; }
.prov-spinner {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid #dfe6ed; border-top-color: #2b7cd3;
  animation: prov-spin .8s linear infinite;
}
@keyframes prov-spin { to { transform: rotate(360deg); } }
#provStage { font-weight: 600; color: #334; }

.site-badge {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  font-size: 11px; font-weight: 600; margin: 2px 0;
}
.site-badge.own    { background: #e8f2ec; color: #2e7d32; }
.site-badge.shared { background: #e6eefc; color: #2b5fa8; }
.site-badge.cpanel { background: #f0eef5; color: #6b5b95; }

.sys-warn {
  margin: 0 12px 10px; padding: 8px 10px;
  background: #fff8e6; border: 1px solid #f0d9a0; border-radius: 4px;
  color: #7a5c1e; font-size: 13px; line-height: 1.45;
}
.cron-flag {
  display: inline-block; margin-top: 3px; padding: 1px 6px;
  border-radius: 3px; font-size: 11px; font-weight: 600;
}
.cron-flag.warn { background: #fdebd0; color: #9c5b12; }
.cron-flag.dup  { background: #fadbd8; color: #a83228; }

.cron-filter {
  height: 30px; margin: 0 4px; padding: 0 6px;
  border: 1px solid #ccd5dd; border-radius: 4px;
  background: #fff; color: #334; font-size: 13px; max-width: 140px;
}

/* --- permission grid --- */
.perm-grid { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.perm-grid th, .perm-grid td {
  border: 1px solid #e0e6ea; padding: 6px; text-align: center;
}
.perm-grid th { background: #f4f6f8; color: #556; font-weight: 600; }
.perm-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px; text-align: center; letter-spacing: 5px;
  padding: 8px; background: #f4f6f8; border-radius: 3px; margin-bottom: 12px;
}

/* --- upload list --- */
.up-item { margin-bottom: 10px; }
.up-name { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; }
.up-bar { height: 6px; background: #e6ebef; border-radius: 3px; overflow: hidden; }
.up-fill { height: 100%; width: 0; background: #4aa564; transition: width .18s; }
.up-fill.err { background: #c0392b; }

/* --- preview --- */
.prev-media { max-width: 100%; max-height: 62vh; display: block; margin: 0 auto; }
.meta { color: #778; font-size: 12px; line-height: 1.7; }
.meta b { color: #445; font-weight: 600; }

/* ================= EDITOR ================= */
.editor-wrap {
  position: fixed; inset: 0; z-index: 1100; background: #1e2227;
  display: flex; flex-direction: column;
}
.vw-wrap {
  max-height: 62vh; overflow: auto; background: #1e2530; border-radius: 4px;
  padding: 8px 0; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.5;
}
.vw-line { display: flex; white-space: pre; }
.vw-line:hover { background: rgba(255,255,255,.05); }
.vw-num {
  flex: 0 0 auto; min-width: 44px; padding: 0 10px 0 6px; text-align: right;
  color: #66748a; user-select: none;
}
.vw-txt { color: #dbe3ec; padding-right: 12px; }

.editor-head {
  display: flex; align-items: center; justify-content: space-between;
  background: #2c3e50; color: #fff; padding: 8px 14px; flex: 0 0 auto;
  position: relative;
}
.editor-toast {
  position: absolute; right: 14px; top: 100%; margin-top: 6px;
  padding: 7px 12px; border-radius: 4px; font-size: 13px; font-weight: 600;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none; z-index: 30; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.editor-toast.show { opacity: 1; transform: translateY(0); }
.editor-toast.ok   { background: #e8f5ec; color: #256b32; border: 1px solid #b9dfc5; }
.editor-toast.info { background: #eef2f7; color: #47566b; border: 1px solid #ccd7e4; }
.editor-toast.err  { background: #fdecea; color: #a32b1e; border: 1px solid #f2c2bc; }
.editor-head > div { display: flex; gap: 8px; }
.editor-wrap .CodeMirror { flex: 1 1 auto; height: auto; font-size: 13px; }

/* ================= RESPONSIF ================= */
@media (max-width: 820px) {
  .sidebar { display: none; }
  .splitter { display: none; }
  .ab span { display: none; }
  .ab { padding: 6px 8px; }
  .c-perm, .c-own, .c-time { display: none; }
  .searchbox input { width: 130px; }
  .chk { display: none; }
}

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

/* fix: hidden harus menang atas display:flex */
[hidden] { display: none !important; }

/* daftar hasil ekstrak */
.xlist {
  max-height: 320px; overflow: auto; background: #f7f9fa;
  border: 1px solid #e0e6ea; border-radius: 3px; padding: 8px 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.7;
}
.xlist div { white-space: nowrap; }
.xsum { margin: 0 0 10px; color: #556; }

@media (max-width: 820px) {
  .crumb-nav span { display: none; }
  .crumb-nav { padding: 0 6px; }
}
