/* Layout for the public viewer pages: top header and tabs, full-width content.
   Loaded after each page's own styles, so these rules take precedence. */

:root {
  --vw-bg: #f3f6fb;
  --vw-surface: #ffffff;
  --vw-surface-2: #f7f9fc;
  --vw-text: #1c2536;
  --vw-muted: #5c6a80;
  --vw-line: #e2e8f1;
  --vw-accent: #1557d6;
  --vw-hero: linear-gradient(120deg, #0b2a6b 0%, #1557d6 60%, #0a8fc4 100%);
  --vw-shadow: 0 6px 22px rgba(16, 38, 84, .07);
}

[data-bs-theme="dark"] {
  --vw-bg: #0e1524;
  --vw-surface: #172136;
  --vw-surface-2: #1e2a42;
  --vw-text: #e7ecf5;
  --vw-muted: #9fadc4;
  --vw-line: #2c3a55;
  --vw-accent: #6ea2ff;
  --vw-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}

body.viewer {
  background: var(--vw-bg);
  color: var(--vw-text);
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- Header ---------- */
.vw-header { position: relative; z-index: 1030; }

.vw-topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 32px;
  background: var(--vw-hero);
  color: #fff;
}

.vw-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  margin-right: auto;
  color: #fff;
  text-decoration: none;
}

