/* =============================================================
   QC Corporate — Design Tokens & komponen dasar
   (kesepakatan DES–DEV: kontras tinggi outdoor, font ≥16px,
    touch target ≥48px, tema clean industrial)
   ============================================================= */

:root {
  --primary: #1E40AF;          /* biru korporat */
  --primary-dark: #172554;
  --accent: #2563EB;           /* CTA */
  --accent-hover: #1D4ED8;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #111827;
  --text-muted: #475569;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --error-border: #FECACA;
  --success: #16A34A;
  --success-bg: #F0FDF4;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 24px rgba(15, 23, 42, 0.12);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;               /* font bodi minimal 16px */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text); font-weight: 700; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout dasar ---- */
.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  flex: 1;
}
.container-wide { max-width: 960px; }

/* ---- Kartu ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ---- Form ---- */
.field { margin-bottom: 16px; }
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
label .hint { font-weight: 400; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  height: 48px;                       /* touch target ≥48px */
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
input[aria-invalid="true"] {
  border-color: var(--error);
}
input:disabled { opacity: 0.6; background: var(--bg); }

.input-group { position: relative; }
.input-group input { padding-right: 52px; }
.input-group .toggle-password {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.input-group .toggle-password:hover { background: var(--bg); }

.micro-error {
  color: var(--error);
  font-size: 14px;
  margin-top: 6px;
  display: none;
}
.field.has-error .micro-error { display: block; }
.field.has-error input { border-color: var(--error); }

/* ---- Tombol ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-outline {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover:not(:disabled) { background: #EFF6FF; }

.btn-danger-outline {
  background: var(--surface);
  color: var(--error);
  border-color: var(--error);
}
.btn-danger-outline:hover:not(:disabled) { background: var(--error-bg); }

.btn-block { width: 100%; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
.btn-outline .spinner { border-color: rgba(30, 64, 175, 0.3); border-top-color: var(--primary); }
.btn-danger-outline .spinner { border-color: rgba(220, 38, 38, 0.3); border-top-color: var(--error); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Alert / banner ---- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: flex; align-items: flex-start; gap: 8px; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.alert-info { background: var(--warning-bg); color: var(--warning); border: 1px solid #FDE68A; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #BBF7D0; }

/* ---- Pita status koneksi ---- */
.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.net-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.net-pill.online .dot { background: var(--success); }
.net-pill.online { color: var(--success); border-color: #BBF7D0; background: var(--success-bg); }
.net-pill.offline .dot { background: var(--error); }
.net-pill.offline { color: var(--error); border-color: var(--error-border); background: var(--error-bg); }

/* ---- Pilihan metode masuk (Password / PIN) ---- */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.mode-btn {
  flex: 1;
  min-height: 48px;
  font: inherit;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mode-btn.is-active {
  background: #EFF6FF;
  border-color: var(--accent);
  color: var(--primary);
}

/* ---- Header halaman ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 70; /* R-24: di atas semua overlay/dim (40/50/60/90) */
  /* R-23/24: pastikan bar TIDAK melebar (scroll-h) tetapi dropdown
     tetap tampil penuh (overflow VISIBLE — bukan hidden). */
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow: visible;
  flex-wrap: nowrap;
}

/* R-24: logo PLN Icon Plus di header */
.brand-logo-img {
  height: 28px;
  width: auto;
  flex-shrink: 0;
  display: block;
}
.brand { min-width: 0; }
.brand > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* R-23: menu hamburger */
.btn-menu-hamburger {
  margin-left: auto;
  flex-shrink: 0;
  touch-action: manipulation; /* R-24: hilangkan delay 300ms & double-tap zoom */
  -webkit-user-select: none;
  user-select: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.menu-dropdown {
  position: absolute;
  top: 58px;
  right: 12px;
  z-index: 80;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-dropdown[hidden] { display: none !important; }
.menu-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
}
.menu-dropdown button:hover { background: #F1F5F9; }

/* R-24: status Online di dalam dropdown */
.menu-dropdown .menu-status {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex;
}
.menu-dropdown .net-pill {
  width: 100%;
  justify-content: center;
}
.menu-dropdown .net-pill .dot { display: inline-block; }

/* R-23: tombol bar lama (Keluar/Ganti PIN) disembunyikan — digantikan
 * menu hamburger; tetap ada di DOM sebagai fallback. */
#btn-logout { display: none; }
/* Body anti-scroll-h (pengganti overflow:hidden pada topbar). */
body { overflow-x: hidden; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary); }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.brand-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.brand small { display: block; font-weight: 500; color: var(--text-muted); font-size: 12px; line-height: 1.2; margin-top: 1px; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 20px; }
/* R-21: logo resmi PLN Icon Plus (menempati slot yang disiapkan). */
.login-brand .brand-logo-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
}
.login-brand .brand-logo-slot img {
  max-width: 240px;
  width: 100%;
  height: auto;
  display: block;
}
.login-brand h1 { margin-top: 12px; }
.login-brand p { color: var(--text-muted); margin: 0; }
.login-footer {
  margin-top: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* ---- Tabel admin ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 0 8px; max-width: 100%; } /* ruang scroll agar tidak menempel pinggir */
.table-wrap table { min-width: 560px; } /* scroll horizontal nyaman di 360px (Opsi 1 DES) */

/* R-25: daftar QC FS ringkas — muat di layar HP (360px), kolom status terjangkau */
.table-wrap .table-daftar { min-width: 320px; width: 100%; font-size: 11px; table-layout: fixed; }
.table-daftar th, .table-daftar td { padding: 4px 5px; overflow: hidden; text-overflow: ellipsis; }
.table-daftar th:nth-child(1), .table-daftar td:nth-child(1) { width: 22%; }
.table-daftar th:nth-child(2), .table-daftar td:nth-child(2) { width: 28%; }
.table-daftar th:nth-child(3), .table-daftar td:nth-child(3) { width: 20%; }
.table-daftar th:nth-child(4), .table-daftar td:nth-child(4) { width: 18%; }
.table-daftar th:nth-child(5), .table-daftar td:nth-child(5) { width: 12%; }
.table-daftar .badge { font-size: 10px; white-space: nowrap; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
/* Paginasi (R-12): maks 10 baris/halaman, nav ramah HP */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; }
.pagination button { min-width: 40px; min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr.survey-readonly { cursor: default; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); background: var(--bg); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.badge-fs { background: #EFF6FF; color: var(--primary); }
.badge-ptl { background: #F0FDF4; color: var(--success); }
.badge-admin { background: #F5F3FF; color: #6D28D9; }
.badge-aktif { background: var(--success-bg); color: var(--success); }
.badge-nonaktif { background: var(--error-bg); color: var(--error); }
.badge-status { background: var(--bg); color: var(--text-muted); }

/* ---- Grid aksi role home ---- */
.role-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 8px;
}
.role-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.role-tile:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); text-decoration: none; }
.role-tile .icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: #EFF6FF;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex: none;
}
.role-tile .tile-title { font-weight: 700; }
.role-tile .tile-desc { font-size: 14px; color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .role-tiles { grid-template-columns: repeat(2, 1fr); }
}
