/* =========================================================
   Tema: Navy + abu aluminium
   Navy tegas untuk elemen utama dan aksi; abu aluminium lembut untuk latar
   agar nyaman dilihat lama. Semua warna diatur dari token di bawah.
   ========================================================= */
:root {
  --bg: #f3f5f8;          /* latar halaman: abu aluminium terang */
  --surface: #ffffff;     /* card, sidebar, tabel */
  --navy: #12305c;        /* warna utama: judul, card head, tab menu, menu aktif */
  --navy-hover: #0c2347;
  --ink: #16243a;         /* teks utama */
  --muted: #5b6778;       /* teks sekunder */
  --line: #cdd5df;
  --line-strong: #9aa6b5;
  --steel: #e4e9ef;       /* tombol sekunder, menu sidebar, footer */
  --steel-hover: #d6dde6;
  --steel-soft: #eef2f6;  /* kotak riwayat, header tabel */

  --blue: #1f6feb;        /* status RUNNING, link, fokus */
  --green: #157f3d;       /* SUCCESS */
  --red: #c0262d;         /* FAILED */
  --amber: #f2b705;       /* fokus di area navy */

  --sidebar-w: 280px;

  /* Posisi tab hamburger = posisi tepi atas sidebar.
     Tab dibuat sejajar tengah dengan baris judul. */
  --header-pad-top: 16px;
  --logo-size: 96px;
  --title-gap: 4px;
  --title-size: clamp(1.35rem, 1rem + 1.4vw, 2rem);
  --menu-h: 58px;
  --rail-top: calc(var(--header-pad-top) + var(--logo-size) + var(--title-gap)
              + (var(--title-size) * 1.2 - var(--menu-h)) / 2);

  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: "Rubik", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button { font: inherit; color: inherit; }

/* =========================================================
   Header: tidak berubah saat sidebar dibuka/ditutup
   ========================================================= */
.topbar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--title-gap);
  padding: var(--header-pad-top) 72px 14px;
}

.logo { display: block; line-height: 0; }
.logo img { width: var(--logo-size); height: var(--logo-size); }

.title {
  margin: 0;
  color: var(--navy);
  font-size: var(--title-size);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .01em;
  text-align: center;
}

.menu-btn {
  position: absolute;
  top: var(--rail-top);
  left: 0;
  display: grid;
  place-items: center;
  width: 54px;
  height: var(--menu-h);
  border: 0;
  border-radius: 0 12px 12px 0;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
}
.menu-btn:hover { background: var(--navy-hover); }
.menu-btn:focus-visible { outline-color: var(--amber); }
/* Saat sidebar terbuka, sidebar menempati posisi tab ini (tetap ada di layout untuk acuan posisi) */
.sidebar-open .menu-btn { visibility: hidden; }

.account { position: absolute; top: var(--header-pad-top); right: 20px; }

.avatar-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
}
.avatar-btn:hover { background: var(--steel); }

.account-menu {
  position: absolute;
  top: 44px;
  right: 0;
  z-index: 50;
  min-width: 240px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(18, 48, 92, .14);
}
.account-name { margin: 0; color: var(--navy); font-weight: 600; }
.account-email { margin: 2px 0 12px; color: var(--muted); font-size: .85rem; word-break: break-all; }
.account-signout { color: var(--red); font-weight: 500; text-decoration: none; }
.account-signout:hover { text-decoration: underline; }

/* =========================================================
   Sidebar
   Tepi atas = posisi tab hamburger (top diperbarui JS saat scroll),
   tepi bawah = bawah layar.
   ========================================================= */
.sidebar {
  position: fixed;
  top: var(--rail-top);
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  padding: 26px 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 16px 0 0;
  visibility: hidden;
  transform: translateX(-101%);
  transition: transform .24s var(--ease), visibility 0s .24s;
}
.sidebar-open .sidebar {
  visibility: visible;
  transform: none;
  transition: transform .24s var(--ease);
}

.sidebar-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.sidebar-close:hover { background: var(--steel-soft); color: var(--ink); }

