/* CHS-SRAMS application shell */
html, body { height: 100%; }
body.app-body { font-family: var(--chs-font, system-ui); background: #f4f6f8; }

/* Branding settings: current/new image thumbnails */
.branding-thumb { height: 48px; max-width: 130px; object-fit: contain; }
.evidence-thumb { max-height: 150px; max-width: 240px; object-fit: cover; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .375rem; }
.evidence-mini-frame { position: relative; width: 240px; height: 150px; overflow: hidden; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .375rem; background: #f8f9fa; }
.evidence-mini-frame iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.evidence-mini-frame .evidence-open { position: absolute; inset: 0; }

/* User avatars (photo or initials circle) — shared across topbar, profile and admin lists */
.chs-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex: 0 0 auto; vertical-align: middle; overflow: hidden; }
.chs-avatar-initials { color: #fff; font-weight: 600; line-height: 1; text-transform: uppercase; }
.chs-avatar-ring { box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.08); }
.profile-avatar-lg { box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* PDF preview modal fills most of the viewport */
.pdf-modal-dialog { height: 92vh; }
.pdf-modal-dialog .modal-content { height: 100%; }


.btn-primary {
  background-color: var(--chs-primary); border-color: var(--chs-primary);
}
.btn-primary:hover, .btn-primary:focus { filter: brightness(1.1); background-color: var(--chs-primary); border-color: var(--chs-primary); }
.btn { border-radius: var(--chs-radius); }
a { color: var(--chs-secondary); }
.text-primary-chs { color: var(--chs-primary) !important; }
.bg-primary-chs { background-color: var(--chs-primary) !important; }

.app-wrapper { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 240px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-dark { background: var(--chs-sidebar); color: #e8eef0; }
.sidebar-dark .nav-link { color: #cfd8dc; }
.sidebar-dark .nav-link:hover, .sidebar-dark .nav-link.active { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-light { background: #fff; border-right: 1px solid #e0e0e0; }
.sidebar-light .nav-link { color: #37474f; }
.sidebar-light .nav-link:hover { background: #f1f3f4; }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem; font-weight: 700; font-size: 1.05rem; }
.sidebar-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; }
.sidebar-logo-placeholder {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--chs-accent); color: #333; border-radius: 6px; font-size: 1.2rem;
}
.sidebar-nav .nav-link { padding: .55rem 1rem; font-size: .92rem; border-radius: 0; }
.sidebar-nav .nav-link i { width: 1.4rem; display: inline-block; }

.app-main { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem;
  background: var(--chs-header, #fff); border-bottom: 1px solid #e0e0e0; position: sticky; top: 0; z-index: 1030;
}
.topbar-search { max-width: 320px; }
.app-content { padding: 1.25rem; flex-grow: 1; }
.app-footer { padding: .75rem 1.25rem; font-size: .8rem; color: #78909c; border-top: 1px solid #e0e0e0; background: #fff; }

/* Horizontal top navigation (NavPosition = top | both) */
.app-topmenu { border-bottom: 1px solid #e0e0e0; }
.app-topmenu.topmenu-dark { background: var(--chs-sidebar); }
.app-topmenu.topmenu-light { background: #fff; }
.topmenu-nav { display: flex; flex-wrap: wrap; gap: .1rem; padding: .25rem .75rem; }
.topmenu-nav .nav-link { padding: .4rem .75rem; font-size: .9rem; border-radius: var(--chs-radius, .375rem); white-space: nowrap; }
.topmenu-nav .nav-link i { margin-right: .3rem; }
.topmenu-dark .nav-link { color: #cfd8dc; }
.topmenu-dark .nav-link:hover, .topmenu-dark .nav-link.active { color: #fff; background: rgba(255,255,255,.10); }
.topmenu-light .nav-link { color: #37474f; }
.topmenu-light .nav-link:hover, .topmenu-light .nav-link.active { background: #f1f3f4; color: var(--chs-primary); }

/* Sticky toggle: when nav is not sticky, let the page scroll normally */
.app-wrapper:not(.nav-sticky) .app-sidebar { position: static; height: auto; }
.app-wrapper:not(.nav-sticky) .app-topbar { position: static; }
.app-wrapper.nav-sticky .app-topmenu { position: sticky; top: 0; z-index: 1020; }

@media (max-width: 991.98px) {
  .topmenu-nav { flex-direction: column; }
}

.stat-card { border: 0; border-left: 4px solid var(--chs-primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: transform .12s ease, box-shadow .12s ease; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: #263238; }
.stat-card .stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #78909c; }
a > .stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.stat-card .stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; font-size: 1.25rem; flex: 0 0 auto; background: rgba(27,94,32,.1); color: var(--chs-primary); }
.stat-card.stat-success { border-left-color: #2e7d32; } .stat-card.stat-success .stat-icon { background: rgba(46,125,50,.12); color: #2e7d32; }
.stat-card.stat-warning { border-left-color: #f9a825; } .stat-card.stat-warning .stat-icon { background: rgba(249,168,37,.15); color: #f57f17; }
.stat-card.stat-danger  { border-left-color: #c62828; } .stat-card.stat-danger .stat-icon { background: rgba(198,40,40,.12); color: #c62828; }
.stat-card.stat-info    { border-left-color: #1565c0; } .stat-card.stat-info .stat-icon { background: rgba(21,101,192,.12); color: #1565c0; }

/* Dashboard welcome banner */
.dashboard-hero { background: linear-gradient(135deg, var(--chs-primary) 0%, var(--chs-secondary) 100%); color: #fff; border-radius: .75rem; }
.dashboard-hero .btn-light { --bs-btn-bg: rgba(255,255,255,.92); --bs-btn-border-color: transparent; }

/* Dashboard charts: fixed-height responsive box (Chart.js runs with maintainAspectRatio:false) */
.chart-box { position: relative; height: 260px; }

/* Public pages: uploaded organisation logo in the navbar and landing hero */
.navbar-logo { height: 36px; width: auto; max-width: 140px; object-fit: contain; }
.hero-logo {
  height: 92px; width: auto; max-width: 200px; object-fit: contain;
  background: rgba(255,255,255,.94); border-radius: 14px; padding: .5rem .75rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.table-responsive { background: #fff; border-radius: .5rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.table > :not(caption) > * > * { padding: .55rem .75rem; }
th a { text-decoration: none; color: inherit; }
.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.badge { font-weight: 500; }
.empty-state i { opacity: .35; }

.landing-hero {
  background: linear-gradient(135deg, var(--chs-primary) 0%, var(--chs-secondary) 100%);
  color: #fff; padding: 4rem 1rem; border-radius: .75rem;
}
.landing-hero .display-5 { font-weight: 700; }

/* ---- 3D hero carousel (uploaded slides rotate behind the hero content) ---- */
.landing-hero.has-slides { position: relative; overflow: hidden; }
.landing-hero .hero-content { position: relative; z-index: 3; }
.hero-slides {
  position: absolute; inset: 0; z-index: 1;
  perspective: 1600px; transform-style: preserve-3d;
}
.hero-slide {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transform: rotateY(24deg) translateZ(-260px) scale(.94);
  transform-origin: center;
  transition: transform 1.25s cubic-bezier(.55, .06, .28, .99), opacity 1.1s ease, visibility 0s linear 1.25s;
  will-change: transform, opacity;
  backface-visibility: hidden;
}
.hero-slide.is-active {
  opacity: 1; visibility: visible; z-index: 2;
  transform: rotateY(0deg) translateZ(0) scale(1);
  transition-delay: 0s;
}
.hero-slide.is-leaving {
  opacity: 0; visibility: visible; z-index: 1;
  transform: rotateY(-24deg) translateZ(-260px) scale(.96);
}
.hero-slide-bg {
  position: absolute; inset: -4%;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  image-rendering: auto;
}
.hero-slide-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(rgba(14, 38, 20, .55), rgba(10, 30, 16, .68));
}
.hero-slide.is-active .hero-slide-bg { animation: hero-ken-burns 9s ease-out forwards; }
@keyframes hero-ken-burns {
  from { transform: scale(1); }
  to   { transform: scale(1.1) translateY(-1.5%); }
}
.hero-caption {
  position: absolute; bottom: 2.1rem; left: 1rem; right: 1rem; z-index: 2;
  color: #fff; font-size: .95rem; font-weight: 500; text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .65);
}
.hero-dots {
  position: absolute; bottom: .85rem; left: 0; right: 0; z-index: 4;
  display: flex; justify-content: center; gap: .5rem;
}
.hero-dot {
  width: 10px; height: 10px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.85); background: transparent;
  transition: background .3s ease, transform .3s ease; cursor: pointer;
}
.hero-dot.active { background: #fff; transform: scale(1.25); }
@media (prefers-reduced-motion: reduce) {
  .hero-slide { transition: opacity .6s ease; transform: none; }
  .hero-slide.is-active, .hero-slide.is-leaving { transform: none; }
  .hero-slide.is-active .hero-slide-bg { animation: none; }
}

/* ---- Login background slideshow (cross-fade + slow zoom behind the sign-in card) ---- */
.login-bg-stack { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.login-bg {
  position: absolute; inset: -3%;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  opacity: 0; transition: opacity 2s ease; will-change: opacity, transform;
}
.login-bg.is-active { opacity: 1; animation: login-slow-zoom 12s ease-out forwards; }
@keyframes login-slow-zoom {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}
.login-bg-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(rgba(10, 25, 14, .45), rgba(10, 25, 14, .58));
}
@media (prefers-reduced-motion: reduce) {
  .login-bg.is-active { animation: none; }
}

/* ---- Appearance settings: contextual per-asset previews ---- */
.asset-mock { border: 1px dashed #cfd8dc; border-radius: .5rem; padding: .5rem .65rem; margin-top: .35rem; background: #fafbfc; }
.asset-mock .mock-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: #90a4ae; display: block; margin-bottom: .3rem; }
.mock-sidebar { display: flex; align-items: center; gap: .5rem; border-radius: .4rem; padding: .45rem .6rem; font-weight: 700; font-size: .9rem; }
.mock-sidebar img, .mock-sidebar .mock-logo-ph { width: 28px; height: 28px; object-fit: contain; border-radius: 5px; background: #fff; }
.mock-logo-ph { display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; color: #333; }
.mock-tab { display: inline-flex; align-items: center; gap: .45rem; background: #e9edf0; border: 1px solid #d5dbe0; border-bottom: 0; border-radius: .55rem .55rem 0 0; padding: .35rem .8rem; font-size: .8rem; color: #37474f; max-width: 100%; }
.mock-tab img { width: 16px; height: 16px; object-fit: contain; }
.mock-tab .mock-tab-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-doc { background: #fff; border: 1px solid #e0e4e8; border-radius: .35rem; padding: .5rem .65rem; }
.mock-doc-head { display: flex; align-items: center; gap: .5rem; }
.mock-doc-head img, .mock-doc-head .mock-logo-ph { width: 34px; height: 34px; object-fit: contain; }
.mock-doc-org { font-weight: 700; font-size: .82rem; line-height: 1.15; }
.mock-doc-sub { font-size: .72rem; color: #78909c; }
.mock-doc-rule { height: 2px; margin-top: .4rem; border-radius: 1px; }
.mock-letterhead { display: flex; align-items: center; gap: .6rem; }
.mock-letterhead img { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 4px; }
/* Mini previews of the hero carousel / login slideshow inside settings */
.hero-mini { position: relative; overflow: hidden; border-radius: .5rem; height: 130px; perspective: 1000px; transform-style: preserve-3d; }
.hero-mini .hero-caption { font-size: .72rem; bottom: .5rem; }
.hero-mini-title { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .95rem; text-shadow: 0 1px 4px rgba(0,0,0,.6); pointer-events: none; }
.login-mini { position: relative; overflow: hidden; border-radius: .5rem; height: 130px; }
.login-mini-card { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; }
.login-mini-card > div { background: rgba(255,255,255,.96); border-radius: .4rem; padding: .45rem .9rem; font-size: .72rem; box-shadow: 0 2px 8px rgba(0,0,0,.25); text-align: center; }
.colour-reset { line-height: 1; padding: 0 .3rem; }
.countdown-box { background: rgba(255,255,255,.15); border-radius: .5rem; padding: .75rem 1rem; min-width: 84px; text-align: center; }
.countdown-box .num { font-size: 1.8rem; font-weight: 700; }
.section-title { border-left: 4px solid var(--chs-accent); padding-left: .75rem; margin: 2rem 0 1rem; }

.qr-scan-region { max-width: 480px; margin: 0 auto; }
.recording-indicator {
  display: inline-flex; align-items: center; gap: .5rem; color: #d32f2f; font-weight: 600;
}
.recording-indicator .dot {
  width: 12px; height: 12px; border-radius: 50%; background: #d32f2f; animation: pulse-rec 1.2s infinite;
}
@keyframes pulse-rec { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* Landing-page province & agency logo marquee (pure CSS, no JS).
   Each group = big provincial flag on top, member-agency logos in a row underneath. */
.chs-logo-marquee { --chs-marquee-duration: 40s; --chs-logo-h: 56px; --chs-flag-h: 110px; }
.chs-marquee-title { letter-spacing: .06em; }
/* Data-driven totals: provinces on record + member agencies on record. */
.chs-marquee-stats { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.chs-stat-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; color: var(--chs-primary, var(--bs-primary, #1b5e20)); background: rgba(0, 0, 0, .04); border: 1px solid rgba(0, 0, 0, .1); border-radius: 999px; padding: .25rem .75rem; }
.chs-marquee-viewport { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.chs-marquee-track { display: flex; align-items: flex-start; gap: 4rem; width: max-content; animation: chs-marquee-scroll var(--chs-marquee-duration) linear infinite; padding: .25rem 0; }
.chs-marquee-viewport:hover .chs-marquee-track { animation-play-state: paused; }
.chs-marquee-group { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: .55rem; }
.chs-marquee-flag img { height: var(--chs-flag-h); width: auto; max-width: 280px; object-fit: contain; border-radius: .375rem; box-shadow: 0 2px 10px rgba(0,0,0,.12); transition: transform .2s ease; }
.chs-marquee-flag img:hover { transform: scale(1.05); }
.chs-group-name { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color, #6c757d); }
/* Per-province agency tally shown on the flag banner. */
.chs-group-count { font-size: .66rem; font-weight: 600; color: #fff; background: var(--chs-primary, var(--bs-primary, #1b5e20)); border-radius: 999px; padding: .12rem .55rem; line-height: 1.2; }
.chs-group-agencies { display: flex; align-items: flex-start; gap: 1.4rem; }
.chs-marquee-item { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .3rem; }
.chs-marquee-item img { height: var(--chs-logo-h); width: auto; max-width: 180px; object-fit: contain; transition: transform .2s ease; }
.chs-marquee-item img:hover { transform: scale(1.08); }
/* Agencies without an uploaded logo still fly with their province, as an initials monogram. */
.chs-agency-monogram { height: var(-agency-monogram { filter: grayscale(1); opacity: .75; }
.chs-logo-marquee.is-grayscale .chs--chs-logo-h); width: var(--chs-logo-h); display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--chs-primary, var(--bs-primary, #1b5e20)); color: #fff; font-weight: 700; font-size: calc(var(--chs-logo-h) * .3); letter-spacing: .03em; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.chs-agency-name { font-size: .68rem; color: var(--bs-secondary-color, #6c757d); max-width: 130px; text-align: center; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.chs-logo-marquee.is-grayscale .chs-marquee-item img,
.chs-logo-marquee.is-grayscale .chs-marquee-flag img { filter: grayscale(1); opacity: .75; }
.chs-logo-marquee.is-grayscale .chs-marquee-item img:hover,
.chs-logo-marquee.is-grayscale .chs-marquee-flag img:hover { filter: grayscale(0); opacity: 1; }
@keyframes chs-marquee-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Aeroplane style: a big plane tows the provincial flag banner; agency logos hang tied beneath it. */
.chs-style-plane { animation: chs-fly-bob 7s ease-in-out infinite; }
.chs-marquee-track > .chs-style-plane:nth-child(2n) { animation-delay: -2.4s; }
.chs-marquee-track > .chs-style-plane:nth-child(3n) { animation-delay: -4.8s; }
.chs-plane-row { display: flex; align-items: center; }
.chs-plane { color: var(--chs-primary, var(--bs-primary, #1b5e20)); line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.2)); }
.chs-plane .bi { font-size: calc(var(--chs-flag-h) * .8); display: block; transform: rotate(-90deg); }
.chs-tow-line { width: 3rem; border-top: 2px dashed rgba(0,0,0,.35); margin: 0 .2rem; flex: 0 0 auto; }
.chs-flag-banner { background: #fff; border: 1px solid rgba(0,0,0,.15); border-radius: .4rem; padding: .55rem .8rem .45rem; box-shadow: 0 5px 16px rgba(0,0,0,.16); display: flex; flex-direction: column; align-items: center; gap: .3rem; transform-origin: left center; animation: chs-banner-sway 5.5s ease-in-out infinite; }
.chs-flag-banner .chs-marquee-flag img { box-shadow: none; border-radius: .25rem; }
/* Hang the agency logos under the banner (offset past the plane + tow rope), each tied by a string. */
.chs-style-plane .chs-group-agencies { margin-left: calc(var(--chs-flag-h) * .8 + 3.6rem); margin-top: .55rem; }
.chs-style-plane .chs-marquee-item::before { content: ""; width: 1px; height: 16px; background: rgba(0,0,0,.3); }
@keyframes chs-fly-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes chs-banner-sway { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(1.4deg); } }
@media (prefers-reduced-motion: reduce) {
  .chs-marquee-track { animation: none; flex-wrap: wrap; justify-content: center; gap: 2rem 4rem; width: 100%; }
  .chs-style-plane, .chs-flag-banner { animation: none; }
}

@media print {
  .app-sidebar, .app-topbar, .app-footer, .breadcrumb, .btn, .no-print, .toast-container { display: none !important; }
  .app-content { padding: 0; }
  body.app-body { background: #fff; }
  .table-responsive { box-shadow: none; }
}

@media (max-width: 991px) {
  .app-sidebar { position: fixed; z-index: 1040; height: 100vh; }
}
