/* ============================================================
   Repositori BBM Digital PPD Muar — gaya kongsi
   ============================================================ */
:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --text: #16233a;
  --muted: #5d6b82;
  --line: #dde4ee;
  --primary: #0f4c81;
  --primary-dark: #0b3a63;
  --primary-soft: #e3eef8;
  --accent: #f4a300;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --success: #1b7f4b;
  --success-soft: #e6f4ec;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(16, 35, 58, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- Header ---------- */
.topbar {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar img { height: 44px; width: auto; background: #fff; border-radius: 8px; padding: 3px; }
.brand { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.2; font-weight: 700; }
.brand p { margin: 2px 0 0; font-size: 12px; opacity: 0.85; }
.topnav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a {
  color: #fff; text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.35);
}
.topnav a.active, .topnav a:hover { background: rgba(255,255,255,0.18); }

.container { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }
.narrow { max-width: 760px; }

/* ---------- Kad / panel ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.card .lead { margin: 0 0 16px; color: var(--muted); }

/* ---------- Borang ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13.5px; }
.field label .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); margin: 0; }
.field input[type="text"], .field input[type="email"], .field input[type="url"],
.field input[type="date"], .field input[type="password"], .field select, .field textarea, .search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-height: 42px;
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}
.field textarea { resize: vertical; min-height: 80px; }
.field select:disabled, .field input:disabled { background: #f1f4f8; color: var(--muted); }
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-row label {
  flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600;
}
.radio-row label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.honeypot { position: absolute; left: -9999px; top: -9999px; height: 0; width: 0; overflow: hidden; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 42px;
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  border-radius: 10px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: #fff; color: var(--primary); }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1c1400; }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

.alert {
  padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; font-size: 14px;
  border: 1px solid transparent;
}
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: #f5c6c2; }
.alert.success { background: var(--success-soft); color: var(--success); border-color: #bfe3cd; }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); border-color: #c5d9ec; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary-dark);
  white-space: nowrap;
}
.badge.muted { background: #eef1f5; color: var(--muted); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: #fff4d6; color: #7a5200; }
.badge.platform { background: #fff; border: 1px solid var(--line); }

/* ---------- Galeri ---------- */
.toolbar { display: grid; grid-template-columns: 1fr; gap: 10px; }
.search { position: relative; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.filters select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 40px;
}
.toolbar-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.count { color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 4px 6px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-top: 16px; }
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px;
  min-height: 190px;
}
.item .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.item h3 { margin: 0; font-size: 16px; line-height: 1.3; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .desc { font-size: 13.5px; color: var(--text); margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.item .who { font-size: 13px; color: var(--muted); margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--line); }
.item .who b { color: var(--text); }
.item .btn { margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- Jadual admin ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; padding: 10px 14px; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--primary-soft); border-radius: 12px; padding: 12px 14px; }
.stat .n { font-size: 26px; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 900px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7f9fc; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.hidden-row td { background: #fbfbfb; color: var(--muted); }
td .sub { display: block; font-size: 12px; color: var(--muted); }
td.actions-cell { white-space: nowrap; }
td.actions-cell .btn + .btn { margin-left: 4px; }
.row-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.row-tools .search { flex: 1; min-width: 200px; }
.row-tools select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 40px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 20, 40, 0.5); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 640px;
  max-height: 92vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 12px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-box #qr { padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr-box .url { font-size: 13px; word-break: break-all; color: var(--muted); }
.login-box { max-width: 420px; margin: 40px auto; }

/* ---------- Pelbagai ---------- */
.success-panel { text-align: center; padding: 30px 10px; }
.success-panel .big { font-size: 48px; line-height: 1; }
.success-panel h2 { margin: 10px 0 6px; }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .topnav { width: 100%; justify-content: flex-start; }
  .brand h1 { font-size: 15px; }
  .card { padding: 16px; }
  .btn.block-sm { width: 100%; }
}
