/* ============================================================
   STC Exit Pass — main.css
   ============================================================ */

/* ---------- Reset & base ----------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-dark:    #1a3a5c;
  --blue-mid:     #2563a8;
  --blue-light:   #e8f0fb;
  --green:        #1a7a3c;
  --green-light:  #d4f0df;
  --red:          #b91c1c;
  --red-light:    #fee2e2;
  --amber:        #b45309;
  --amber-light:  #fef3c7;
  --grey-100:     #f5f7fa;
  --grey-200:     #e5e9ef;
  --grey-400:     #9ca3af;
  --grey-700:     #374151;
  --grey-900:     #111827;
  --radius:       6px;
  --shadow:       0 1px 4px rgba(0,0,0,.12);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--grey-100);
  color: var(--grey-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ----------------------------------------- */
.site-header {
  background: var(--blue-dark);
  color: #fff;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
}
.header-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.user-info {
  font-size: .85rem;
  opacity: .85;
}

/* ---------- Footer ----------------------------------------- */
.site-footer {
  margin-top: auto;
  padding: 1rem;
  text-align: center;
  font-size: .75rem;
  color: var(--grey-400);
  border-top: 1px solid var(--grey-200);
}

/* ---------- Main content ----------------------------------- */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Flash messages --------------------------------- */
.flash-messages { margin-bottom: 1rem; }
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .9rem;
}
.flash-info    { background: var(--blue-light);   color: var(--blue-dark); }
.flash-success { background: var(--green-light);  color: var(--green); }
.flash-warning { background: var(--amber-light);  color: var(--amber); }
.flash-error   { background: var(--red-light);    color: var(--red); }

/* ---------- Buttons ---------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary   { background: var(--blue-mid); color: #fff; }
.btn-danger    { background: var(--red);      color: #fff; }
.btn-success   { background: var(--green);    color: #fff; }
.btn-outline   { background: #fff; border-color: var(--grey-200); color: var(--grey-700); }
.btn-sm        { padding: .3rem .75rem; font-size: .8rem; }
.btn-full      { width: 100%; }
.inline-form   { display: inline; }

/* ---------- Forms ------------------------------------------ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--grey-700);
}
.form-input {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: .95rem;
  background: #fff;
  color: var(--grey-900);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--blue-mid); }
.form-hint {
  display: block;
  margin-top: .3rem;
  font-size: .8rem;
  color: var(--grey-400);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
}

/* ---------- Auth pages ------------------------------------- */
.auth-container {
  max-width: 400px;
  margin: 3rem auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-title    { font-size: 1.5rem; margin-bottom: .5rem; color: var(--blue-dark); }
.auth-subtitle { font-size: .9rem; color: var(--grey-400); margin-bottom: 1.5rem; }
.auth-form     { margin-top: 1rem; }
.auth-link     { margin-top: 1rem; text-align: center; font-size: .85rem; }
.code-input    { font-size: 2rem; letter-spacing: .5rem; text-align: center; }

/* ---------- Student dashboard ------------------------------ */
.student-dashboard { max-width: 540px; margin: 0 auto; }

.student-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.student-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--grey-200);
}
.student-photo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--blue-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
}
.student-name { font-size: 1.3rem; font-weight: 700; margin-bottom: .4rem; }
.student-meta { font-size: .875rem; color: var(--grey-700); margin-bottom: .2rem; }
.meta-label   { font-weight: 600; margin-right: .3rem; }

.exit-pass-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-align: center;
}

.permission-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1.25rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1rem;
}
.permission-badge .badge-icon { font-size: 1.2rem; }
.permitted { background: var(--green-light); color: var(--green); }
.denied    { background: var(--red-light);   color: var(--red); }

.qr-container { margin-top: .5rem; }
.qr-label  { font-size: .9rem; color: var(--grey-700); margin-bottom: 1rem; }
.qr-image  { display: block; margin: 0 auto; border: 4px solid var(--grey-200); border-radius: var(--radius); }
.qr-note   { font-size: .78rem; color: var(--grey-400); margin-top: .75rem; }
.denial-reason { font-size: .9rem; color: var(--grey-700); margin-top: .5rem; }

/* ---------- Security scanner ------------------------------- */
.scan-container { max-width: 540px; margin: 0 auto; }
.scan-title     { margin-bottom: 1rem; color: var(--blue-dark); }

