/* =========================================================
   PERFORMANCE DIGITAL EXPOSURE — PARTAI NASDEM
   Shell dashboard (sidebar + header) untuk report Looker Studio
   ========================================================= */

:root {
  /* Palet mengikuti gambar referensi */
  --navy-900: #0a1838;   /* header */
  --navy-800: #0e2149;   /* sidebar */
  --navy-700: #16306a;   /* border/hover di area gelap */
  --blue-600: #1f5fd6;   /* menu aktif / aksen */
  --blue-500: #2f74ec;
  --blue-100: #e6eefc;   /* header tabel di Looker */
  --bg:       #f3f5f9;   /* background konten */
  --card:     #ffffff;
  --line:     #dfe4ee;   /* border tipis kartu */
  --text:     #142245;
  --muted:    #6b7690;
  --on-dark:  #e9eefb;
  --on-dark-muted: #9fb0d6;
  --green:    #22c55e;

  --sidebar-w: 178px;
  --topbar-h: 84px;
  --radius: 10px;
  --pad: 16px;

  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
svg { width: 18px; height: 18px; flex: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
[hidden] { display: none !important; }

.app { display: flex; min-height: 100vh; }

/* ====================== SIDEBAR ====================== */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--navy-800);
  color: var(--on-dark);
  display: flex; flex-direction: column;
  z-index: 40;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: var(--navy-900);
}
.brand-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 50%; background: #fff; padding: 3px; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text span { font-weight: 800; font-size: 15px; letter-spacing: .6px; color: #fff; }

.nav { display: flex; flex-direction: column; padding: 10px 0; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  font-size: 14px; font-weight: 500;
  color: var(--on-dark);
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 20px; height: 20px; opacity: .95; }
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active {
  background: var(--blue-600);
  color: #fff; font-weight: 600;
  border-left-color: #8fb4ff;
}

.sidebar-foot { margin-top: auto; padding: 14px 12px 18px; display: flex; flex-direction: column; gap: 18px; }

.period-card {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--navy-700);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,.03);
}
.period-card svg { width: 22px; height: 22px; color: var(--on-dark-muted); margin-top: 2px; }
.period-card small { display: block; font-size: 10.5px; color: var(--on-dark-muted); }
.period-card strong { display: block; font-size: 12.5px; color: #fff; margin: 2px 0; }

.foot-block h4 { font-size: 11.5px; font-weight: 600; color: #fff; margin-bottom: 6px; }
.foot-block ul { list-style: none; font-size: 11px; color: var(--on-dark-muted); }
.foot-block li { position: relative; padding-left: 12px; margin-bottom: 3px; }
.foot-block li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--on-dark-muted); }

