/* =============================================================================
 * Bootstrap Visual-Class Overrides — Phase 1 Foundation
 * Source: 01-UI-SPEC.md "Bootstrap-Overrides Contract" + "Theme Toggle Contract"
 * Loaded AFTER tokens.css. Two narrow exceptions for Bootstrap utility overrides (see below).
 * ============================================================================= */

/* -- Buttons (FOUND-03) -- */
.btn-primary {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: calc(var(--radius) - 2px);
  font-weight: 500;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: hsl(var(--primary) / 0.9);
  border-color: hsl(var(--primary) / 0.9);
  color: hsl(var(--primary-foreground));
}
.btn-primary:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  box-shadow: none;
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  border-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-radius: calc(var(--radius) - 2px);
  font-weight: 500;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn-secondary:hover, .btn-secondary:focus {
  background-color: hsl(var(--secondary) / 0.8);
  border-color: hsl(var(--secondary) / 0.8);
  color: hsl(var(--secondary-foreground));
}
.btn-secondary:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  box-shadow: none;
}

.btn-outline-primary {
  color: hsl(var(--primary));
  border-color: hsl(var(--primary));
  background-color: transparent;
  border-radius: calc(var(--radius) - 2px);
}
.btn-outline-primary:hover {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-outline-secondary {
  color: hsl(var(--secondary));
  border-color: hsl(var(--secondary));
  background-color: transparent;
  border-radius: calc(var(--radius) - 2px);
}
.btn-outline-secondary:hover {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

/* .btn-outline-danger — Bootstrap default leaves the sharper .btn-sm radius,
   making Delete buttons read as a different shape from sibling
   .btn-outline-primary / .btn-outline-secondary in the same action row.
   Apply the same corner radius as the other outline variants so destructive
   outlines match their neighbours app-wide. */
.btn-outline-danger {
  border-radius: calc(var(--radius) - 2px);
}

/* .btn-danger — Bootstrap default keeps the .btn-sm radius (3.2px) which reads
   visibly sharper than .btn-primary / .btn-secondary (10px) sitting next to it
   in the same action row. Apply the same 10px corner so danger buttons (Block,
   Remove rights, future destructive actions) match their neighbours app-wide. */
.btn-danger {
  border-radius: calc(var(--radius) - 2px);
}

/* Audit Phase 6: .btn-outline-light tokenised — used by the revoke toast undo
   button which sits on a dark (--foreground) background. The "light" outline
   reads as foreground-on-foreground in light theme without explicit tokens. */
.btn-outline-light {
  color: hsl(var(--background));
  border-color: hsl(var(--background) / 0.6);
  background-color: transparent;
  border-radius: calc(var(--radius) - 2px);
}
.btn-outline-light:hover {
  background-color: hsl(var(--background) / 0.15);
  border-color: hsl(var(--background));
  color: hsl(var(--background));
}

/* -- Bootstrap utility classes declare specificity-forcing overrides; we must match -- */
.bg-primary {
  background-color: hsl(var(--primary)) !important;
}
/* 06-13: legacy theme_ssd.css:129-134 applies a heavy box-shadow to .box-shadow and .card
   via !important — Steve felt the resulting drop was too harsh ("bring them back 50%").
   Override here (loads after theme_ssd.css) at ~50% strength on each component:
     blur     0.75rem → 0.375rem
     offset   0.25rem → 0.125rem
     opacity  0.5     → 0.25
   Light-mode card surfaces sit clearly above the off-white page background, so a
   single drop shadow does the job. */
.box-shadow,
.card {
  box-shadow: 0 0.125rem 0.375rem rgba(0,0,0,0.25) !important;
}
/* 06-13: in dark mode the card token (217 45% 14%) and page background token
   (216 50% 13%) are only ~1% lightness apart — a drop shadow alone gets lost. Steve
   asked for "shadow more like a highlight to lift it off the page". Layered effect:
     · inset top edge → subtle white highlight, mimics a raised surface
     · sharper 1px drop directly below → micro-shadow for the bottom edge
     · larger soft drop → ambient depth
   No layout shift; pure visual cue. */
.dark .box-shadow,
.dark .card {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 1px 0 rgba(0,0,0,0.5),
    0 0.5rem 1rem rgba(0,0,0,0.35) !important;
}
/* 06-13: Bootstrap's default `.table { color: #212529 }` renders dark-on-dark in dark
   mode (MyDocuments file-name column was invisible — Image #35). Tokenize so the table
   text always reads against its surface. */
.table {
  color: hsl(var(--foreground));
}
.table th,
.table td {
  color: inherit;
}
/* 06-13 (pass 2): legacy theme_ssd.css pins IBM Plex Sans to a list of selectors
   (lines 85-95) and IBM Plex Serif to all headings (line 18). The Secuura brand uses
   Geist Sans for both body and display, so we re-pin the same selectors to
   var(--font-sans). Loads after theme_ssd.css via _HeadAssets.cshtml; same single-class
   specificity but later in cascade → wins, no !important needed. */
small,
.table-responsive,
.card-body,
.btn-primary,
.btn-secondary,
.btn-icon,
.badge-pill-shared-green,
.badge-pill-shared-grey,
.badge-pill-shared-blue,
.badge-pill-shared-red,
.badge-pill-shared-orange,
h1, h2, h3, h4, h5, h6,
.card-header {
  font-family: var(--font-sans);
}

/* 06-13: DataTables marks unsortable columns with .sorting_disabled but still renders
   its sort-indicator pseudo-elements (the up/down chevrons). Suppress them so the
   Actions header reads as a plain label, not a sortable column. */
table.dataTable thead th.sorting_disabled::before,
table.dataTable thead th.sorting_disabled::after,
table.dataTable thead td.sorting_disabled::before,
table.dataTable thead td.sorting_disabled::after {
  display: none !important;
  content: none !important;
}
/* 06-13: the legacy SSD icon SVGs (/wwwroot/images/icons/*.svg) are authored with
   fill="white" because the original SSD theme wanted white icons on its dark-navy
   .btn-primary (theme_ssd:435 forces #0F1B33 bg + theme_ssd:449 forces brightness(0)
   invert(1) on the icon → white). That pairing still works in light mode.
   In dark mode our .dark .btn-primary override (above) flips the bg to Secuura teal,
   so the white icon becomes white-on-teal — invisible. Map white → navy in dark mode
   only so the icon matches the navy text on the teal surface. */
.dark .btn-primary.btn-icon img {
  filter: brightness(0) saturate(100%) invert(8%) sepia(43%) saturate(2034%) hue-rotate(208deg) brightness(91%) contrast(94%);
}
.text-muted {
  color: hsl(var(--muted-foreground)) !important;
}
/* 06-13 dark/light sweep: tokenize the semantically-named "light" / "dark" Bootstrap utility
   classes. NOT tokenizing .bg-white / .text-white because some surfaces (e.g. EntraVerify QR
   code container) legitimately need a literal white background regardless of theme — those
   keep the explicit Bootstrap default. */
.bg-light {
  background-color: hsl(var(--muted)) !important;
}
.text-dark {
  color: hsl(var(--foreground)) !important;
}

/* -- Card -- */
.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
.card-header, .card-footer {
  background-color: hsl(var(--muted));
  border-color: hsl(var(--border));
}

/* -- Alert -- */
.alert {
  border-radius: var(--radius);
  border-width: 1px;
}
.alert-danger {
  background-color: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}
.alert-success {
  background-color: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--primary));
}
/* 06-13: alert-info / alert-warning / alert-light were missing from this sheet,
   so every use across the site rendered with Bootstrap's hardcoded light-blue /
   yellow / pale-gray defaults — readable in light mode but jarring in dark mode
   (e.g. Validator empty-state, /Assign legacy alert). Tokenized to match the
   alert-danger/-success pattern above. */
