:root {
  --blue-900: #0b2545;
  --blue-700: #13315c;
  --blue-600: #1a4d8f;
  --blue-500: #2563eb;
  --gold-500: #c9a227;
  --gold-400: #e0b93a;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e5e9f0;
  --text: #16202e;
  --text-muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 32, 63, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 32, 63, 0.08);
  --shadow-lg: 0 16px 40px rgba(11, 37, 69, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.narrow { max-width: 440px; }

.topbar {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-600));
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-400); }
.topbar nav a { color: #dbe6f6; margin-left: 16px; font-size: 0.9rem; }
.topbar nav a:hover { color: #fff; }

/* ---- Sidebar (panel admin) ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--blue-900), var(--blue-700));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.sidebar-brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; padding: 6px 10px 24px; }
.sidebar-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-400); flex-shrink: 0; box-shadow: 0 0 0 4px rgba(224,185,58,0.18); }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd8ec;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--gold-500); color: var(--blue-900); box-shadow: var(--shadow-sm); }
.sidebar-nav .nav-icon { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-logout { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.12); }
.sidebar-logout button {
  background: none; border: none; color: #dbe6f6; cursor: pointer;
  font-size: 0.88rem; padding: 8px 12px; width: 100%; text-align: left; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-logout button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.main-content { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar-brand { padding: 0; margin-right: 18px; }
  .sidebar-nav { flex-direction: row; flex: 1; overflow-x: auto; }
  .sidebar-nav a { white-space: nowrap; }
  .sidebar-logout { margin-top: 0; padding-top: 0; border-top: none; }
  .container { padding: 18px 14px 40px; }
}

/* ---- Cards, headings ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

h1, h2, h3 { color: var(--blue-900); letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.12rem; font-weight: 700; }

/* ---- Responsive form layout helpers ---- */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stat-tile .value { font-size: 1.7rem; font-weight: 800; color: var(--blue-700); }
.stat-tile .label { color: var(--text-muted); font-size: 0.85rem; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
input[type=text], input[type=url], input[type=password], input[type=datetime-local], textarea, select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
textarea { resize: vertical; min-height: 70px; }

/* ---- Password field with show/hide toggle ---- */
.password-field { position: relative; }
.password-field input { padding-right: 40px; }
.password-field .toggle-visibility {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  border-radius: 6px;
}
.password-field .toggle-visibility:hover { color: var(--blue-600); background: var(--bg); }

/* ---- Toggle switch (mis. "kunci dengan password") ---- */
.switch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 999px; transition: background 0.15s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--blue-600); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch-row .switch-label { font-size: 0.9rem; font-weight: 600; color: var(--text); cursor: pointer; }
.field-collapsible { display: none; }
.field-collapsible.open { display: flex; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
}
.btn:hover { background: var(--blue-700); text-decoration: none; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--blue-600); border: 1px solid var(--border); box-shadow: none; }
.btn.secondary:hover { background: #f0f5ff; border-color: var(--blue-500); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 12px; font-size: 0.8rem; }
.btn.icon { padding: 6px 10px; line-height: 1; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
th { color: var(--text-muted); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #f7f9fc; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge.active { background: #dcfce7; color: var(--success); }
.badge.inactive { background: #fee2e2; color: var(--danger); }
.badge.expired { background: #fef3c7; color: #92400e; }

.slug-link { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-weight: 700; color: var(--blue-700); }
.muted { color: var(--text-muted); font-size: 0.85rem; }
.error-box { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.9rem; }
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at top, var(--blue-700), var(--blue-900)); }
.center-page .card.narrow { box-shadow: var(--shadow-lg); }

/* ---- QR modal ---- */
.qr-modal-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(11, 37, 69, 0.55);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.qr-modal-backdrop.open { display: flex; }
.qr-modal {
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 320px; text-align: center; box-shadow: var(--shadow-lg);
  position: relative;
}
.qr-modal h3 { margin: 0 0 4px; }
.qr-modal .qr-slug { font-family: ui-monospace, monospace; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
.qr-modal img { width: 100%; max-width: 240px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.qr-modal .qr-actions { display: flex; gap: 8px; margin-top: 18px; }
.qr-modal .qr-actions .btn { flex: 1; justify-content: center; }
.qr-modal-close {
  position: absolute; top: 10px; right: 10px; background: none; border: none;
  font-size: 1.2rem; cursor: pointer; color: var(--text-muted); width: 30px; height: 30px; border-radius: 50%;
}
.qr-modal-close:hover { background: var(--bg); color: var(--text); }

/* ---- Microsite block builder ---- */
.block-list { display: flex; flex-direction: column; gap: 10px; }
.block-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  background: var(--bg);
}
.block-item .block-type-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--blue-600); background: #e8f0ff; padding: 3px 8px; border-radius: 999px; flex-shrink: 0;
}
.block-item .block-body { flex: 1; min-width: 0; }
.block-item .block-title { font-weight: 600; font-size: 0.92rem; }
.block-item .block-sub { color: var(--text-muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-item .block-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.block-item .block-actions form { display: inline; }
.block-item .block-actions .btn.icon { padding: 5px 9px; font-size: 0.85rem; line-height: 1; }
.block-divider-preview { border-top: 2px dashed var(--border); flex: 1; }
.block-type-picker { display: flex; gap: 8px; margin-bottom: 14px; }
.block-type-picker button {
  flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-weight: 600; font-size: 0.85rem; color: var(--text-muted);
}
.block-type-picker button.active { border-color: var(--blue-600); color: var(--blue-600); background: #eef4ff; }
.block-add-form { display: none; }
.block-add-form.active { display: block; }

@media (max-width: 640px) {
  .block-item { flex-wrap: wrap; }
  .block-item .block-actions { width: 100%; justify-content: flex-end; }
}

/* ---- Public microsite / bio page ---- */
.bio-body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 48px 16px;
  background: radial-gradient(circle at top, var(--blue-700), var(--blue-900));
}
.bio-card { width: 100%; max-width: 420px; text-align: center; color: #fff; }
.bio-avatar { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold-400); margin-bottom: 14px; background: #fff; }
.bio-name { font-size: 1.3rem; font-weight: 800; margin: 0 0 4px; }
.bio-text { color: #cbd8ec; margin: 0 0 24px; font-size: 0.95rem; }
.bio-link-btn {
  display: block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.bio-link-btn:hover { background: rgba(255,255,255,0.18); text-decoration: none; transform: translateY(-1px); }
.bio-text-block { text-align: left; margin-bottom: 16px; padding: 2px 4px; }
.bio-text-title { font-weight: 700; margin: 0 0 4px; color: #fff; font-size: 0.95rem; }
.bio-text-body { margin: 0; color: #cbd8ec; font-size: 0.9rem; white-space: pre-line; }
.bio-divider { border-top: 1px solid rgba(255,255,255,0.2); margin: 20px 0; }
.bio-footer { margin-top: 32px; font-size: 0.75rem; color: #93a5c4; }

.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin: 12px 0; }
.bar-chart .bar { flex: 1; background: var(--blue-500); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar:hover { background: var(--gold-500); }

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-0 { margin-top: 0; }

@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
}