.platforms { display: flex; gap: 6px; flex-wrap: nowrap; }
.pf {
  width: 24px; height: 24px; border-radius: 6px;
  display: inline-grid; place-items: center;
  color: #fff;
}
.pf svg { width: 14px; height: 14px; }
.pf-tt { background: #000; }
.pf-ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 90%); }
.pf-yt { background: #ff0000; }
.pf-yt svg { width: 16px; height: 16px; }
.pf-fb { background: #1877f2; }
.pf-x  { background: #000; border: 1px solid #3b4b72; }
.pf-x svg { width: 13px; height: 13px; }

.sidebar-backdrop { display: none; }

/* ====================== MAIN ====================== */
.main {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-width: 0;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ---------- HEADER ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  min-height: var(--topbar-h);
  background: var(--navy-900);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px;
  padding: 10px 22px;
}
.menu-toggle { display: none; padding: 6px; border-radius: 6px; }
.menu-toggle svg { width: 24px; height: 24px; }

.title-block { min-width: 0; }
.title-block h1 { font-size: 21px; font-weight: 800; letter-spacing: .3px; line-height: 1.15; }
.title-block h2 { font-size: 14.5px; font-weight: 600; margin-top: 1px; }
.subnav { display: flex; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; gap: 8px; font-size: 11px; color: var(--on-dark-muted); margin-top: 5px; }
.subnav i { font-style: normal; opacity: .5; }

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Filter multi-select ---------- */
.ctl { position: relative; color: #fff; }
.ms-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 44px;
  padding: 0 30px 0 10px;
  border: 1px solid #2c4580; border-radius: 6px;
  background: transparent; color: #fff; text-align: left;
  transition: border-color .15s, background .15s;
}
.ms-trigger:hover { background: rgba(255,255,255,.05); }
.ms.open .ms-trigger, .ms-trigger:focus-visible { border-color: var(--blue-500); box-shadow: 0 0 0 2px rgba(47,116,236,.35); outline: 0; }
.ms.is-filtered .ms-trigger { border-color: #4f86f0; background: rgba(47,116,236,.14); }
.ms-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ms-text small { font-size: 10px; color: var(--on-dark-muted); line-height: 1; margin-bottom: 3px; }
.ms-value { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctl-chev { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; pointer-events: none; opacity: .85; transition: transform .15s; }
.ms.open .ctl-chev { transform: translateY(-50%) rotate(180deg); }

.ctl-period { min-width: 210px; }
.ctl-period .ms-trigger { height: 40px; padding-left: 12px; }
.ctl-period .ctl-ico { width: 18px; height: 18px; opacity: .9; }
.ctl-period .ms-value { font-size: 14px; font-weight: 600; }
.ctl-box { width: 136px; }
.ctl-wide { width: 168px; }

/* Penanda filter belum terhubung ke Looker */
.ms.is-unlinked .ms-trigger::after {
  content: ""; position: absolute; top: -4px; right: -4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #f59e0b; border: 2px solid var(--navy-900);
}

/* Panel */
.ms-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  width: 260px; max-width: calc(100vw - 24px);
  background: #fff; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(10,24,56,.22);
  padding: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.ctl-wide .ms-panel, .ctl-box:nth-last-child(-n+3) .ms-panel { left: auto; right: 0; }
.ms-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ms-head strong { font-size: 13px; }
.ms-count { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 8px; }
.ms-search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; margin-bottom: 4px; }
.ms-search svg { width: 14px; height: 14px; color: var(--muted); }
.ms-search input { border: 0; outline: 0; font: inherit; font-size: 12.5px; height: 32px; width: 100%; background: transparent; }
.ms-search:focus-within { border-color: var(--blue-500); }
.ms-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; }
.ms-opt { display: flex; align-items: center; gap: 9px; padding: 7px 6px; border-radius: 6px; font-size: 12.5px; cursor: pointer; user-select: none; }
.ms-opt:hover { background: var(--blue-100); }
.ms-opt input { width: 15px; height: 15px; accent-color: var(--blue-600); cursor: pointer; flex: none; }
.ms-all { font-weight: 600; border-bottom: 1px dashed var(--line); border-radius: 6px 6px 0 0; margin-bottom: 2px; }
.ms-empty { font-size: 12px; color: var(--muted); padding: 8px 6px; }
.ms-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.ms-hint { flex: 1; font-size: 11px; color: #d9480f; font-weight: 500; }
.ms-btn { padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.ms-reset { color: var(--muted); }
.ms-reset:hover { background: var(--bg); }
.ms-apply { background: var(--blue-600); color: #fff; }
.ms-apply:hover { background: var(--blue-500); }
.ms-apply:disabled { background: #b8c4dc; cursor: not-allowed; }

.updated { display: flex; align-items: center; gap: 8px; padding: 0 4px 0 6px; }
.updated .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.updated small { display: block; font-size: 10.5px; color: var(--on-dark-muted); }
.updated strong { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; }
.updated small { white-space: nowrap; }

.refresh-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid #2c4580;
  transition: background .15s;
}
.refresh-btn:hover { background: rgba(255,255,255,.08); }
.refresh-btn svg { width: 18px; height: 18px; }
.refresh-btn.spinning svg { animation: spin .8s linear infinite; }

/* ---------- CONTENT ---------- */
.content {
  flex: 1;
  padding: 14px var(--pad) var(--pad);
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
}
.content-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb svg { width: 18px; height: 18px; color: var(--blue-600); }
.crumb h3 { font-size: 15px; font-weight: 700; }
.page-desc { font-size: 12px; color: var(--muted); }
.page-desc::before { content: "—"; margin-right: 6px; opacity: .6; }
.page-desc:empty::before { content: none; }

.content-actions { display: flex; align-items: center; gap: 12px; }
.ext-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--blue-600); }
.ext-link svg { width: 14px; height: 14px; }
.ext-link:hover { text-decoration: underline; }
.filter-note.warn { color: #9a3412; background: #fff7ed; border-color: #fed7aa; }
.filter-note { font-size: 11px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }

.report-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16,30,70,.04);
}
.stage { position: relative; width: 100%; min-height: 240px; }
.frame-viewport { position: relative; width: 100%; overflow: hidden; }
.frame-viewport iframe { display: block; border: 0; background: #fff; }

/* Loader */
.loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(243,245,249,.92);
  z-index: 5;
  font-size: 13px; color: var(--muted);
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--blue-100);
  border-top-color: var(--blue-600);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fallback */
.fallback {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 10px; padding: 24px;
  background: var(--bg);
}
.fallback > svg { width: 40px; height: 40px; color: #f59e0b; }
.fallback h4 { font-size: 16px; }
.fallback p { font-size: 13px; color: var(--muted); max-width: 520px; line-height: 1.55; }
.fallback-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { padding: 9px 16px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-500); }
.btn-ghost { border: 1px solid var(--line); background: #fff; color: var(--text); }

/* ====================== LOGIN STATE ====================== */
.auth-check { display: none; }
html.auth-pending .app { visibility: hidden; }
html.auth-pending .auth-check {
  display: flex; position: fixed; inset: 0; z-index: 100;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--navy-900); color: var(--on-dark-muted); font-size: 13px;
}
html.auth-pending .auth-check .spinner { border-color: rgba(255,255,255,.15); border-top-color: #fff; }

.dev-banner { background: #fff7ed; color: #9a3412; border-bottom: 1px solid #fed7aa; font-size: 12px; padding: 7px 22px; }

.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 4px 4px 4px; border: 1px solid #2c4580; border-radius: 999px; }
.user-chip .avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-600); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.user-text { display: flex; flex-direction: column; min-width: 0; max-width: 150px; line-height: 1.2; }
.user-text strong { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-text small { font-size: 10.5px; color: var(--on-dark-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--on-dark-muted); transition: background .15s, color .15s; }
.logout-btn:hover { background: rgba(239,68,68,.18); color: #fecaca; }
.logout-btn svg { width: 16px; height: 16px; }

/* ====================== RESPONSIVE ====================== */

/* Laptop kecil: header jadi 2 baris */
@media (max-width: 1480px) {
  .topbar { flex-wrap: wrap; padding: 12px 18px; }
  .controls { width: 100%; justify-content: flex-start; }
}

/* Tablet & mobile: sidebar collapsible */
@media (max-width: 960px) {
  :root { --pad: 10px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: 4px 0 24px rgba(0,0,0,.3); width: 220px; }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(5,12,30,.45); z-index: 35; }
  .main { margin-left: 0; width: 100%; }
  .menu-toggle { display: inline-grid; place-items: center; }
  .topbar { position: sticky; }
  .title-block { flex: 1; }
  .title-block h1 { font-size: 17px; }
  .subnav { display: none; }
}

@media (max-width: 640px) {
  .topbar { position: relative; }
  .controls { gap: 8px; }
  .filter-note { display: none; }
  .ctl-period { width: 100%; }
  .ctl-box, .ctl-wide { flex: 1 1 calc(50% - 8px); width: auto; min-width: 0; }
  .ms-panel { width: min(300px, calc(100vw - 24px)); }
  .ms[data-filter="platform"] .ms-panel, .ms[data-filter="province"] .ms-panel { left: 0; right: auto; }
  .ms[data-filter="accountLevel"] .ms-panel { left: auto; right: 0; }
  .updated { flex: 1; }
  .content-bar { flex-direction: column; align-items: flex-start; }
  .page-desc { display: none; }
  .user-text { display: none; }
}

.title-block {
  min-width: 0;
}

.title-block .subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  white-space: normal;
  overflow: visible;
  line-height: 1.6;
}

.title-block .subnav span {
  white-space: normal;
  flex-shrink: 0;
}

.title-block .subnav i {
  font-style: normal;
  flex-shrink: 0;
}