/* App-specific additions on top of ds/styles.css — layout/interaction rules
   that aren't part of the design system itself. */

body { margin: 0; }

/* .card and other author rules set `display` unconditionally, which — at
   equal CSS specificity — beats the UA stylesheet's `[hidden] { display:
   none }`. Without this, `el.hidden = true` on any `class="card"` element
   (e.g. the Assistant tab's disabled-state panel) silently has no visual
   effect. */
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--color-neutral-400); }
::-webkit-scrollbar-track { background: var(--color-neutral-100); }

[data-tab-panel] { display: none; }
[data-tab-panel].is-active { display: block; }

[data-overlay] { display: none; }
[data-overlay="drawer"].is-open,
[data-overlay="docDetail"].is-open,
[data-overlay="incidentDetail"].is-open,
[data-overlay="equipmentDetail"].is-open,
[data-overlay="subDetail"].is-open { display: flex; }
[data-overlay="trail"].is-open,
[data-overlay="invite"].is-open,
[data-overlay="photo"].is-open,
[data-overlay="newDocument"].is-open,
[data-overlay="groups"].is-open,
[data-overlay="sendNotification"].is-open,
[data-overlay="addSubcontractor"].is-open,
[data-overlay="deleteCompany"].is-open,
[data-overlay="trainingTypes"].is-open,
[data-overlay="addTraining"].is-open,
[data-overlay="startInspection"].is-open,
[data-overlay="addAttendance"].is-open,
[data-overlay="editAttendance"].is-open { display: grid; }
/* Any dialog-style overlay opens as a grid even if it is missing from the
   list above, so a new dialog can't stay invisible when it is opened.
   Overlays without .dialog-backdrop (the drawers, addAttendance) still need
   their own line above. */
.dialog-backdrop[data-overlay].is-open { display: grid; }

.avatar-sm {
  width: 26px; height: 26px; flex: none; background: var(--color-neutral-200);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 10px;
}
.avatar-md {
  width: 44px; height: 44px; flex: none; background: var(--color-accent-100); color: var(--color-accent-800);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 14px;
}
.stat-icon {
  width: 44px; height: 44px; flex: none; background: var(--color-accent-100); color: var(--color-accent-700);
  display: flex; align-items: center; justify-content: center;
}
.row-line {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px 0; border-bottom: 1px solid var(--color-divider);
}
/* In drawers a list is followed by an .hr, so the last row's own border would
   draw a second line just above it. */
[data-overlay] [data-list] > .row-line:last-child { border-bottom: 0; }
.list-empty { color: color-mix(in srgb, var(--color-text) 55%, transparent); padding: var(--space-4) 0; }

/* — dashboard sidebar (dashboard.php) — */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px;
  border-radius: 9px; text-decoration: none; font-weight: 500; font-size: 13.5px;
  color: var(--sidebar-muted); transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); }
.sidebar-nav a[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-text); }

/* — per-tenant brand color, scoped to the dashboard shell only — logins
   and the platform admin area stay on the platform's own cyan (--color-accent). */
.dashboard-shell .btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--brand) 30%, transparent);
}
.dashboard-shell .btn-primary:hover {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent), 0 8px 24px color-mix(in srgb, var(--brand) 35%, transparent);
}
.dashboard-shell .card-kicker { color: var(--brand); }
.dashboard-shell .tag-outline { border-color: var(--brand); color: var(--brand); }
.dashboard-shell :focus-visible {
  outline-color: var(--brand);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent), 0 8px 24px color-mix(in srgb, var(--brand) 35%, transparent);
}
.dashboard-shell input:focus-visible, .dashboard-shell .input:focus-visible { border-color: var(--brand); }

/* — training matrix (dashboard.php) — deliberately spreadsheet-styled
   (full grid lines, frozen header row + frozen name column, dense
   center-aligned cells) rather than the app's normal borderless-row
   .table, per the client's explicit "make it look like Excel" request. */
.matrix-table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.matrix-table th, .matrix-table td {
  border-right: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}
