/* assets/app.css — tampilan aplikasi jakartaelectric.pages.dev (design system Jakarta Electric). */
:root {
  --je-primary: #3366ff;
  --je-primary-hover: #254edb;
  --je-primary-soft: #eef3ff;
  --je-bg: #f0f2f5;
  --je-surface: #ffffff;
  --je-surface-muted: #f8fafc;
  --je-border: #e5e7eb;
  --je-text: #1f2937;
  --je-text-strong: #111827;
  --je-text-secondary: #475569;
  --je-text-muted: #64748b;
  --je-success: #059669;
  --je-warning: #d97706;
  --je-danger: #dc2626;
  --je-radius: 8px;
  --je-radius-lg: 12px;
  --je-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --je-shadow-lg: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --je-focus: 0 0 0 3px rgba(51, 102, 255, 0.25);
  --topbar-h: 56px;
  font-family: "Poppins", system-ui, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--je-bg);
  color: var(--je-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--je-primary);
}

button {
  font: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--je-focus);
}

/* ── Tombol ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--je-radius);
  border: 1px solid transparent;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.btn--primary {
  background: var(--je-primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--je-primary-hover);
}

.btn--outline {
  background: var(--je-surface);
  border-color: #cbd5e1;
  color: var(--je-text);
}

.btn--outline:hover {
  border-color: var(--je-primary);
  color: var(--je-primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--je-radius);
  background: transparent;
  color: var(--je-text-secondary);
  font-size: 1.1rem;
  text-decoration: none;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--je-surface-muted);
  color: var(--je-primary);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
  color: var(--je-primary);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Layar pembuka ──────────────────────────────────────── */
.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--je-surface);
  transition: opacity 0.25s ease;
}

.splash--done {
  opacity: 0;
  pointer-events: none;
}

.splash__bar {
  width: 140px;
  height: 3px;
  border-radius: 3px;
  background: var(--je-primary-soft);
  overflow: hidden;
}

.splash__bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--je-primary);
  animation: bar 1s ease-in-out infinite;
}

@keyframes bar {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(260%);
  }
}

/* ── Login ──────────────────────────────────────────────── */
.login {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 5fr) 6fr;
}

.login__brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(32px, 6vw, 80px);
  background: var(--je-primary);
  color: #fff;
}

.login__brand img {
  border-radius: 18px;
  background: #fff;
  margin-bottom: 24px;
}

.login__brand h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
  font-weight: 700;
}

.login__brand p {
  margin: 0 0 28px;
  max-width: 420px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

.login__features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.login__features li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.login__features .bi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--je-radius);
  background: rgba(255, 255, 255, 0.16);
}

.login__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login__card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  background: var(--je-surface);
  border: 1px solid var(--je-border);
  border-radius: var(--je-radius-lg);
  box-shadow: var(--je-shadow-lg);
}

.login__card h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  color: var(--je-text-strong);
}

.login__hint {
  margin: 0 0 24px;
  color: var(--je-text-muted);
  line-height: 1.5;
}

.login__google {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.login__busy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 44px;
  color: var(--je-text-secondary);
}

.login__foot {
  margin: 24px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--je-border);
  font-size: 0.85rem;
  color: var(--je-text-muted);
}

.login__copy {
  margin: 16px 0 0;
  font-size: 0.75rem;
  color: var(--je-text-muted);
}

.notice {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--je-radius);
  border: 1px solid #fecaca;
  border-left: 4px solid var(--je-danger);
  background: #fef2f2;
}

.notice--warning {
  border-color: #fde68a;
  border-left-color: var(--je-warning);
  background: #fffbeb;
}

.notice .bi {
  font-size: 1.2rem;
  color: var(--je-danger);
}

.notice--warning .bi {
  color: var(--je-warning);
}

.notice strong {
  display: block;
  color: var(--je-text-strong);
}

.notice p {
  margin: 2px 0 0;
  color: var(--je-text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

/* ── Aplikasi ───────────────────────────────────────────── */
.app,
.main {
  height: 100%;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 12px 0 16px;
  background: var(--je-surface);
  border-bottom: 1px solid var(--je-border);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--je-text-strong);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.topbar__brand img {
  border-radius: 7px;
}

/* Di Main Menu: merek mengisi ruang; di menu lain: tombol kembali + judul */
.app--home .topbar__brand {
  flex: 1;
}

.topbar__back {
  height: 34px;
  padding: 0 12px;
  font-size: 0.85rem;
}

.topbar__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--je-text-strong);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar__title .bi {
  color: var(--je-primary);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Menu akun (foto profil) */
.user-menu {
  position: relative;
  margin-left: 6px;
}

.avatar-btn {
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--je-primary-soft) center / cover no-repeat;
  color: var(--je-primary);
  font-weight: 600;
}

.user-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 260px;
  background: var(--je-surface);
  border: 1px solid var(--je-border);
  border-radius: var(--je-radius-lg);
  box-shadow: var(--je-shadow-lg);
  overflow: hidden;
}

.user-menu__info {
  padding: 14px 16px;
  border-bottom: 1px solid var(--je-border);
}

.user-menu__info strong,
.user-menu__info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__info strong {
  color: var(--je-text-strong);
}

.user-menu__info span {
  font-size: 0.8rem;
  color: var(--je-text-muted);
}

.user-menu__role {
  display: inline-block !important;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--je-primary-soft);
  color: var(--je-primary) !important;
  font-weight: 500;
}

.user-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--je-danger);
  text-align: left;
  cursor: pointer;
}

.user-menu__item:hover {
  background: #fef2f2;
}

.frame-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--je-bg);
}

.frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.frame-loading,
.frame-help {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: var(--je-bg);
  text-align: center;
  color: var(--je-text-secondary);
}

.frame-help .bi-hourglass-split {
  font-size: 2rem;
  color: var(--je-primary);
}

.frame-help h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--je-text-strong);
}

.frame-help p {
  margin: 0;
  max-width: 420px;
  line-height: 1.6;
}

.frame-help__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

/* ── Notifikasi ─────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 340px;
  max-width: 100%;
  padding: 12px 14px;
  background: var(--je-surface);
  border: 1px solid var(--je-border);
  border-left: 4px solid var(--je-primary);
  border-radius: var(--je-radius);
  box-shadow: var(--je-shadow-lg);
  animation: toastIn 0.2s ease-out;
}

.toast--success {
  border-left-color: var(--je-success);
}

.toast--warning {
  border-left-color: var(--je-warning);
}

.toast__text {
  flex: 1;
  line-height: 1.45;
}

.toast .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 0.8rem;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ── Layar kecil ────────────────────────────────────────── */
@media (max-width: 900px) {
  .login {
    grid-template-columns: 1fr;
  }

  .login__brand {
    padding: 32px 24px 28px;
  }

  .login__brand img {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
  }

  .login__brand h1 {
    font-size: 1.5rem;
  }

  .login__brand p {
    margin-bottom: 0;
  }

  .login__features {
    display: none;
  }

  .topbar {
    gap: 6px;
    padding: 0 8px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }

  .toast-stack {
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 576px) {
  /* HP: di menu lain cukup ikon panah kembali; tombol salin link disembunyikan */
  .app:not(.app--home) .topbar__brand span,
  .topbar__back span,
  #shareBtn {
    display: none;
  }

  .app:not(.app--home) .topbar__brand {
    display: none;
  }

  .topbar__back {
    width: 36px;
    padding: 0;
  }
}
