/* ==========================================================================
   ui-v2.css — Tampilan baru Binarta Access (desktop + mobile)
   Dimuat paling akhir agar menimpa gaya lama tanpa mengubah struktur JS.
   ========================================================================== */

:root {
  --v2-a1: #13315c;
  --v2-a2: #1d4ed8;
  --v2-a3: #0ea5e9;
  --v2-ring: rgba(29, 78, 216, 0.32);
  --v2-navh: 66px;
}
html[data-theme="dark"] { --v2-ring: rgba(125, 178, 255, 0.32); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) { --v2-ring: rgba(125, 178, 255, 0.32); }
}

body { padding-bottom: calc(var(--v2-navh) + env(safe-area-inset-bottom, 0px)); }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

/* ───────────────────────── Topbar ───────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  margin: 0 -18px 18px;
  padding: 0 18px;
  background: var(--surface-alpha);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.tb-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
}
.tb-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar .logo {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff;
  box-shadow: 0 6px 16px -7px rgba(15, 23, 42, 0.45);
}
.topbar .logo img { width: 100%; height: 100%; object-fit: contain; }
.tb-titles { min-width: 0; }
.topbar .brand {
  font-size: 19px; font-weight: 900;
  letter-spacing: -0.4px; line-height: 1.12;
}
.topbar .brand-sub {
  font-size: 11.5px; font-weight: 600; color: var(--text3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* user-bar dilebur ke dalam topbar */
.tb-inner .user-bar {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; padding: 0;
  box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  max-width: none; border-radius: 0;
}
.user-bar.hidden { display: none !important; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 12px;
  font-size: 15px; font-weight: 900;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--v2-a2), var(--v2-a3));
  color: #fff; flex: 0 0 38px;
}
.user-meta { min-width: 0; line-height: 1.25; }
.user-name { font-size: 13.5px; font-weight: 800; }
.user-jabatan { font-size: 11px; color: var(--text3); font-weight: 600; }

.theme-toggle, .presence-btn, .notif-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 16px; cursor: pointer;
  position: relative;
  transition: 0.18s;
}
/* Tombol tema berdiri sendiri di topbar: selalu tampil, didorong ke kanan */
.tb-inner > .theme-toggle { margin-left: auto; flex-shrink: 0; }
.tb-inner > .theme-toggle + .user-bar { margin-left: 10px; }

