/* =============================================
   style.css — CSS Gabungan Sistem ID Card
   Berlaku untuk: admin.php, index.php (form),
   generate_qr.php, cetak_idcard.php
   Tema: Merah | Responsif semua layar
   ============================================= */

/* === RESET & ROOT === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Warna utama merah */
  --primary:      #8B0000;
  --primary-dark: #6B0000;
  --primary-light:#B22222;
  --accent:       #C0392B;
  --accent-light: #E74C3C;

  /* Warna netral */
  --bg:           #f5f0f0;
  --bg-card:      #ffffff;
  --text:         #2d2d2d;
  --text-muted:   #718096;
  --border:       #e2d5d5;
  --light:        #fdf0f0;

  /* Status */
  --danger:       #e53e3e;
  --success:      #38a169;
  --warning:      #d69e2e;
  --info:         #3b7dd8;

  /* Ukuran */
  --radius:       10px;
  --radius-lg:    14px;
  --shadow-sm:    0 2px 6px rgba(139,0,0,.08);
  --shadow-md:    0 4px 12px rgba(139,0,0,.12);
  --shadow-lg:    0 8px 24px rgba(139,0,0,.16);
}

html { font-size: 16px; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* === TOPBAR ADMIN === */
.topbar {
  background: var(--primary);
  color: #fff;
  padding: .85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar h1  { font-size: .95rem; font-weight: 700; letter-spacing: .3px; }
.topbar a   { color: #ffcdd2; font-size: .82rem; }
.topbar a:hover { color: #fff; text-decoration: none; }

/* === CONTAINER === */
.container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* === STAT CARDS === */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--primary);
  transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .num  { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-card .lbl  { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.num-total    { color: var(--primary); }
.num-baru     { color: var(--danger); }
.num-diproses { color: var(--warning); }
.num-selesai  { color: var(--success); }
.num-rating   { color: var(--info); }

/* === TABS === */
.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.tab {
  padding: .5rem 1.1rem;
  border-radius: 20px;
  font-size: .83rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  transition: all .15s;
  white-space: nowrap;
}
.tab:hover  { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === CARD / PANEL === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--border);
  flex-wrap: wrap;
  gap: .5rem;
  background: #fff9f9;
}
.card-header h2 { font-size: .92rem; color: var(--primary); font-weight: 700; }

/* === TABEL === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th {
  background: #fff5f5;
  padding: .65rem .9rem;
  text-align: left;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid #f5c6c6;
  white-space: nowrap;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .3px;
}
td {
  padding: .65rem .9rem;
  border-bottom: 1px solid #fdf0f0;
  vertical-align: middle;
}
tr:hover td { background: #fff9f9; }
tr:last-child td { border-bottom: none; }

/* === BADGE === */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-baru     { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }
.badge-diproses { background: #fffff0; color: #975a16; border: 1px solid #f6e05e; }
.badge-selesai  { background: #e6f4ea; color: #276749; border: 1px solid #9ae6b4; }
.badge-jenis    { background: #fff5f5; color: var(--primary); border: 1px solid #f5c6c6; }
.badge-kode     { background: var(--light); color: var(--accent); border: 1px solid #f5c6c6; font-family: monospace; }

/* === BINTANG RATING === */
.stars { color: #f6ad55; letter-spacing: 1px; }

/* === FORM UPDATE STATUS === */
.status-form { display: flex; gap: 4px; align-items: center; }
.status-form select {
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  font-size: .78rem;
  cursor: pointer;
  font-family: inherit;
}
.status-form button {
  padding: 4px 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: .78rem;
  cursor: pointer;
  font-weight: 600;
}
.status-form button:hover { background: var(--primary); }

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: center;
}
.filter-bar select,
.filter-bar input[type=text] {
  padding: .5rem .8rem;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  font-size: .84rem;
  font-family: inherit;
  background: #fff;
  flex: 1;
  min-width: 140px;
  max-width: 220px;
}
.filter-bar select:focus,
.filter-bar input:focus { outline: none; border-color: var(--accent); }
.filter-bar button {
  padding: .5rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: .84rem;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.filter-bar button:hover { background: var(--primary-dark); }
.filter-bar a {
  padding: .5rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .84rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.filter-bar a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* === NOTIFIKASI === */
.notif {
  padding: .85rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .87rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.notif-ok   { background: #e6f4ea; border: 1.5px solid #9ae6b4; color: #276749; }
.notif-info { background: #fff5f5; border: 1.5px solid #f5c6c6; color: var(--primary); }
.notif-warn { background: #fffff0; border: 1.5px solid #f6e05e; color: #744210; }
.notif-error{ background: #fff5f5; border: 1.5px solid #feb2b2; color: #c53030; }

/* === TOMBOL GENERATE QR === */
.btn-qr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--primary);
  background: #fff;
  color: var(--primary);
  transition: all .15s;
  white-space: nowrap;
}
.btn-qr:hover   { background: var(--primary); color: #fff; }
.btn-qr.loading { opacity: .6; cursor: wait; }
.btn-qr.done    { border-color: var(--success); color: var(--success); background: #e6f4ea; cursor: default; }
.btn-qr.gagal   { border-color: var(--danger); color: var(--danger); background: #fff5f5; }

/* Status QR */
.qr-status { font-size: .74rem; font-weight: 600; }
.qr-ada    { color: var(--success); }
.qr-tidak  { color: var(--danger); }

/* === FORM TAMBAH PETUGAS (admin) === */
.form-tambah {
  padding: 1.25rem;
  border-bottom: 1.5px solid var(--border);
  background: #fff9f9;
}
.form-tambah h3 { font-size: .9rem; color: var(--primary); margin-bottom: .85rem; font-weight: 700; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .65rem;
  margin-bottom: .75rem;
}
.form-row input {
  padding: .5rem .8rem;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  font-size: .84rem;
  font-family: inherit;
  width: 100%;
  background: #fff;
}
.form-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,0,0,.08);
}
.btn-tambah {
  padding: .55rem 1.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-tambah:hover { background: var(--primary-dark); }

/* === LOGIN === */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8B0000 0%, #C0392B 100%);
  padding: 1rem;
}
.login-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo .icon { font-size: 2.5rem; }
.login-box h2 {
  color: var(--primary);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  text-align: center;
  line-height: 1.4;
}
.login-box label {
  display: block;
  font-size: .84rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}
.login-box input[type=text],
.login-box input[type=password] {
  width: 100%;
  padding: .7rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  margin-bottom: 1rem;
  background: #fafafa;
}
.login-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,0,0,.1);
  background: #fff;
}
.login-box button[type=submit] {
  width: 100%;
  padding: .8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
.login-box button[type=submit]:hover { background: var(--primary-dark); }
.login-error {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  color: #c53030;
  padding: .7rem 1rem;
  border-radius: 7px;
  margin-bottom: 1rem;
  font-size: .84rem;
}
.login-note {
  font-size: .74rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1rem;
  line-height: 1.6;
}

/* === FORM KELUHAN (index.php) === */
.form-page-bg {
  background: linear-gradient(135deg, #fdf0f0 0%, #fff5f5 100%);
  min-height: 100vh;
  padding: 1.5rem 1rem;
}
.wrapper { max-width: 520px; margin: 0 auto; }

.header-instansi {
  text-align: center;
  padding: 1.25rem 1rem 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.header-instansi h2 { font-size: .98rem; font-weight: 700; letter-spacing: .4px; }
.header-instansi p  { font-size: .77rem; opacity: .85; margin-top: 3px; }

.card-petugas {
  background: #fff;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 2px solid var(--light);
}
.foto-placeholder {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--light);
  border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.foto-petugas {
  width: 60px; height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  flex-shrink: 0;
}
.info-petugas h3 { font-size: 1rem; color: var(--primary); font-weight: 700; }
.info-petugas p  { font-size: .81rem; color: var(--text-muted); margin-top: 2px; }
.badge-kode-petugas {
  display: inline-block; margin-top: 5px;
  padding: 2px 10px;
  background: var(--light);
  color: var(--accent);
  border-radius: 20px;
  font-size: .73rem;
  font-family: monospace;
  font-weight: 700;
}

.form-card {
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}
.form-title {
  font-size: .97rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--light);
}
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-group input[type=text],
.form-group input[type=tel],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: #fafafa;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,0,0,.1);
  background: #fff;
}
.form-group input[readonly] {
  background: #fff5f5;
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: #f5c6c6;
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* Rating bintang */
.rating-wrap {
  display: flex;
  gap: .35rem;
  flex-direction: row-reverse;
  justify-content: flex-end;
}
.rating-wrap input { display: none; }
.rating-wrap label {
  font-size: 2rem; color: #d1d9e0; cursor: pointer; line-height: 1;
  font-weight: 400; transition: color .15s; margin-bottom: 0;
}
.rating-wrap input:checked ~ label,
.rating-wrap label:hover,
.rating-wrap label:hover ~ label { color: #f6ad55; }

.btn-submit {
  width: 100%;
  padding: .85rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
  margin-top: .5rem;
  letter-spacing: .3px;
}
.btn-submit:hover  { background: var(--primary-dark); }
.btn-submit:active { transform: scale(.99); }

/* Alert */
.alert { padding: 1rem 1.25rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem; font-weight: 500; }
.alert-success { background: #e6f4ea; border: 1.5px solid #9ae6b4; color: #276749; }
.alert-error   { background: #fff5f5; border: 1.5px solid #feb2b2; color: #c53030; }

.footer-note {
  text-align: center;
  font-size: .73rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
  line-height: 1.6;
}

/* Halaman sukses */
.sukses-wrap {
  text-align: center;
  padding: 2.5rem 1.5rem;
}
.sukses-wrap .icon { font-size: 3rem; margin-bottom: 1rem; }
.sukses-wrap h2 { color: var(--success); margin-bottom: .5rem; }
.sukses-wrap p  { color: var(--text-muted); line-height: 1.7; font-size: .9rem; }
.sukses-ref {
  margin-top: 1.25rem;
  padding: .85rem 1rem;
  background: var(--light);
  border-radius: 8px;
  font-size: .84rem;
  color: var(--primary);
}

/* === TOMBOL UMUM === */
.btn {
  display: inline-block;
  padding: .65rem 1.4rem;
  border-radius: 8px;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; text-decoration: none; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* === AKSI TABEL (kolom aksi) === */
.aksi-grup {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}
.aksi-link {
  font-size: .76rem;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.aksi-link:hover { text-decoration: underline; }
.aksi-link.merah { color: var(--danger); }

/* === GENERATE QR PAGE === */
.qr-ringkasan {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.qr-stat {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
  min-width: 120px;
  border-top: 3px solid var(--primary);
}
.qr-stat .num { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.qr-stat .lbl { font-size: .76rem; color: var(--text-muted); margin-top: 3px; }
.qr-stat.skip .num { color: var(--text-muted); }
.qr-stat.error .num { color: var(--danger); }

.section-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 1.5rem 0 .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.qr-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--primary);
}
.qr-card.skip { border-top-color: var(--border); opacity: .75; }
.qr-card img  { width: 130px; height: 130px; border: 2px solid var(--light); border-radius: 7px; margin-bottom: .6rem; }
.qr-card h3   { font-size: .85rem; color: var(--primary); font-weight: 700; margin-bottom: .25rem; }
.qr-card .kode { font-size: .73rem; color: var(--text-muted); font-family: monospace; margin-bottom: .4rem; }
.qr-card a    { font-size: .71rem; color: var(--accent); word-break: break-all; }

/* === RESPONSIVE === */

/* Tablet (≤ 900px) */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .container { padding: 0 .85rem; }
}

/* Mobile besar (≤ 600px) */
@media (max-width: 600px) {
  html { font-size: 15px; }

  .topbar { padding: .75rem 1rem; }
  .topbar h1 { font-size: .88rem; }

  .container { padding: 0 .75rem; margin: 1rem auto; }

  .stats { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
  .stat-card { padding: .85rem .75rem; }
  .stat-card .num { font-size: 1.6rem; }

  .tabs { gap: .4rem; }
  .tab  { padding: .45rem .85rem; font-size: .78rem; }

  /* Tabel scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: .78rem; min-width: 600px; }
  th, td { padding: .55rem .7rem; }

  /* Filter bar stack vertikal */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select,
  .filter-bar input[type=text] { max-width: 100%; }

  /* Form tambah petugas */
  .form-row { grid-template-columns: 1fr; }

  /* Login */
  .login-box { padding: 2rem 1.25rem; }

  /* Form keluhan */
  .wrapper { max-width: 100%; }
  .form-card { padding: 1.25rem 1rem; }
  .card-petugas { padding: 1rem; }
  .foto-placeholder, .foto-petugas { width: 52px; height: 52px; }

  /* QR grid */
  .qr-grid { grid-template-columns: repeat(2, 1fr); }
  .qr-ringkasan { gap: .65rem; }

  /* Aksi kolom tabel */
  .aksi-grup { flex-direction: row; flex-wrap: wrap; }

  .btn { padding: .6rem 1.1rem; font-size: .83rem; }
}

/* Mobile kecil (≤ 380px) */
@media (max-width: 380px) {
  html { font-size: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tabs .tab { font-size: .74rem; padding: .4rem .75rem; }
  .qr-grid { grid-template-columns: 1fr 1fr; }
  .login-box { padding: 1.75rem 1rem; }
}