.sidebar-user { padding: 0 48px 0 24px; }
.user-name { margin: 0; color: var(--navy); font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.user-email { margin: 4px 0 0; color: var(--muted); font-size: .82rem; word-break: break-all; }

/* Menu menempel ke tepi kiri dan tidak selebar sidebar (sesuai blueprint) */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 44px;
  padding-right: 72px;
}
.sidebar-nav a {
  display: block;
  padding: 15px 24px;
  border-radius: 0 18px 18px 0;
  background: var(--steel);
  color: var(--navy);
  font-size: 1.3rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .15s;
}
.sidebar-nav a:hover { background: var(--steel-hover); }
.sidebar-nav a.active { background: var(--navy); color: #fff; font-weight: 600; }
.sidebar-nav a.active:focus-visible { outline-color: var(--amber); }

.sidebar-foot { margin-top: auto; display: grid; justify-items: center; gap: 8px; }
.signout { color: var(--navy); font-size: 1.1rem; font-weight: 500; text-decoration: none; }
.signout:hover { color: var(--red); }
.sidebar-foot small { color: var(--muted); font-size: .7rem; }

.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(18, 48, 92, .35); }

/* =========================================================
   Konten
   ========================================================= */
.content { padding: 24px 24px 110px; transition: margin-left .24s var(--ease); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.empty { padding: 48px 16px; color: var(--muted); text-align: center; }
.empty code { padding: 2px 6px; background: var(--steel); border-radius: 4px; }

/* =========================================================
   Card projek
   ========================================================= */
.card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px 12px 6px 6px;
}

.card-head {
  position: relative;
  padding: 20px 16px 24px;
  background: var(--navy);
  color: #fff;
  text-align: center;
}
.card-head h2 { margin: 0 0 14px; font-size: 1.55rem; font-weight: 700; letter-spacing: .02em; }