.alert-info {
  background-color: hsl(var(--secondary) / 0.1);
  border-color: hsl(var(--secondary) / 0.3);
  color: hsl(var(--secondary));
}
/* Audit Phase 6: .alert-warning re-tuned away from gold. Gold is reserved for
   trust claims per DESIGN.md "Gold-as-Trust Rule"; a warning is "pay attention"
   not "trust this", so it uses destructive-soft (red-tinted at low intensity)
   with foreground text. Real blockers (failed identity verification etc.)
   should use .alert-danger; .alert-warning is for soft cautions only. */
.alert-warning {
  background-color: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.35);
  color: hsl(var(--foreground));
}
.alert-light {
  background-color: hsl(var(--muted) / 0.5);
  border-color: hsl(var(--border));
  color: hsl(var(--muted-foreground));
}

/* -- Modal -- */
.modal-content {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
.modal-header, .modal-footer {
  border-color: hsl(var(--border));
}

/* -- Form control -- */
.form-control {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.form-control:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
  outline: none;
}
.form-control::placeholder {
  color: hsl(var(--muted-foreground));
}
/* 06-13: Bootstrap's default disabled / readonly form-control uses a hardcoded
   light-gray background (#e9ecef) that renders as white-on-light in dark mode —
   user can't read what's prefilled. Tokenize so it adapts. */
.form-control:disabled,
.form-control[readonly] {
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  opacity: 1;
}

/* -- Badge -- */
.badge {
  border-radius: calc(var(--radius) - 4px);
  font-weight: 600;
  font-size: 0.75rem;
}
.badge-primary, .badge.bg-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.badge-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.badge-danger {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.badge-muted {
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

/* -- Dark-mode .btn-primary contrast override (Plan 06-13).
      theme_ssd.css:435 forces .btn-primary bg to #0F1B33 with !important (legacy
      SSD brand). In dark mode the bg stays dark-navy while our base rule pulls
      text to --primary-foreground (near-black) — net dark-on-dark, ~1:1 contrast.
      Match the legacy !important so the brand primary tokens win in dark mode
      only; light mode keeps its SSD-branded button look unchanged. -- */
.dark .btn-primary,
.dark .btn-primary:focus,
.dark .btn-primary:active {
  background-color: hsl(var(--primary)) !important;
  border-color: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
}
.dark .btn-primary:hover {
  background-color: hsl(var(--primary) / 0.9) !important;
  border-color: hsl(var(--primary) / 0.9) !important;
  color: hsl(var(--primary-foreground)) !important;
}

/* -- Theme-toggle ghost button (consumed by _ThemeToggle.cshtml in Plan 04) -- */
.btn-ghost-toggle {
  background-color: transparent;
  border: none;
  color: hsl(var(--foreground));
  padding: 8px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background-color 150ms ease;
  font-size: 1.125rem;
}
.btn-ghost-toggle:hover {
  background-color: hsl(var(--muted) / 0.5);
}
.btn-ghost-toggle:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* =============================================================================
   DataTables footer cluster — 06-13 pass 2
   `dom: 'rt<"secuura-dt-foot"i<"secuura-dt-foot__right"lp>>'` renders:
     [info]                 [length picker] [pagination]
   Length picker sits next to pagination (Steve: "move that next to the previous
   1 2 3 next"); pagination buttons tokenized so the bright Bootstrap-default
   blue doesn't shout in dark mode.
   ============================================================================= */
.secuura-dt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid hsl(var(--border));
}
.secuura-dt-foot__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
/* DataTables emits its own scoped wrappers for length/info/paginate — strip the
   built-in margins so our flex parent owns the spacing. */
.secuura-dt-foot .dataTables_info,
.secuura-dt-foot .dataTables_length,
.secuura-dt-foot .dataTables_paginate {
  margin: 0;
  padding: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}
.secuura-dt-foot .dataTables_length label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: hsl(var(--muted-foreground));
  font-weight: 400;
}
.secuura-dt-foot .dataTables_length select {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  padding: 4px 24px 4px 10px;          /* 24px right keeps the system chevron unclipped */
  font-size: 0.875rem;
  min-width: 64px;
  cursor: pointer;
}
.secuura-dt-foot .dataTables_length select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* Pagination buttons — tokenized for both light and dark themes so they read as
   part of the surface, not as bright primary buttons. */
.secuura-dt-foot .paginate_button {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: hsl(var(--muted-foreground)) !important;
  border-radius: calc(var(--radius) - 4px) !important;
  padding: 4px 10px !important;
  margin: 0 2px !important;
  font-size: 0.875rem;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
  cursor: pointer;
}
.secuura-dt-foot .paginate_button:hover {
  background: hsl(var(--muted) / 0.6) !important;
  color: hsl(var(--foreground)) !important;
  border-color: hsl(var(--border)) !important;
}
.secuura-dt-foot .paginate_button.current,
.secuura-dt-foot .paginate_button.current:hover {
  background: hsl(var(--primary) / 0.12) !important;
  color: hsl(var(--foreground)) !important;
  border-color: hsl(var(--primary) / 0.5) !important;
}
.secuura-dt-foot .paginate_button.disabled,
.secuura-dt-foot .paginate_button.disabled:hover {
  background: transparent !important;
  color: hsl(var(--muted-foreground) / 0.4) !important;
  border-color: transparent !important;
  cursor: not-allowed;
}

/* =============================================================================
   Block modal — per-share confirmation surface (replaces system confirm() in
   MyDocuments). Visual language matches _RevokeModal but the action is single-
   shot (no 5s deferred undo).
   ============================================================================= */
.secuura-block-summary {
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.secuura-block-summary__row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: baseline;
  gap: 12px;
}
.secuura-block-summary__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
}
.secuura-block-summary__value {
  font-weight: 500;
  color: hsl(var(--foreground));
  word-break: break-word;
}

/* Confirm-button pulse during the 350ms hold between confirm and AJAX dispatch. */
.secuura-block-pulse {
  animation: secuura-block-pulse 350ms ease-out;
}
@keyframes secuura-block-pulse {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 hsl(var(--destructive) / 0.5); }
  60%  { transform: scale(0.97); box-shadow: 0 0 0 8px hsl(var(--destructive) / 0); }
  100% { transform: scale(1);   box-shadow: 0 0 0 0 hsl(var(--destructive) / 0); }
}

