/* ============================================================
   Hospital QR System — Crextio-style redesign
   Design language: clean white panels, soft warm-yellow accents,
   large readable type, minimal borders, pill badges, sticky topbar.
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Design tokens ---------- */
:root {
  --c-bg:       #f0f0ef;       /* outer page background */
  --c-surface:  #ffffff;
  --c-panel:    #fafafa;
  --c-accent:   #F5C518;       /* warm yellow — primary action */
  --c-accent-d: #d4a900;
  --c-ink:      #1a1a1a;
  --c-ink-2:    #555555;
  --c-ink-3:    #999999;
  --c-border:   #e8e8e8;
  --c-green:    #22c55e;
  --c-green-bg: #dcfce7;
  --c-red:      #ef4444;
  --c-red-bg:   #fee2e2;
  --c-blue:     #3b82f6;
  --c-blue-bg:  #dbeafe;
  --c-amber:    #f59e0b;
  --c-amber-bg: #fef3c7;
  --c-row-hi:   #fffbea;       /* highlighted table row */

  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  18px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-ink);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { opacity: .8; }
img, svg { display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ---------- Layout shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__logo {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--c-ink);
  border: 1.5px solid var(--c-ink);
  border-radius: 20px;
  padding: 4px 14px;
  white-space: nowrap;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto;
}

.topbar__nav a {
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-ink-2);
  padding: 6px 14px;
  border-radius: 20px;
  transition: background .15s, color .15s;
}

.topbar__nav a:hover { background: var(--c-bg); color: var(--c-ink); }

.topbar__nav a.active {
  background: var(--c-ink);
  color: #fff;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  background: var(--c-surface);
  cursor: pointer;
  color: var(--c-ink-2);
  transition: border-color .15s;
}
.topbar__icon-btn:hover { border-color: var(--c-ink); color: var(--c-ink); }

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar__label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-ink-3);
  padding: 8px 10px 4px;
  margin-top: 8px;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-ink-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.sidebar__item:hover { background: var(--c-bg); color: var(--c-ink); }
.sidebar__item.active { background: var(--c-accent); color: var(--c-ink); font-weight: 600; }
.sidebar__item svg { flex-shrink: 0; }

.sidebar__spacer { flex: 1; }

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--c-border);
  margin-top: 8px;
}

.sidebar__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-ink);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name { font-size: .8rem; font-weight: 600; color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: .72rem; color: var(--c-ink-3); }

/* ---------- Main content ---------- */
.main {
  grid-area: main;
  padding: 28px 32px;
  overflow-x: hidden;
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.15;
  color: var(--c-ink);
}

.page-header .subtitle { font-size: .875rem; color: var(--c-ink-3); margin-top: 2px; }

/* ---------- Stat bars (like the Crextio progress bars) ---------- */
.stat-bars {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-bar { display: flex; align-items: center; gap: 8px; }
.stat-bar__label { font-size: .78rem; color: var(--c-ink-3); white-space: nowrap; }

.stat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 6px 18px;
  white-space: nowrap;
}

.stat-pill--dark { background: var(--c-ink); color: #fff; min-width: 80px; }
.stat-pill--yellow { background: var(--c-accent); color: var(--c-ink); min-width: 160px; }
.stat-pill--stripe {
  background: repeating-linear-gradient(
    45deg,
    var(--c-border),
    var(--c-border) 2px,
    #fff 2px,
    #fff 8px
  );
  color: var(--c-ink-2);
  min-width: 80px;
  border: 1px solid var(--c-border);
}
.stat-pill--outline { background: transparent; border: 1.5px solid var(--c-border); color: var(--c-ink-2); min-width: 90px; }

/* ---------- Filter toolbar ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, box-shadow .15s;
}
.filter-btn:hover { border-color: var(--c-ink-2); }
.filter-btn svg { width: 13px; height: 13px; }

.filter-search {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  position: relative;
}

.filter-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-ink-3);
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.filter-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-surface);
  font-size: .85rem;
  color: var(--c-ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.filter-search input:focus { border-color: var(--c-ink-2); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.filter-search input::placeholder { color: var(--c-ink-3); }

.filter-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ---------- White panel ---------- */
.panel {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------- Data table ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead tr {
  border-bottom: 1px solid var(--c-border);
}

.data-table thead th {
  font-size: .75rem;
  font-weight: 600;
  color: var(--c-ink-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 14px 16px;
  white-space: nowrap;
  background: var(--c-surface);
}

.data-table thead th:first-child { padding-left: 20px; }
.data-table thead th:last-child { padding-right: 20px; }

.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table thead th.sortable::after {
  content: ' ⇅';
  font-size: .65rem;
  opacity: .45;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--c-border);
  transition: background .12s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--c-bg); }
.data-table tbody tr.row-selected { background: var(--c-row-hi); }

.data-table tbody td {
  padding: 14px 16px;
  font-size: .875rem;
  color: var(--c-ink);
  vertical-align: middle;
}
.data-table tbody td:first-child { padding-left: 20px; }
.data-table tbody td:last-child { padding-right: 20px; }

/* Checkbox column */
.data-table .col-check { width: 40px; }
.data-table .col-check input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--c-accent);
  cursor: pointer;
}

