/* =========================================================
   Persamaan Antigores - Tema terang (putih + biru langit), mobile-first
   ========================================================= */

/* ==== Font: Plus Jakarta Sans (self-hosted, variable font 400-800) ==== */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('./assets/fonts/PlusJakartaSans-Variable.woff2') format('woff2-variations'),
       url('./assets/fonts/PlusJakartaSans-Variable.woff2') format('woff2');
}

:root {
  --bg: #ffffff;
  --bg-elevated: #f1f7fe;
  --bg-card: #ffffff;
  --border: #dbeafe;
  --text: #0f172a;
  --text-dim: #64748b;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --accent-antigores: #0ea5e9;
  --accent-hp: #16a34a;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* ==== Ionicons (inline SVG) ==== */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

button, input, select, textarea {
  font-family: inherit;
}

/* ==== Header ==== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
}

.header-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-logout:active {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ==== View container ==== */
.view {
  min-height: 100vh;
  padding: 16px 16px calc(96px + var(--safe-bottom));
}

.view.no-nav {
  padding-bottom: 24px;
}

/* ==== Bottom nav ==== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.nav-item {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px 8px;
  font-size: 11px;
}

.nav-item .nav-icon {
  font-size: 20px;
}

.nav-item.active {
  color: var(--primary);
}

/* ==== Login ==== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  gap: 24px;
}

.login-logo {
  width: 110px;
  height: 110px;
  border-radius: 26px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.25);
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  margin-top: -12px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
}

/* ==== Form elements ==== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 14px;
  border-radius: 10px;
  font-size: 16px;
  width: 100%;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

select[multiple] {
  min-height: 160px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  min-height: 50px;
}

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

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:active {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 10px 12px;
  font-size: 14px;
  min-height: 40px;
  border-radius: 10px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

/* ==== Search / Home ==== */
.search-bar {
  position: relative;
  margin-bottom: 12px;
}

.search-bar input {
  padding-left: 42px;
  font-size: 16px;
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.filter-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-antigores);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.06);
}

.result-card.card-hp {
  border-left-color: var(--accent-hp);
}

.result-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.result-title {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==== Logo merek (dipakai di hasil pencarian & daftar admin) ==== */
/* Background sengaja putih solid (bukan var(--bg-elevated)) karena logo upload umumnya PNG transparan */
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 15px;
}

.item-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  color: var(--accent-antigores);
  white-space: nowrap;
}

.result-badge .icon {
  font-size: 12px;
}

.result-badge.badge-hp {
  background: rgba(22, 163, 74, 0.12);
  color: var(--accent-hp);
}

.result-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.result-related {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.result-related-label {
  color: var(--text-dim);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
  font-size: 14px;
}

.empty-state .empty-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
}

/* ==== Page header (admin list pages) ==== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-header h2 {
  margin: 0;
  font-size: 19px;
}

/* ==== Admin item cards ==== */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.06);
}

.item-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.item-card-with-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-title {
  font-weight: 700;
  font-size: 15px;
}

.item-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.item-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.item-actions .btn {
  flex: 1;
}

.role-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.12);
  color: var(--accent-hp);
}

.role-tag.role-user {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-dim);
}

/* ==== FAB (tambah data) ==== */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(84px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 26px;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:active {
  background: var(--primary-dark);
}

/* ==== Modal form (tambah/edit) ==== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}

.modal-sheet {
  background: var(--bg-elevated);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 16px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 4px;
}

.hp-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.hp-checklist label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  padding: 4px 0;
}

.hp-checklist input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ==== Upload logo merek ==== */
.logo-upload {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-upload-preview {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 26px;
  overflow: hidden;
  flex-shrink: 0;
}

.logo-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions .btn {
  flex: 1;
}

/* ==== Toast ==== */
.toast {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  transition: transform 0.25s ease;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.toast-error {
  border-color: var(--danger);
  color: var(--danger-dark);
}

.toast.toast-success {
  border-color: var(--accent-hp);
  color: #15803d;
}

/* ==== Install button ==== */
.btn-install {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 14px;
  z-index: 90;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==== Update button (muncul saat ada versi baru service worker) ==== */
.btn-update {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 14px;
  z-index: 91;
  background: var(--accent-hp);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Kalau tombol install juga sedang tampil, geser tombol update ke bawahnya supaya tidak tumpang tindih */
.btn-install:not(.hidden) ~ .btn-update:not(.hidden) {
  top: calc(58px + var(--safe-top));
}

/* ==== Loading spinner ==== */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(14, 165, 233, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* Di dalam tombol berwarna solid (primary/danger), spinner butuh warna putih supaya kontras */
.btn-primary .spinner,
.btn-danger:active .spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}

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

.center-loading {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

/* ==== Small screens tuning ==== */
@media (min-width: 480px) {
  .view {
    max-width: 480px;
    margin: 0 auto;
  }
  .app-header, .bottom-nav {
    max-width: 480px;
    margin: 0 auto;
  }
}