/* The expanding row in MyDocuments tints destructive while the block POST flies. */
tr.secuura-row-revoking > td {
  background: hsl(var(--destructive) / 0.08) !important;
  transition: background-color 200ms ease;
}

/* impeccable polish (Phase E): reduced-motion guard for the destructive pulse +
   row tint. Users who request less motion get the colour shift only. */
@media (prefers-reduced-motion: reduce) {
  .secuura-block-pulse {
    animation: none;
  }
  tr.secuura-row-revoking > td {
    transition: none;
  }
}

/* =============================================================================
   Typeset (impeccable critique, P1): the Three-Step Scale Rule from DESIGN.md
   was failing on workspace cards. Default Bootstrap h5.card-header renders at
   ~17.5px against a 14px body — a ratio of 1.09, well under the spec's 1.25.
   Force display-size (24px / 700) on card-headers that opt into the workspace
   page-title treatment via the .secuura-card-header--display modifier, and
   title-size (15px / 600) on the filename column's .fw-semibold span inside
   .secuura-shares-table so the spoken scale becomes 24 → 15 → 14 → 11.
   ============================================================================= */
.card-header.secuura-card-header--display {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}
.secuura-shares-table tbody td .fw-semibold {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
}

/* ---- Body backdrop + margin override.
   theme_ssd.css:40-51 ships the legacy body { background-color: #000;
   background-image: var(--bg-img); margin-bottom: 60px; } rule designed
   for the pre-shell era. With the modern shell sitting over the body but
   not always covering 100% of the viewport:
     1. The legacy black / backdrop image bleeds through margins,
        scrollbar gutters, and any layout gaps — visually wrong in both
        themes.
     2. The 60px margin-bottom pushes the body 60px taller than the
        viewport on any page whose content already fills the viewport,
        forcing an unnecessary vertical scrollbar.
   Force body to the active theme's --background token, strip the
   backdrop image, and zero the bottom margin. Token resolves to near-
   white in light mode and navy in dark mode, so a single rule covers
   both. Also reset the duplicate @media(<=768px) margin from theme_ssd:60. */