.camera-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 1rem;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
}
.camera-video  { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.scan-status {
  text-align: center;
  padding: .5rem;
  font-size: .9rem;
  color: var(--grey-700);
  margin-bottom: 1rem;
}

.result-overlay {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-align: center;
}
.result-overlay.hidden { display: none; }

.result-card .result-name    { font-size: 1.3rem; font-weight: 700; margin-bottom: .4rem; }
.result-card .result-meta    { font-size: .875rem; color: var(--grey-700); margin-bottom: .3rem; }
.result-card .result-photo   { width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
                                border: 3px solid var(--grey-200); margin: 0 auto 1rem; display: block; }
.result-card .result-status  { font-size: 1.1rem; font-weight: 700; margin: .75rem 0; padding: .5rem 1rem;
                                border-radius: var(--radius); display: inline-block; }
.result-card .status-ok      { background: var(--green-light); color: var(--green); }
.result-card .status-denied  { background: var(--red-light);   color: var(--red); }
.result-card .result-reason  { font-size: .875rem; color: var(--grey-700); margin-bottom: 1rem; }
.result-card .action-buttons { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Confirm page ----------------------------------- */
.confirm-container {
  max-width: 420px;
  margin: 3rem auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  text-align: center;
}
.confirm-result { margin-bottom: 1.5rem; }
.confirm-result h1 { margin-top: .5rem; }
.confirm-icon  { font-size: 3rem; display: block; }
.confirm-exit  { color: var(--green); }
.confirm-denied{ color: var(--red); }

/* ---------- Admin layout ----------------------------------- */
.admin-container { max-width: 1000px; margin: 0 auto; }
.admin-container h1 { font-size: 1.5rem; color: var(--blue-dark); margin-bottom: 1.5rem; }
.admin-container h2 { font-size: 1.1rem; color: var(--blue-dark); margin-bottom: .75rem; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.page-header h1 { margin-bottom: 0; }
.page-count { font-size: .85rem; color: var(--grey-400); }

.stats-row  { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card  {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.5rem;
  min-width: 120px;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--blue-dark); }
.stat-label { font-size: .8rem; color: var(--grey-400); }

.admin-nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.nav-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  display: block;
  color: inherit;
  border: 2px solid transparent;
  transition: border-color .15s;
}
.nav-card:hover { border-color: var(--blue-mid); text-decoration: none; }
.nav-card h2 { font-size: 1rem; color: var(--blue-dark); margin-bottom: .3rem; }
.nav-card p  { font-size: .85rem; color: var(--grey-400); }

.recent-section { margin-top: 1.5rem; }

/* ---------- Tables ----------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-size: .875rem;
}
.data-table th, .data-table td {
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--grey-200);
}
.data-table th {
  background: var(--grey-100);
  font-weight: 600;
  color: var(--grey-700);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td      { background: var(--grey-100); }

/* ---------- Badges ----------------------------------------- */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-exit    { background: var(--green-light);  color: var(--green); }
.badge-denied  { background: var(--red-light);    color: var(--red); }
.badge-return  { background: var(--blue-light);   color: var(--blue-dark); }
.badge-perm-always       { background: var(--green-light);  color: var(--green); }
.badge-perm-free_period  { background: var(--blue-light);   color: var(--blue-dark); }
.badge-perm-never        { background: var(--red-light);    color: var(--red); }

/* ---------- Search / Pagination ---------------------------- */
.search-form {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.search-input { max-width: 360px; }
.pagination {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
  justify-content: center;
}
.page-info { font-size: .85rem; color: var(--grey-400); }

/* ---------- Import page ------------------------------------ */
.import-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.import-section p { font-size: .9rem; color: var(--grey-700); margin-bottom: .75rem; }
.import-form { margin-top: .5rem; }
.refresh-results { margin-top: 1rem; }

/* ---------- Edit form ------------------------------------- */
.edit-form {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.student-meta-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .875rem; }
.meta-list dt { font-weight: 600; color: var(--grey-700); }

/* ---------- Ban alert -------------------------------------- */
.ban-active-alert {
  background: var(--red-light);
  color: var(--red);
  padding: .5rem .85rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

/* ---------- Daily schedule table --------------------------- */
.schedule-table { width: 100%; border-collapse: collapse; font-size: .875rem; margin-top: .5rem; }
.schedule-table th,
.schedule-table td { padding: .4rem .75rem; text-align: left; border-bottom: 1px solid var(--grey-200); }
.schedule-table th { font-weight: 600; color: var(--grey-700); }
.schedule-row-current td { background: var(--amber-light); font-weight: 700; }

/* ---------- Misc ------------------------------------------- */
.empty-state { color: var(--grey-400); font-style: italic; padding: 1rem 0; }
.text-muted  { color: var(--grey-400); }

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .main-content { padding: 1rem; }
  .student-card { flex-direction: column; text-align: center; }
}

/* ---------- Reports ---------------------------------------- */
.report-filter-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.report-filter-card h2 { margin-bottom: 1rem; }
.report-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}
.report-filter-row .form-group { margin-bottom: 0; min-width: 160px; }
.preset-group { display: flex; gap: .4rem; flex-wrap: wrap; }
.preset-btn {
  padding: .35rem .75rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: .85rem;
  color: var(--grey-700);
}
.preset-btn.active, .preset-btn:hover {
  background: var(--blue-mid);
  color: #fff;
  border-color: var(--blue-mid);
}
.report-print-btn { margin-bottom: 1rem; }
.group-header td {
  background: var(--blue-light);
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue-dark);
  padding: .6rem 1rem .45rem;
  border-top: 2px solid var(--blue-mid);
  letter-spacing: .01em;
}
.badge-admin    { background: var(--blue-light);  color: var(--blue-dark); }
.badge-security { background: var(--amber-light); color: var(--amber); }

@media print {
  .site-header, .site-footer, .flash-messages,
  .page-header .btn, .report-filter-card,
  .report-print-btn, .pagination { display: none !important; }

  body { background: #fff !important; color: #000 !important; }
  a    { color: #000 !important; }

  .main-content { padding: 0; max-width: 100%; }
  .admin-container { max-width: 100%; }

  .data-table {
    box-shadow: none;
    font-size: .8rem;
    background: transparent;
  }
  .data-table th, .data-table td {
    padding: .3rem .5rem;
    border-color: #bbb;
  }
  .data-table th {
    background: #eee !important;
    color: #000 !important;
  }
  .data-table tr:hover td { background: transparent !important; }

  .group-header td {
    background: none !important;
    border-top: 1.5pt solid #000 !important;
    border-bottom: 1pt solid #999 !important;
    color: #000 !important;
    font-size: .95rem;
  }

  .badge {
    background: none !important;
    color: #000 !important;
    border: 1pt solid #999;
    padding: 0 .25rem;
  }

  .table-wrap { overflow: visible; }
}