.vw-brand:hover { color: #fff; }

.vw-brand img {
  flex: none;
  width: 52px;
  height: 52px;
  padding: 3px;
  border-radius: 50%;
  background: #fff;
}

.vw-brand strong {
  display: block;
  font: 700 1.2rem/1.25 'Poppins', 'Inter', sans-serif;
}

.vw-brand small {
  display: block;
  font-size: .82rem;
  color: rgba(255, 255, 255, .82);
}

.vw-clock {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.vw-time {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(4, 14, 40, .55);
  font-family: 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
}

.vw-time #vwTime {
  font-size: 1.35rem;
  font-weight: 700;
  color: #03dbfc;
}

.vw-ampm {
  font-size: .8rem;
  font-weight: 700;
  color: #ffb38a;
}

.vw-date {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
}

.vw-date small {
  display: block;
  font-weight: 500;
  color: rgba(255, 255, 255, .82);
}

.vw-date .fa-circle { font-size: .55rem; vertical-align: 1px; }
.vw-date .fa-circle.open { color: #4ade80; }
.vw-date .fa-circle.evening { color: #fbbf24; }
.vw-date .fa-circle.off { color: #cbd5e1; }

.vw-theme {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.vw-theme:hover { background: rgba(255, 255, 255, .15); }

/* ---------- Tabs ---------- */
.vw-tabs {
  display: flex;
  gap: 4px;
  padding: 0 32px;
  background: var(--vw-surface);
  border-bottom: 1px solid var(--vw-line);
  box-shadow: 0 2px 10px rgba(16, 38, 84, .05);
  overflow-x: auto;
  scrollbar-width: none;
}

.vw-tabs::-webkit-scrollbar { display: none; }

.vw-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 14px 16px 12px;
  border-bottom: 3px solid transparent;
  color: var(--vw-muted);
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.vw-tab:hover { color: var(--vw-accent); }

.vw-tab.active {
  border-bottom-color: var(--vw-accent);
  color: var(--vw-accent);
}

/* ---------- Page frame ---------- */
body.viewer .main-content {
  flex: 1;
  width: 100%;
  max-width: 1680px;
  min-height: 0;
  margin: 0 auto !important;
  padding: 24px 32px;
  background: transparent;
}

body.viewer .main-content > .container-fluid { padding: 0; }

body.viewer .main-container {
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

/* Hero banner, the same on every page */
body.viewer .page-header {
  margin-bottom: 22px;
  padding: 26px 32px;
  border: 0;
  border-radius: 18px;
  background: var(--vw-hero);
  color: #fff;
  box-shadow: var(--vw-shadow);
}

body.viewer .page-header h1,
body.viewer .page-title {
  margin: 0 0 4px;
  background: none;
  color: #fff;
  -webkit-text-fill-color: #fff;
  font: 700 2rem/1.2 'Poppins', 'Inter', sans-serif;
}

body.viewer .page-header p,
body.viewer .page-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, .85);
  font-size: 1rem;
}

/* ---------- Surfaces ---------- */
body.viewer .stats-card,
body.viewer .table-container {
  border-radius: 16px;
  background: var(--vw-surface);
  color: var(--vw-text);
  box-shadow: var(--vw-shadow);
}

body.viewer .table-container { padding: 18px 20px; }

/* Stat cards: one slim row. Icon | label and notes | number */
body.viewer .stats-container {
  gap: 14px;
  margin-bottom: 16px;
}

body.viewer .stats-card {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 1px;
  padding: 10px 16px;
  border-radius: 12px;
}

body.viewer .stats-card:hover { transform: none; }

body.viewer .stats-header { display: contents; }

body.viewer .stats-header > div:first-child {
  grid-column: 2 / 4;
  grid-row: 1;
  min-width: 0;
}

body.viewer .stats-icon {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
  margin: 0;
  border-radius: 10px;
  font-size: 1rem;
}

body.viewer .stats-title {
  margin: 0;
  color: var(--vw-muted);
  font-size: .74rem;
  letter-spacing: .4px;
}

body.viewer .stats-value {
  grid-column: 4;
  grid-row: 1 / 3;
  margin: 0;
  color: var(--vw-text);
  font-size: 1.7rem;
  line-height: 1;
}

body.viewer .stats-subtext {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  color: var(--vw-muted);
  font-size: .76rem;
}

body.viewer .stats-trend {
  grid-column: 3;
  grid-row: 2;
  margin: 0;
  font-size: .76rem;
}

/* ---------- Company cards ----------
   The markup stays a table so DataTables can search and page it.
   CSS draws each row as a card. */
.vw-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.vw-filter button {
  padding: 7px 14px;
  border: 1px solid var(--vw-line);
  border-radius: 20px;
  background: var(--vw-surface);
  color: var(--vw-muted);
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
}

.vw-filter button:hover { border-color: var(--vw-accent); color: var(--vw-accent); }

.vw-filter button.active {
  border-color: var(--vw-accent);
  background: var(--vw-accent);
  color: #fff;
}

.vw-filter span {
  margin-left: 6px;
  opacity: .75;
  font-weight: 500;
}

body.viewer table.vw-cards {
  display: block;
  width: 100% !important;
  margin: 12px 0 !important;
  border: 0;
}

/* Hidden on screen, still read by screen readers */
body.viewer table.vw-cards > thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

body.viewer table.vw-cards > tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  border: 0;
}

body.viewer table.vw-cards > tbody > tr {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--vw-line);
  border-top: 4px solid #94a3b8;
  border-radius: 14px;
  background: var(--vw-surface);
  box-shadow: 0 2px 8px rgba(16, 38, 84, .05);
}

body.viewer table.vw-cards > tbody > tr:hover { box-shadow: 0 8px 20px rgba(16, 38, 84, .12); }

body.viewer table.vw-cards > tbody > tr[data-status="accredited"],
body.viewer table.vw-cards > tbody > tr[data-status="partner"] { border-top-color: #22a559; }

body.viewer table.vw-cards > tbody > tr[data-status="expired"],
body.viewer table.vw-cards > tbody > tr[data-status="not_accredited"] { border-top-color: #dc3545; }

body.viewer table.vw-cards > tbody > tr > td {
  display: block;
  width: auto !important;
  max-width: none !important;
  padding: 0;
  overflow: visible !important;
  border: 0;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--vw-text);
  font-size: .86rem;
  white-space: normal !important;
}

/* A row number means nothing on a card */
body.viewer table.vw-cards > tbody > tr > td:first-child:not(.dataTables_empty) { display: none; }

/* Company name above the status */
body.viewer table.vw-cards > tbody > tr > td:nth-child(3) { order: -2; }
body.viewer table.vw-cards > tbody > tr > td:nth-child(2) { order: -1; }

/* Labelled lists sit at the bottom of the card */
body.viewer table.vw-cards td[data-label] {
  padding-top: 7px;
  border-top: 1px dashed var(--vw-line);
}

body.viewer table.vw-cards td[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 4px;
  color: var(--vw-muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

body.viewer table.vw-cards td.dataTables_empty {
  padding: 30px;
  text-align: center;
}

body.viewer table.vw-cards > tbody > tr:has(td.dataTables_empty) {
  grid-column: 1 / -1;
  border-top-width: 1px;
}

body.viewer .company-name {
  max-width: none !important;
  overflow: visible !important;
  color: var(--vw-accent);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal !important;
}

body.viewer .company-info {
  max-width: none !important;
  overflow: visible !important;
  color: var(--vw-muted);
  font-size: .85rem;
  line-height: 1.4;
  white-space: normal !important;
  word-break: break-word;
}

body.viewer .status-badge {
  align-self: flex-start;
  padding: 2px 9px;
  font-size: .68rem;
  white-space: nowrap;
}

body.viewer .accreditation-info {
  margin-top: 3px;
  color: var(--vw-muted);
  font-size: .74rem;
  line-height: 1.35;
}

body.viewer .accreditation-info span { display: block; }
body.viewer .accreditation-date { color: var(--vw-muted); }

body.viewer .email-display { padding: 3px 6px; }

body.viewer .email-text {
  max-width: none !important;
  overflow: hidden;
  font-size: .85rem;
  text-overflow: ellipsis;
  white-space: nowrap !important;
}

body.viewer .btn-copy-email {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: .72rem;
}

body.viewer .vacancy-tag,
body.viewer .qualification-tag,
body.viewer .service-tag,
body.viewer .job-tag {
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}

body.viewer .dataTables_wrapper .dataTables_length,
body.viewer .dataTables_wrapper .dataTables_filter,
body.viewer .dataTables_wrapper .dataTables_info { color: var(--vw-muted); }

/* ---------- Footer ---------- */
.vw-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  border-top: 1px solid var(--vw-line);
  background: var(--vw-surface);
  color: var(--vw-muted);
  font-size: .85rem;
}

.vw-footer a {
  color: var(--vw-accent);
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Smaller screens ---------- */
@media (max-width: 1100px) {
  .vw-topbar { flex-wrap: wrap; padding: 12px 20px; }
  .vw-brand { flex: 1 1 calc(100% - 60px); }
  .vw-clock { order: 3; flex: 1 1 100%; }
  .vw-tabs { padding: 0 12px; }
  body.viewer .main-content { padding: 16px 20px; }
  .vw-footer { padding: 14px 20px; }
}

@media (max-width: 576px) {
  .vw-brand strong { font-size: 1rem; }
  .vw-brand small { font-size: .74rem; }
  .vw-brand img { width: 44px; height: 44px; }
  .vw-time #vwTime { font-size: 1.1rem; }
  .vw-date { font-size: .8rem; }
  body.viewer .main-content { padding: 12px; }
  body.viewer .page-header { padding: 20px; }
  body.viewer .page-header h1,
  body.viewer .page-title { font-size: 1.5rem; }
  body.viewer .table-container { padding: 12px; }
}

@media print {
  .vw-header, .vw-footer { display: none; }
}

[data-bs-theme="dark"] .email-display,
[data-bs-theme="dark"] .btn-copy-email {
  background: var(--vw-surface-2) !important;
  border-color: var(--vw-line) !important;
  color: var(--vw-text) !important;
}

/* Icon stays beside the text when a line wraps */
body.viewer table.vw-cards .company-info {
  display: flex;
  gap: 8px;
}

body.viewer table.vw-cards .company-info > i {
  flex: none;
  width: 16px;
  margin-top: 3px;
  text-align: center;
}

body.viewer .stats-trend { white-space: nowrap; }