body {
  background-color: hsl(var(--background)) !important;
  background-image: none !important;
  margin-bottom: 0 !important;
}
@media (max-width: 768px) {
  body {
    margin-bottom: 0 !important;
  }
}

/* ---- CMS content (legacy DB-stored HTML on /site/cookies, /site/tnc,
   /site/privacy via PagesController + Views/Pages/PageDisplay.cshtml).
   The stored markup is plain HTML the app has no control over — it carries
   hard-coded white backgrounds via inline style attributes, semi-transparent
   white via .box-shadow / .card (theme_ssd:130 — rgba(255,255,255,0.8)),
   table-light, bg-light, and other Bootstrap-isms. In dark mode any of those
   reads as a bright grey panel against the navy backdrop. The targeted-class
   list I had before missed at least one offender, so go nuclear: zero out
   background and box-shadow on the wrapper AND every descendant within it,
   and force foreground colour back to the theme token. Scoped to the
   .secuura-cms-content wrapper so other surfaces (EntraVerify QR container,
   etc.) keep their intentional whites. */
.dark .secuura-cms-content,
.dark .secuura-cms-content * {
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
}
.dark .secuura-cms-content,
.dark .secuura-cms-content p,
.dark .secuura-cms-content li,
.dark .secuura-cms-content span,
.dark .secuura-cms-content div,
.dark .secuura-cms-content th,
.dark .secuura-cms-content td,
.dark .secuura-cms-content h1,
.dark .secuura-cms-content h2,
.dark .secuura-cms-content h3,
.dark .secuura-cms-content h4,
.dark .secuura-cms-content h5,
.dark .secuura-cms-content h6,
.dark .secuura-cms-content small {
  color: hsl(var(--foreground)) !important;
}
.dark .secuura-cms-content th,
.dark .secuura-cms-content td {
  border-color: hsl(var(--border)) !important;
}
.dark .secuura-cms-content a,
.dark .secuura-cms-content a:visited {
  color: hsl(var(--primary)) !important;
}
.dark .secuura-cms-content a:hover,
.dark .secuura-cms-content a:focus {
  color: hsl(var(--primary) / 0.85) !important;
}
