:root {
  --color-primary: #004e34;
  --color-primary-dark: #001a0f;
  --color-accent: #84d7ae;
  --color-background: #f8f9ff;
  --color-surface: #ffffff;
  --color-ink: #0b1c30;
  --color-muted: #6f7a72;
  --color-outline-variant: #d0d8d3;
  --color-error: #ba1a1a;
  --color-error-bg: #ffdad6;
  --radius-card: 16px;
  --radius-control: 10px;
  --shadow-card: 0 1px 4px rgba(11, 28, 48, 0.06), 0 8px 24px rgba(11, 28, 48, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: var(--color-background);
  color: var(--color-ink);
  margin: 0;
  min-height: 100vh;
}

h1, h2 {
  font-family: 'Public Sans', ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }

a {
  color: var(--color-primary);
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  -webkit-font-smoothing: antialiased;
}

/* ---- Sidebar (admin pages) ---- */
:root {
  --sidebar-w: 240px;
}

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Public Sans', sans-serif;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  color: #fff;
}

.sidebar-brand .brand-name {
  color: #fff;
  font-family: 'Public Sans', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  line-height: 1.2;
}

.sidebar-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.main-with-sidebar {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.page-header {
  padding: 28px 32px 0;
}

.page-header h1 {
  font-size: 22px;
}

.page-header .page-sub {
  color: var(--color-muted);
  font-size: 13.5px;
  margin-top: 4px;
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 4px 10px;
  }
  .sidebar-nav {
    flex-direction: row;
  }
  .main-with-sidebar {
    margin-left: 0;
  }
}

/* ---- Page shell ---- */
.page {
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.page.centered {
  min-height: 100vh;
  align-items: center;
}

/* ---- Card ---- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 32px;
  max-width: 420px;
  width: 100%;
}

.card.wide {
  max-width: 100%;
}

.card .top-accent {
  height: 4px;
  margin: -32px -32px 24px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent) 70%);
}

.card-sub {
  color: var(--color-muted);
  font-size: 13.5px;
  margin: 6px 0 0;
}

.content-wrap {
  margin: 0 auto;
  padding: 28px 32px 60px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  text-decoration: none;
  margin-bottom: 18px;
}

/* ---- Status / message banners ---- */
.status {
  color: var(--color-muted);
  font-size: 13.5px;
  margin: 4px 0 0;
}

#nama-sesi,
#status {
  text-align: center;
}

.message {
  margin-top: 18px;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  display: none;
}

.message:not(:empty) {
  display: block;
}

.message.success {
  background: #e3f4ea;
  color: #0f5132;
  border-left: 3px solid var(--color-primary);
}

.message.error {
  background: var(--color-error-bg);
  color: #93000a;
  border-left: 3px solid var(--color-error);
}

/* ---- Form fields ---- */
form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.input-wrap {
  border-bottom: 1.5px solid var(--color-outline-variant);
  transition: border-color 0.2s;
  padding-bottom: 8px;
}

.input-wrap:focus-within {
  border-bottom-color: var(--color-primary);
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  color: var(--color-ink);
  padding: 4px 0;
}

input::placeholder {
  color: #b8c4bd;
}

button[type="submit"],
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-control);
  padding: 13px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 78, 52, 0.2);
  transition: transform 0.15s, box-shadow 0.2s, background 0.15s;
}

button[type="submit"]:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 78, 52, 0.28);
}

button:disabled {
  background: #c3cac5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: #eef2ee;
  color: var(--color-primary);
  border: none;
  border-radius: var(--radius-control);
  padding: 8px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #e0e8e2;
}

/* ---- Camera preview (student page) ---- */
/* Positioned off-screen (not display:none) so the browser keeps decoding
   real video frames for canvas capture, while staying invisible to the user. */
/* Kept within the viewport (not off-screen) but invisible via opacity —
   some mobile browsers pause/throttle camera auto-exposure for elements
   positioned outside the visible viewport, even when not display:none. */
.camera-preview {
  position: fixed;
  top: 0;
  left: 0;
  width: 160px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.camera-preview video {
  display: block;
  width: 100%;
  height: auto;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

th {
  text-align: left;
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--color-outline-variant);
}

td {
  padding: 12px;
  font-size: 13.5px;
  border-bottom: 1px solid #eef1ee;
}

tbody tr:hover {
  background: #f4f7f4;
}

.absensi-row {
  cursor: pointer;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

/* ---- Dashboard stat cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.stat-card {
  max-width: none;
}

.stat-icon {
  color: var(--color-primary);
  background: #e3f4ea;
  border-radius: 10px;
  padding: 8px;
  font-size: 22px;
}

.stat-value {
  font-family: 'Public Sans', sans-serif;
  font-weight: 700;
  font-size: 30px;
  color: var(--color-ink);
  margin-top: 16px;
}

.stat-label {
  color: var(--color-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 28, 48, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 32px;
  max-width: 420px;
  width: 100%;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  padding: 4px;
  display: flex;
}

.modal-close:hover {
  color: var(--color-ink);
}

/* ---- Session list row actions ---- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.buka {
  background: #e3f4ea;
  color: #0f5132;
}

.status-pill.tutup {
  background: #f1f1f1;
  color: var(--color-muted);
}

/* ---- Detail panel ---- */
#detail-panel {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid #eef1ee;
}

#detail-panel-body {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

#detail-foto {
  display: block;
  width: 220px;
  flex-shrink: 0;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

#detail-map {
  flex: 1;
  min-width: 280px;
}

#detail-map,
#overview-map {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ---- QR result ---- */
#qr-result {
  margin-top: 20px;
}

#qr-result img {
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  margin-top: 10px;
}

#qr-result p {
  font-size: 13.5px;
  word-break: break-all;
}
