/* =============================================================
   VISITOR MANAGEMENT SYSTEM - PT PLN (PERSERO) PUSHARLIS
   Main Stylesheet: Themes, Layout, Forms, Tables, Modals
   ============================================================= */

/* =============================================================
   1. TEMA & VARIABEL WARNA
   ============================================================= */
:root {
  --card:  #ffffff;
  --text:  #1e293b;
  --muted: #475569;
  --input: #ffffff;
  --line:  #d1d5db;
  --th:    #fff;
  --side:  #17435a;
  --bg:    #f3f6f9;
  --acc:   #1b6378;

  box-sizing: border-box;
  padding-top:    env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark mode otomatis */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg:    #11191f;
    --card:  #1f2a30;
    --text:  #eef2f3;
    --muted: #b5c0c5;
    --input: #17212626;
    --line:  #3b4a52;
  }
}

/* Dark mode manual */
:root[data-theme=dark] {
  --bg:    #11191f;
  --card:  #1f2a30;
  --text:  #eef2f3;
  --muted: #b5c0c5;
  --input: #17212626;
  --line:  #3b4a52;
}

html { scroll-padding-top: env(safe-area-inset-top, 0px); }
*    { box-sizing: border-box; }
.hide { display: none !important; }

/* =============================================================
   2. TATA LETAK UTAMA (LAYOUT)
   ============================================================= */
body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  font-family: Poppins, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

aside {
  width: 250px;
  height: 100vh;
  position: sticky;
  top: 0;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--side);
  color: #fff;
}

main {
  flex: 1;
  min-width: 0;
  padding: 28px 40px;
}

.card {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 44px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

h1 { font-size: 23px; margin: 0 0 24px; }
h2 { font-size: 20px; margin: 26px 0 12px; }

/* =============================================================
   3. BILAH SAMPING (SIDEBAR)
   ============================================================= */
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 22px 20px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
}

.brand-logo-img {
  width: 44px;
  height: auto;
  max-height: 58px;
  display: block;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

nav a {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 22px;
  color: #fff;
  font-size: 14px;
  text-decoration: none;
  opacity: .9;
}

nav a.on { background: rgba(255, 255, 255, .12); }

.me {
  width: 100%;
  margin-top: auto;
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.av {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8eef0;
  color: var(--side);
  font-weight: 600;
}

/* =============================================================
   4. FORMULIR & INPUT DATA TAMU
   ============================================================= */
label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 15px;
}

input[type=text],
input[type=date],
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select {
  cursor: pointer;
}

/* Opsi dropdown teks hitam di atas latar putih agar angka selalu terbaca jelas */
select option {
  color: #111827 !important;
  background-color: #ffffff !important;
}

input[type=text]:focus,
input[type=date]:focus,
select:focus {
  border-color: var(--acc);
  outline: none;
  box-shadow: 0 0 0 3px rgba(27, 99, 120, 0.15);
}

.bad {
  border-color: #e5483b !important;
}

.err {
  margin-top: 6px;
  color: #e5483b;
  font-size: 13px;
}

.err:empty {
  display: none;
}

.err.hint {
  color: var(--muted);
}

.btn {
  padding: 12px 28px;
  border: 0;
  border-radius: 8px;
  background: var(--acc);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn.sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn.ghost {
  background: none;
  border: 2px solid var(--acc);
  color: var(--acc);
}

.photo {
  text-align: center;
}

.ph {
  display: block;
  width: 168px;
  height: 233px;
  margin: 0 auto 14px;
  object-fit: cover;
  background: #bdbdbd;
}

/* =============================================================
   5. CHECKBOX APD (ALAT PELINDUNG DIRI)
   ============================================================= */
.apd {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-weight: 600;
  color: var(--muted);
}

.apd label {
  margin: 0;
}

.chk {
  position: relative;
  display: block;
  cursor: pointer;
}

.chk input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chk span {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
  transition: 0.15s;
}

.chk span::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--muted);
  border-radius: 6px;
  text-align: center;
  font-size: 16px;
  line-height: 18px;
}

.chk input:checked + span {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
}

.chk input:checked + span::before {
  content: "✓";
  background: #fff;
  border-color: #fff;
  color: var(--acc);
}

.chk input:focus-visible + span {
  outline: 3px solid #ffe600;
}

.chk.none input:checked + span {
  background: #c0392b;
  border-color: #c0392b;
}

.chk.none input:checked + span::before {
  color: #c0392b;
}