.matrix-table th {
  position: sticky; top: 0; z-index: 2;
  padding: 7px 10px;
  background: var(--color-neutral-100);
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: none;
  color: var(--color-neutral-700); text-align: left;
}
.matrix-table td { padding: 0; text-align: center; }
.matrix-table td.matrix-cell-text { padding: 7px 10px; text-align: left; }
.matrix-table th:first-child, .matrix-table td:first-child {
  position: sticky; left: 0; z-index: 1;
  background: var(--color-bg);
  border-right: 2px solid var(--color-divider);
}
.matrix-table th:first-child { z-index: 3; background: var(--color-neutral-100); }
.matrix-table tbody tr:hover td:first-child { background: var(--color-neutral-200); }
.matrix-cell-btn {
  display: block; width: 100%; height: 100%; min-height: 38px;
  border: none; cursor: pointer; font: inherit; padding: 6px 10px;
  text-align: center; line-height: 1.25;
}
.matrix-cell-btn:hover { filter: brightness(0.94); }

/* — dashboard sidebar responsiveness — no other page in the app has a
   fixed sidebar, so this is the only place a breakpoint is needed. Below
   768px the sidebar becomes an off-canvas drawer (data-sidebar-toggle
   opens it, data-sidebar-backdrop or a nav tap closes it — wired in
   dashboard.js). */
.dash-sidebar { width: 236px; flex: none; }
.dash-sidebar-backdrop { display: none; }
.dash-sidebar-toggle { display: none; border: none; background: none; padding: 6px; cursor: pointer; color: var(--color-text); }

@media (max-width: 768px) {
  .dash-sidebar-toggle { display: inline-flex; align-items: center; }
  .dash-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 transparent;
  }
  .dash-sidebar.is-open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,0.25); }
  .dash-sidebar-backdrop.is-open {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,0.4);
  }
}

/* — scroll reveal (assets/js/reveal.js) — */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal].is-visible { opacity: 1; transform: translateY(0); }

/* Roll call: a long visitor/subcontractor label shortens with "…" instead of
   running into the site column (assets/js/dashboard.js, loadAttendance). */
.roll-badge > span { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

/* Worker and crew portal header: on a phone the name drops out and nothing
   wraps mid-word (worker/index.php, subcontractor/index.php). */
.portal-nav .nav-brand, .portal-nav a, .portal-nav .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .portal-nav { gap: var(--space-2); }
  .portal-nav .portal-user { display: none; }
  .portal-nav .portal-links { gap: var(--space-2); }
  .portal-nav .btn { padding: 6px 10px; font-size: 13px; }
  .portal-nav .nav-brand { font-size: 17px; }
  .portal-nav .portal-links a:not(.btn) { font-size: 12.5px !important; }
}

/* Signature pad (includes/signature.php render_signature_fields,
   assets/js/signature-pad.js) on every signing form. A white box with a
   faint line to sign on, tall enough for a finger on a phone. touch-action
   none so a finger on the pad draws instead of scrolling the page. The
   line is only the box's background: it is not part of the saved image. */
#sig-pad, .sig-pad {
  display: block; width: 100%; height: 180px;
  border: 1px solid var(--color-divider); border-radius: var(--radius-sm);
  background: #fff linear-gradient(#cfd8db, #cfd8db) no-repeat left 16px bottom 40px / calc(100% - 32px) 1px;
  touch-action: none; cursor: crosshair;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#clear-sig { margin-bottom: var(--space-4); }

/* Tick boxes in a list and the small hint under a field: Plant and
   equipment and the Settings card on the dashboard, and the subcontractor
   office's plant pages (subcontractor/plant.php, plant-item.php). */
.eq-hint { font-size: 11.5px; margin: 4px 0 0; }
.eq-checks { display: flex; flex-direction: column; }
.eq-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; min-height: 34px; cursor: pointer; }

/* No rule under the last permit type in Settings (assets/js/dashboard.js loadPermitSettings). */
[data-list="permitSettingRows"] > .row-line:last-child { border-bottom: 0; }

/* Privacy notice and terms of use links (login, invite, worker and
   subcontractor home), and the visitor privacy line on the kiosk. */
.policy-links { text-align: center; font-size: 12.5px; color: var(--color-neutral-600); margin: var(--space-5) 0 0; }
.policy-links a { color: inherit; }
.kiosk-privacy { font-size: 12.5px; line-height: 1.45; color: var(--color-neutral-600); margin: 0 0 var(--space-2); }