.btn-update {
  display: inline-grid;
  place-items: center;
  min-width: 148px;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--navy);
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
  transition: background-color .15s;
}
.btn-update:hover { background: #dce6f5; }
.btn-update:focus-visible { outline-color: var(--amber); }
.btn-busy { display: none; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* State running */
.card.is-running .btn-update { background: rgba(255, 255, 255, .16); color: #fff; cursor: progress; }
.card.is-running .btn-label { display: none; }
.card.is-running .btn-busy { display: inline-flex; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Garis sinkronisasi selama proses: warna diambil dari logo */
.card-head::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 4px;
  opacity: 0;
  background: linear-gradient(90deg, #22a35a 0 33%, #4c93f5 33% 66%, var(--amber) 66% 100%);
  background-size: 300% 100%;
}
.card.is-running .card-head::after { opacity: 1; animation: sweep 1.6s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sweep { to { background-position: -300% 0; } }

.card-body { padding: 12px 10px 0; }
.history-title { margin: 0 0 6px 4px; color: var(--muted); font-size: .75rem; }

.history-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px 8px;
  align-items: center;
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  background: var(--steel-soft);
  border-radius: 8px;
  font-size: .76rem;
}
.history-list li { display: contents; }   /* kolom sejajar di semua baris */
.h-user { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.h-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-empty {
  margin: 0;
  padding: 12px;
  background: var(--steel-soft);
  border-radius: 8px;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}

.status { font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-align: right; }
.status-success { color: var(--green); }
.status-failed { color: var(--red); }
.status-running { color: var(--blue); }

.links { display: grid; justify-items: center; gap: 8px; margin: 16px 0 6px; }
.pill {
  width: 172px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--steel);
  color: var(--navy);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition: background-color .15s;
}
a.pill:hover { background: var(--steel-hover); }
.pill.is-disabled { color: var(--muted); opacity: .55; cursor: not-allowed; }

.card-toggle {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 9px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
}
.card-toggle:hover { background: var(--steel-soft); }
.card-toggle svg { transition: transform .2s var(--ease); }
.card-toggle[aria-expanded="true"] { border-top: 0; }
.card-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* =========================================================
   Log
   ========================================================= */
.log { max-width: 1280px; margin: 0 auto; }
.log-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.log-head h2 { margin: 0; color: var(--navy); font-size: 1.5rem; }
.log-filter { display: flex; align-items: center; gap: 8px; }
.log-filter select {
  min-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--steel-soft); color: var(--navy); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
td.msg { min-width: 180px; color: var(--muted); }

/* =========================================================
   Footer
   ========================================================= */
.footer-tag {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 20;
  width: min(490px, 72vw);
  padding: 7px 0 5px;
  background: var(--steel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  color: var(--navy);
  font-style: italic;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  transition: left .24s var(--ease);
}

/* =========================================================
   Toast
   ========================================================= */
.toasts {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 48, 92, .16);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #fff; }
.toast-success .toast-icon { background: var(--green); }
.toast-error .toast-icon { background: var(--red); }
.toast-title { display: block; color: var(--ink); font-weight: 700; }
.toast-detail { display: block; margin-top: 2px; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.toast-detail a { color: var(--blue); }
.toast-close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.toast-close:hover { background: var(--steel-soft); }

/* =========================================================
   Layar lebar (>= 1024px): sidebar mendorong konten.
   Di bawah itu sidebar menimpa konten + scrim, supaya tidak
   menabrak judul header yang posisinya tetap di tengah.
   ========================================================= */
@media (min-width: 1024px) {
  .sidebar-open .content { margin-left: var(--sidebar-w); }
  .sidebar-open .footer-tag { left: calc(50% + var(--sidebar-w) / 2); }
}

@media (max-width: 1023px) {
  .sidebar { box-shadow: 8px 0 24px rgba(18, 48, 92, .14); }
}

@media (max-width: 600px) {
  :root {
    --header-pad-top: 12px;
    --logo-size: 76px;
    --menu-h: 52px;
    --rail-top: calc(var(--header-pad-top) + var(--logo-size) + var(--title-gap));
  }
  .topbar { padding-left: 60px; padding-right: 60px; }
  .menu-btn { width: 46px; }
  .content { padding: 20px 14px 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
  .spinner { animation-duration: 2.4s; }
  .card.is-running .card-head::after { animation: none; background-position: 0 0; }
}

/* =========================================================
   Halaman login
   ========================================================= */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px 80px;
}
.login-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(500px, 100%);
  padding: 32px 28px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--navy);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(18, 48, 92, .10);
  text-align: center;
}
.login-card .title { font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem); white-space: nowrap; }
@media (max-width: 420px) { .login-card .title { white-space: normal; } }
.login-hint { margin: 2px 0 8px; color: var(--muted); font-size: .92rem; }
.login-hint strong { color: var(--ink); font-weight: 600; }
.login-alert {
  width: 100%;
  margin: 0 0 4px;
  padding: 10px 12px;
  background: var(--steel-soft);
  border-radius: 8px;
  color: var(--ink);
  font-size: .88rem;
}
.login-alert-error { background: #fbeaea; color: var(--red); }
.login-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .15s;
}
.login-btn:hover { background: var(--navy-hover); }
.login-btn:focus-visible { outline-color: var(--amber); }
.log .out-link { color: var(--blue); white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Banner mode simulasi */
.mock-banner {
  max-width: 1280px;
  margin: 0 auto 20px;
  padding: 12px 16px;
  background: #fff6db;
  border: 1px solid #f2d27a;
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  color: var(--ink);
  font-size: .92rem;
}
.mock-banner code { padding: 1px 5px; background: rgba(18, 48, 92, .08); border-radius: 4px; }

/* =========================================================
   Peran, Log, dan halaman Akun
   ========================================================= */
.role-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--steel);
  color: var(--navy);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.role-badge.role-developer { background: var(--navy); color: #fff; }

.log-scope { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.log-filter { flex-wrap: wrap; }

.flash {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: var(--surface);
}
.flash-success { border-left-color: var(--green); }
.flash-error { border-left-color: var(--red); color: var(--red); }

.accounts { max-width: 1280px; margin: 0 auto; }
.acct-add {
  margin-bottom: 20px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.acct-add h3 { margin: 0 0 12px; color: var(--navy); font-size: 1.05rem; }
.acct-add-fields {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1.5fr) minmax(130px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.acct-add label { display: grid; gap: 4px; color: var(--muted); font-size: .82rem; }
.acct-add input, .acct-add select,
.acct-table input, .acct-table select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
}
.acct-table input { min-width: 130px; }
.acct-table select { min-width: 124px; }
.acct-table th, .acct-table td { padding: 10px 10px; }
.acct-email { font-size: .88rem; }
.acct-email .tag:first-of-type { margin-left: 0; }
.acct-tags { display: flex; gap: 4px; margin-top: 4px; }
.acct-table select:disabled { background: var(--steel-soft); color: var(--muted); }
.acct-note { margin: 12px 0 0; color: var(--muted); font-size: .82rem; }

.acct-table td { vertical-align: middle; }
.acct-table tr.is-inactive td { color: var(--muted); }
.acct-actions { display: flex; gap: 8px; justify-content: flex-end; white-space: nowrap; }
.acct-actions form { margin: 0; }

.tag {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: .68rem;
  font-weight: 600;
  vertical-align: middle;
}
.tag-self { margin-left: 0; background: var(--steel); color: var(--navy); }

.btn {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-hover); }
.btn-small { padding: 6px 12px; background: var(--steel); color: var(--navy); font-size: .85rem; }
.btn-small:hover { background: var(--steel-hover); }
.btn-danger { background: transparent; border-color: #e9b8ba; color: var(--red); }
.btn-danger:hover { background: #fbeaea; }

@media (max-width: 760px) {
  .acct-add-fields { grid-template-columns: 1fr; }
}