/* =============================================================
   6. SAFETY AND SECURITY INDUCTION (PLN PUSHARLIS)
   ============================================================= */
.induction-container {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.induction-header-text {
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.5;
}

.induction-poster-wrapper {
  max-width: 680px;
  margin: 0 auto;
  border: 2px solid #1a202c;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.induction-poster-wrapper:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.16);
}

.induction-poster-img {
  width: 100%;
  height: auto;
  display: block;
}

.induction-zoom-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.induction-poster-wrapper:hover .induction-zoom-hint {
  opacity: 1;
}

.induction-agree-box {
  max-width: 680px;
  margin: 16px auto 0;
  padding: 14px 18px;
  background: rgba(27, 99, 120, 0.05);
  border: 1px solid rgba(27, 99, 120, 0.22);
  border-radius: 8px;
}

.induction-agree-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.induction-agree-label input[type="checkbox"] {
  width: 19px;
  height: 19px;
  cursor: pointer;
  accent-color: var(--acc);
  flex-shrink: 0;
  margin: 0;
}

.induction-agree-label span {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.btn-submit {
  min-width: 240px;
  padding: 14px 42px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(27, 99, 120, 0.3);
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.btn-submit:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

/* =============================================================
   7. HALAMAN TERIMA KASIH (KONFIRMASI SUKSES)
   ============================================================= */
.thanks {
  max-width: 640px;
  margin: 8vh auto 0;
  text-align: center;
}

.thanks .tick {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--acc);
  color: #fff;
  font-size: 46px;
  animation: pop 0.5s ease-out;
}

.thanks p {
  margin: 0 0 8px;
  line-height: 1.6;
  color: var(--muted);
}

.thanks .btn {
  margin-top: 24px;
  padding: 16px 34px;
  font-size: 16px;
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* =============================================================
   8. DASHBOARD ADMIN, STATISTIK & TABEL TAMU
   ============================================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.stat {
  padding: 26px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  text-align: center;
  box-shadow: 0 1px 2px #0002;
}

.stat b {
  display: block;
  font-size: 34px;
  font-weight: 400;
  color: var(--acc);
}

.filters {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters label {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
}

.filters input {
  width: auto;
}

.filters .btn {
  margin-left: auto;
}

.tw {
  margin-top: 22px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  padding: 14px 12px;
  border-left: 1px solid #fff5;
  background: var(--acc);
  color: var(--th);
  text-align: left;
}

td {
  padding: 12px;
  border: 1px solid var(--line);
}

td.e {
  padding: 16px;
  text-align: center;
}

/* =============================================================
   9. DIALOG OVERLAY / MODAL UMUM
   ============================================================= */
#ov {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #0009;
}

.dlg {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow: auto;
  padding: 24px;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
}

/* Badges & Thumbnail Tabel Tamu */
.tb-thumb {
  width: 40px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid var(--acc);
  cursor: pointer;
  display: block;
  margin: 0 auto;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--bg);
}
.tb-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.tb-name {
  cursor: pointer;
  color: var(--pri);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.2s, text-decoration-color 0.2s;
}
.tb-name:hover {
  color: #00bcd4;
  text-decoration-color: #00bcd4;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.in {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.status-badge.done {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.status-badge.wait {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.apd-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(0, 162, 185, 0.15);
  color: #00bcd4;
  border: 1px solid rgba(0, 162, 185, 0.25);
  margin: 1px 2px;
  white-space: nowrap;
}
.apd-tag.none {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.tag-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.3);
  white-space: nowrap;
}

th, td {
  white-space: nowrap;
}
td.wrap {
  white-space: normal;
  min-width: 140px;
  max-width: 220px;
}

.dlg h2 {
  margin: 0 0 14px;
  font-size: 19px;
}

.dlg p {
  margin: 0;
  line-height: 1.5;
}

.dlg dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 14px;
}

.dlg dt {
  color: var(--muted);
}

.dlg dd {
  margin: 0;
  font-weight: 500;
  word-break: break-word;
}

.acts {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* =============================================================
   10. RESPONSIF UMUM (TABLET & MOBILE)
   ============================================================= */
@media (max-width: 800px) {
  body {
    flex-direction: column;
  }

  aside {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .brand {
    padding: 12px 16px;
  }

  .brand-logo-img {
    width: 36px;
  }

  nav {
    display: flex;
  }

  .me {
    width: auto;
    margin-left: auto;
    padding: 8px 16px;
  }

  main {
    padding: 16px;
  }

  .card {
    padding: 18px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .filters .btn {
    margin-left: 0;
  }
}
