/* ============================================================================
   MH-PDPA-Sign Admin Dashboard — Desktop-first
   ============================================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #834c9e;
  --primary-light: #a06ab8;
  --green: #38a169;
  --yellow: #d69e2e;
  --red: #e53e3e;
  --orange: #dd6b20;
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-500: #718096;
  --gray-700: #4a5568;
  --gray-800: #2d3748;
  --gray-900: #1a202c;
  --white: #fff;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

/* --------------- Login --------------- */
#login-view {
  max-width: 400px;
  margin: 120px auto;
  text-align: center;
  padding: 40px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-logo { max-width: 220px; margin-bottom: 20px; }
#login-view h1 { font-size: 20px; margin-bottom: 8px; color: var(--primary); }
#login-view p { color: var(--gray-500); margin-bottom: 24px; }
.error { color: var(--red); margin-top: 12px; font-size: 13px; }

/* --------------- Buttons --------------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-success { background: var(--green); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-warning { background: var(--orange); color: var(--white); }
.btn-outline { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* --------------- Navbar --------------- */
#navbar {
  display: flex;
  align-items: center;
  background: var(--gray-900);
  color: var(--white);
  padding: 0 20px;
  height: 48px;
  gap: 4px;
}
.nav-logo { height: 28px; margin-right: 16px; background: var(--white); padding: 4px 10px; border-radius: 6px; }
.nav-link {
  color: var(--gray-300);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.1); color: var(--white); }
.nav-spacer { flex: 1; }
#admin-name { font-size: 12px; color: var(--gray-300); margin-right: 8px; }
#session-timer { font-size: 11px; color: var(--yellow); margin-right: 12px; }
#logout-btn { background: transparent; color: var(--gray-300); border: 1px solid var(--gray-500); }

/* --------------- Main content --------------- */
#content { max-width: 1280px; margin: 0 auto; padding: 24px 20px; }

/* --------------- Stats cards --------------- */
.stats-row { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 180px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.stat-card.green .value { color: var(--green); }
.stat-card.yellow .value { color: var(--yellow); }
.stat-card.red .value { color: var(--red); }
.stat-card.orange .value { color: var(--orange); }

/* --------------- Toolbar --------------- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="text"] {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
  width: 240px;
}
.filter-btn {
  padding: 4px 12px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  color: var(--gray-700);
}
.filter-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* --------------- Tables --------------- */
.table-wrap { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--gray-100); text-align: left; padding: 10px 12px; font-weight: 600; color: var(--gray-700); white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid var(--gray-100); }
tr:hover td { background: var(--gray-50); }
tr.clickable { cursor: pointer; }

/* --------------- Badges --------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-signed { background: #c6f6d5; color: #276749; }
.badge-pending { background: var(--gray-200); color: var(--gray-700); }
.badge-partial { background: #fefcbf; color: #975a16; }
.badge-expired { background: #fed7d7; color: #9b2c2c; }
.badge-pending_review { background: #feebc8; color: #9c4221; }
.badge-completed { background: #c6f6d5; color: #276749; }
.badge-revoked { background: #fed7d7; color: #9b2c2c; }
.badge-in_progress { background: #bee3f8; color: #2a4365; }
.badge-no_session { background: var(--gray-200); color: var(--gray-500); }
.badge-viewed { background: #bee3f8; color: #2a4365; }
.badge-scrolled { background: #bee3f8; color: #2a4365; }
.badge-invalidated { background: #fed7d7; color: #9b2c2c; }

/* --------------- Pagination --------------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 16px; align-items: center; }
.pagination button { padding: 4px 12px; border: 1px solid var(--gray-300); background: var(--white); border-radius: var(--radius); cursor: pointer; }
.pagination button.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: default; }

/* --------------- Cards / sections --------------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin-bottom: 12px; color: var(--gray-800); }
.card h3 { font-size: 14px; margin-bottom: 8px; color: var(--gray-700); }

/* --------------- Detail fields --------------- */
.field-grid { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; font-size: 13px; }
.field-label { color: var(--gray-500); font-weight: 500; }

/* --------------- Audit timeline --------------- */
.timeline { list-style: none; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.timeline .time { color: var(--gray-500); font-size: 11px; margin-right: 8px; }
.timeline .action { font-weight: 600; }
.timeline .meta { color: var(--gray-500); font-size: 11px; margin-top: 2px; }

/* --------------- Forms --------------- */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
}
.form-group textarea { min-height: 60px; resize: vertical; }

/* --------------- Upload zone --------------- */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--gray-500);
  cursor: pointer;
  transition: border-color .15s;
}
.upload-zone:hover { border-color: var(--primary); }
.upload-zone input[type="file"] { display: none; }

/* --------------- Modal --------------- */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 400px;
  max-width: 90vw;
  box-shadow: 0 10px 25px rgba(0,0,0,.15);
}
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* --------------- Responsive --------------- */
@media (max-width: 768px) {
  .stats-row { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type="text"] { width: 100%; }
  .field-grid { grid-template-columns: 1fr; }
  .modal { min-width: auto; width: 95vw; }
}