.theme-toggle:hover, .presence-btn:hover, .notif-btn:hover {
  border-color: var(--v2-a2);
  transform: translateY(-2px);
}
.notif-badge, .presence-count {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 900; color: #fff;
  border: 2px solid var(--surface);
}
.notif-badge { background: #dc2626; }
.presence-count { background: #16a34a; }
.logout-btn {
  height: 38px; padding: 0 15px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text2);
  font-weight: 800; font-size: 12.5px; cursor: pointer;
  transition: 0.18s;
}
.logout-btn:hover { background: #dc2626; border-color: #dc2626; color: #fff; }

/* ───────────────────────── Hero ───────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 20px 22px;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--v2-a1), var(--v2-a2) 58%, var(--v2-a3));
  color: #fff;
  box-shadow: 0 18px 40px -22px rgba(29, 78, 216, 0.9);
}
.hero-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(620px 220px at 100% 0%, rgba(255, 255, 255, 0.22), transparent 62%),
    radial-gradient(420px 220px at 0% 100%, rgba(255, 255, 255, 0.14), transparent 62%);
}
.hero-main { position: relative; flex: 1 1 260px; min-width: 0; }
.hero-hi { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.hero-sub { font-size: 13px; font-weight: 600; opacity: 0.92; margin-top: 3px; }
.hero-quick { position: relative; display: flex; gap: 8px; flex-wrap: wrap; }
.qa {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 15px; border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.16);
  color: #fff; font: inherit; font-weight: 800; font-size: 13px;
  cursor: pointer; transition: 0.18s;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.qa:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-2px); }
.qa span { font-size: 16px; }

/* ───────────────────────── Toolbar ───────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.search {
  display: flex; align-items: center; gap: 9px;
  flex: 1 1 300px; height: 46px; padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 14px -10px rgba(15, 23, 42, 0.5);
  transition: 0.18s;
}
.search:focus-within {
  border-color: var(--v2-a2);
  box-shadow: 0 0 0 4px var(--v2-ring);
}
.search-ic { font-size: 15px; opacity: 0.65; }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
}
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-x {
  display: none;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--border); color: var(--text2);
  font-size: 11px; line-height: 1; cursor: pointer;
}
.search.has .search-x { display: block; }

.cats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text2);
  font: inherit; font-size: 12.5px; font-weight: 800;
  cursor: pointer; white-space: nowrap; transition: 0.18s;
}
.cat:hover { border-color: var(--v2-a2); color: var(--v2-a2); }
.cat.on {
  background: linear-gradient(135deg, var(--v2-a2), var(--v2-a3));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 20px -10px rgba(29, 78, 216, 0.85);
}

/* ───────────────────────── Kartu aplikasi ───────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 15px;
}
.app-card {
  position: relative;
  display: flex; flex-direction: column; gap: 9px;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: var(--surface);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px -10px rgba(15, 23, 42, 0.45);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.22s ease, border-color 0.22s ease;
}
.app-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-grad, linear-gradient(135deg, #1d4ed8, #0ea5e9));
  opacity: 0.95;
}
.app-card::after { display: none; }
.app-card:hover {
  transform: translateY(-4px);
  border-color: transparent;
  box-shadow: 0 22px 44px -22px rgba(15, 23, 42, 0.6);
}
.app-icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 23px;
  background: var(--card-grad, linear-gradient(135deg, #1d4ed8, #0ea5e9));
  box-shadow: 0 12px 24px -12px rgba(15, 23, 42, 0.75);
}
.app-name { font-size: 15.5px; font-weight: 900; letter-spacing: -0.3px; line-height: 1.25; }
.app-desc {
  font-size: 12.5px; line-height: 1.55; color: var(--text3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-roles {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: auto; padding-top: 4px;
}
.role-tag {
  font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 999px;
  background: var(--border); color: var(--text2);
}
.login-status {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 800; color: var(--text3);
}
.login-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #cbd5e1; flex: 0 0 7px;
}
.login-dot.active { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.app-arrow { display: none; }
.app-card[data-locked="true"] { opacity: 0.52; filter: grayscale(0.55); }
.app-card[data-locked="true"]:hover { transform: none; }
.app-card[hidden] { display: none !important; }

/* ───────────────────────── Empty state ───────────────────────── */
.no-result { text-align: center; padding: 54px 20px; color: var(--text3); }
.no-result[hidden] { display: none; }
.nr-ic { font-size: 40px; margin-bottom: 8px; }
.nr-t { font-size: 16px; font-weight: 900; color: var(--text2); }
.nr-s { font-size: 13px; margin-top: 4px; }

/* ───────────────────────── Ticker & footer ───────────────────────── */
.activity-ticker { border-radius: 14px; margin-bottom: 16px; }
.footer { margin-top: 30px; text-align: center; font-size: 12px; color: var(--text3); }

/* ══════════════════════ TABLET ≤ 900px ══════════════════════ */
@media (max-width: 900px) {
  .hero-quick { width: 100%; }
  .qa { flex: 1 1 auto; justify-content: center; }
}

/* ══════════════════════ MOBILE ≤ 768px ══════════════════════ */
@media (max-width: 768px) {
  .wrap { padding: 0 14px 28px; }
  .topbar { margin: 0 -14px 14px; padding: 0 14px; }
  .tb-inner { min-height: 58px; gap: 10px; }
  .topbar .logo { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; }
  .topbar .brand { font-size: 16.5px; }
  .topbar .brand-sub { display: none; }
  .user-meta { display: none; }
  .logout-btn { display: none; }
  .user-avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; font-size: 13px; }
  .theme-toggle, .presence-btn, .notif-btn { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
  .hero { padding: 16px; border-radius: 18px; }
  .hero-hi { font-size: 18px; }
  .hero-sub { font-size: 12px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
}

/* ══════════════════════ PONSEL ≤ 560px ══════════════════════ */
@media (max-width: 560px) {
  .hero { flex-direction: column; align-items: stretch; gap: 13px; }
  .hero-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .qa { padding: 11px 6px; font-size: 12px; gap: 5px; }
  .qa span { font-size: 15px; }

  .toolbar { gap: 9px; }
  .search { flex: 1 1 100%; height: 44px; }
  .cats { margin: 0 -14px; padding: 2px 14px; }

  /* Kartu jadi baris ringkas: ikon di kiri, teks di kanan */
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .app-card {
    display: grid;
    grid-template-columns: 52px 1fr;
    grid-template-areas: "ic name" "ic desc" "ic roles";
    column-gap: 13px; row-gap: 3px;
    align-items: start;
    padding: 14px 14px 13px;
    border-radius: 16px;
  }
  .app-card:hover { transform: none; }
  .app-card:active { transform: scale(0.985); }
  .app-icon { grid-area: ic; width: 52px; height: 52px; font-size: 25px; align-self: center; }
  .app-name { grid-area: name; font-size: 14.5px; padding-right: 60px; }
  .app-desc { grid-area: desc; font-size: 12px; -webkit-line-clamp: 2; }
  .app-roles { grid-area: roles; margin-top: 3px; padding-top: 2px; }
  .role-tag { font-size: 9.5px; padding: 2px 7px; }
  .login-status { top: 10px; right: 11px; font-size: 9.5px; }

  /* Panel notifikasi & presensi jadi lembar penuh */
  .notif-panel, .presence-panel {
    position: fixed !important;
    top: 62px !important; left: 10px !important; right: 10px !important;
    width: auto !important; max-width: none !important;
    max-height: 70vh; overflow-y: auto;
  }
}

/* ══════════════════════ PONSEL KECIL ≤ 380px ══════════════════════ */
@media (max-width: 380px) {
  .app-name { padding-right: 0; }
  .login-status { position: static; margin-bottom: 2px; grid-area: name; }
  .hero-quick { grid-template-columns: repeat(2, 1fr); }
  .qa:last-child { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  .app-card, .qa, .cat, .theme-toggle, .presence-btn, .notif-btn { transition: none; }
  .app-card:hover { transform: none; }
}