/* Name cell with avatar */
.cell-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cell-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-accent);
  color: var(--c-ink);
  font-size: .78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.cell-avatar--dark { background: var(--c-ink); color: #fff; }

.cell-name-text { font-weight: 600; }
.cell-name-sub { font-size: .78rem; color: var(--c-ink-3); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-active  { background: var(--c-green-bg); color: #16a34a; }
.badge-active::before  { background: #16a34a; }

.badge-inactive { background: var(--c-red-bg); color: #dc2626; }
.badge-inactive::before { background: #dc2626; }

.badge-absent  { background: #f3f4f6; color: var(--c-ink-3); }
.badge-absent::before  { background: var(--c-ink-3); }

.badge-pending { background: var(--c-amber-bg); color: #d97706; }
.badge-pending::before { background: #d97706; }

.badge-embassy { background: var(--c-blue-bg); color: #2563eb; }
.badge-embassy::before { background: #2563eb; }

.badge-plain { background: var(--c-bg); color: var(--c-ink-2); }
.badge-plain::before { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--c-ink);
  color: #fff;
  border-color: var(--c-ink);
}
.btn-primary:hover { background: #333; border-color: #333; opacity: 1; }

.btn-accent {
  background: var(--c-accent);
  color: var(--c-ink);
  border-color: var(--c-accent);
}
.btn-accent:hover { background: var(--c-accent-d); border-color: var(--c-accent-d); opacity: 1; }

.btn-ghost {
  background: transparent;
  border-color: var(--c-border);
  color: var(--c-ink-2);
}
.btn-ghost:hover { border-color: var(--c-ink-2); color: var(--c-ink); opacity: 1; }

.btn-danger {
  background: var(--c-red-bg);
  border-color: var(--c-red);
  color: var(--c-red);
}
.btn-danger:hover { background: var(--c-red); color: #fff; opacity: 1; }

.btn-sm { padding: 5px 13px; font-size: .78rem; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ---------- Action icon group ---------- */
.action-group { display: flex; align-items: center; gap: 6px; }

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-ink-2);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.action-btn:hover { background: var(--c-bg); border-color: var(--c-ink-2); color: var(--c-ink); opacity: 1; }
.action-btn.danger:hover { background: var(--c-red-bg); border-color: var(--c-red); color: var(--c-red); }

/* ---------- Cards grid (stats) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card__val {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--c-ink);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card__label {
  font-size: .78rem;
  color: var(--c-ink-3);
  font-weight: 500;
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-ink-2);
}

.form-label span { color: var(--c-red); }

.form-control {
  padding: 9px 13px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--c-ink);
  background: var(--c-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus { border-color: var(--c-ink); box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.form-control::placeholder { color: var(--c-ink-3); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ---------- File upload zone ---------- */
.upload-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.upload-zone:hover { border-color: var(--c-ink-2); background: var(--c-bg); }
.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone__icon { color: var(--c-ink-3); margin: 0 auto 8px; }
.upload-zone__text { font-size: .875rem; font-weight: 600; color: var(--c-ink-2); }
.upload-zone__sub  { font-size: .78rem; color: var(--c-ink-3); margin-top: 3px; }

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 18px;
}
.alert-success { background: var(--c-green-bg); color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--c-red-bg); color: #b91c1c; border: 1px solid #fecaca; }
.alert-info    { background: var(--c-blue-bg); color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--c-amber-bg); color: #b45309; border: 1px solid #fde68a; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid var(--c-border);
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  color: var(--c-ink-2);
  border: 1px solid transparent;
  transition: all .12s;
  padding: 0 8px;
}
.page-link:hover { background: var(--c-bg); border-color: var(--c-border); opacity: 1; }
.page-link.active { background: var(--c-ink); color: #fff; border-color: var(--c-ink); }

.pagination__info { margin-left: auto; font-size: .78rem; color: var(--c-ink-3); }

/* ---------- Document slots ---------- */
.doc-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }

.doc-slot {
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
}

.doc-slot__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.doc-slot__title { font-size: .9rem; font-weight: 700; color: var(--c-ink); }

.doc-slot__meta { font-size: .78rem; color: var(--c-ink-3); margin-bottom: 4px; }

.doc-slot__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

/* ---------- Patient info grid ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 20px;
}
.info-cell__label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-ink-3); margin-bottom: 3px; }
.info-cell__val   { font-size: .9rem; color: var(--c-ink); }

/* ---------- Section card ---------- */
.section-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.section-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 700;
  font-size: .9rem;
}

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 36px;
}

.login-card__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.login-card__logo-mark {
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--c-ink);
  border-radius: 20px;
  padding: 6px 18px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.login-card .sub {
  font-size: .83rem;
  color: var(--c-ink-3);
  text-align: center;
  margin-bottom: 28px;
}

/* ---------- Verification (public) page ---------- */
.verify-page {
  min-height: 100vh;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.verify-card {
  width: 100%;
  max-width: 500px;
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px;
  text-align: center;
}

.verify-card__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 1.8rem;
}

.verify-card__icon--ok     { background: var(--c-green-bg); color: #16a34a; }
.verify-card__icon--warn   { background: var(--c-amber-bg); color: #d97706; }
.verify-card__icon--error  { background: var(--c-red-bg);   color: #dc2626; }

.verify-card h1  { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.verify-card .sub { color: var(--c-ink-3); font-size: .9rem; margin-bottom: 28px; }

.verify-table { width: 100%; border-collapse: collapse; text-align: left; margin-bottom: 24px; }
.verify-table tr { border-bottom: 1px solid var(--c-border); }
.verify-table tr:last-child { border-bottom: none; }
.verify-table td { padding: 10px 0; font-size: .875rem; }
.verify-table td:first-child { color: var(--c-ink-3); width: 45%; }
.verify-table td:last-child  { font-weight: 600; }

/* ---------- Role badge (for admin list) ---------- */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-superadmin { background: #f0fdf4; border: 1px solid #86efac; color: #16a34a; }
.role-admin      { background: var(--c-blue-bg); border: 1px solid #93c5fd; color: #1d4ed8; }
.role-viewer     { background: #f3f4f6; border: 1px solid #d1d5db; color: #6b7280; }

/* ---------- Utility ---------- */
.text-muted  { color: var(--c-ink-3); }
.text-sm     { font-size: .8rem; }
.fw-600      { font-weight: 600; }
.mt-4        { margin-top: 16px; }
.mb-4        { margin-bottom: 16px; }
.gap-2       { gap: 8px; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap   { flex-wrap: wrap; }
.w-100       { width: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar { display: none; }
  .doc-slots { grid-template-columns: 1fr; }
  .topbar__nav { display: none; }
  .main { padding: 20px 16px; }
}

@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .data-table thead th:nth-child(n+4),
  .data-table tbody td:nth-child(n+4) { display: none; }
}

/* ── Soft-deleted row ───────────────────────────────────── */
.row-deleted td { opacity: .55; }
.row-deleted .cell-name-text { text-decoration: line-through; }

/* ── Bulk bar ────────────────────────────────────────────── */
#bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--c-row-hi);
  border: 1px solid var(--c-accent);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 12px;
}
