/*
 * University of Prishtina palette (override Bootstrap defaults)
 * Red #b31b00 · Blue #1a4a8e (accent bar / links)
 */
/* Kosovo (XK) — same mechanism as core .flag-al (Unicode escapes); not in compiled core map yet */
.flag-xk::before,
.flag-xk:before {
  content: "\1f1fd\1f1f0";
  font-style: normal;
}

/* Flag emoji from ::before (core); prefer emoji font — <i> often picked up Font Awesome on user lists */
[class^="flag-"]::before,
[class^="flag-"]:before {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}

:root {
  /* Increase a few px if the nav overlaps page titles; decrease if a white line remains */
  --shecurity-header-offset: 60px;
  --shecurity-header-offset-mobile: 54px;
  --up-red: #b31b00;
  --up-blue: #1a4a8e;
  --up-red-dim: #8c1500;
  --bs-primary: #b31b00;
  --bs-primary-rgb: 179, 27, 0;
  --bs-link-color: #1a4a8e;
  --bs-link-hover-color: #14386e;
  /* Ensure form typing color is body black, not primary red */
  --bs-body-color: #212529;
  --bs-body-color-rgb: 33, 37, 41;
}

/* Homepage hero logo (index page) */
.shecurity-home-logo {
  max-width: 240px;
  width: 100%;
  height: auto;
  padding: 1rem 0;
}

/* Header — color schema: dark blue accent, primary red bar, CTFd nav only */

.shecurity-header-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
}

.shecurity-accent-bar {
  display: none;
}

.shecurity-red-wrap {
  background: #b31b00;
  color: #fff;
}

.shecurity-main-navbar {
  background: #b31b00 !important;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.shecurity-main-navbar .navbar-brand,
.shecurity-main-navbar .nav-link,
.shecurity-main-navbar .nav-link.dropdown-toggle {
  color: rgba(255, 255, 255, 0.95) !important;
}

.shecurity-brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  display: block;
}

.shecurity-brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  max-width: 14rem;
}

.shecurity-main-navbar .nav-link:hover,
.shecurity-main-navbar .navbar-brand:hover {
  color: #fff !important;
}

.shecurity-main-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.55);
}

.shecurity-main-navbar .navbar-toggler-icon {
  filter: invert(1);
}

/*
 * Fixed header: offset on body only.
 * Match real header height (navbar ~56–60px). Values that are too
 * large leave a white band between the red nav and the red jumbotron.
 */
body {
  padding-top: var(--shecurity-header-offset);
}

main {
  padding-top: 0 !important;
  /* Core reserves ~100px bottom margin for the “Powered by” footer; shrink once hidden */
  margin-bottom: 2rem !important;
}

/* Remove any stray gap before the first page title block */
main > .jumbotron:first-child {
  margin-top: 0 !important;
}

/* Core base.html has no footer block — hide branding link */
body > footer.footer {
  display: none !important;
}

@media (max-width: 767.98px) {
  body {
    padding-top: var(--shecurity-header-offset-mobile);
  }
}

.shecurity-main-navbar .dropdown-menu {
  z-index: 1050;
}

/*
 * Page title bars — core uses background-color: var(--bs-dark) on .jumbotron.
 * Shadow --bs-dark on the jumbotron so Bootstrap’s rule resolves to UP red.
 */
.jumbotron {
  --bs-dark: #b31b00;
}

.jumbotron,
main .jumbotron {
  background-color: var(--up-red) !important;
  color: #fff !important;
}

.jumbotron h1,
.jumbotron h2,
.jumbotron h3,
main .jumbotron h1,
main .jumbotron h2,
main .jumbotron h3,
main .jumbotron .text-muted {
  color: rgba(255, 255, 255, 0.95) !important;
}

/* Primary actions — UP red (not Bootstrap blue) */
.btn-primary {
  --bs-btn-bg: var(--up-red);
  --bs-btn-border-color: var(--up-red);
  --bs-btn-hover-bg: var(--up-red-dim);
  --bs-btn-hover-border-color: var(--up-red-dim);
  --bs-btn-active-bg: #731000;
  --bs-btn-active-border-color: #731000;
  --bs-btn-focus-shadow-rgb: 179, 27, 0;
  background-color: var(--up-red) !important;
  border-color: var(--up-red) !important;
  color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background-color: var(--up-red-dim) !important;
  border-color: var(--up-red-dim) !important;
  color: #fff !important;
}

.btn-outline-primary {
  --bs-btn-color: var(--up-red);
  --bs-btn-border-color: var(--up-red);
  --bs-btn-hover-bg: var(--up-red);
  --bs-btn-hover-border-color: var(--up-red);
  --bs-btn-hover-color: #fff;
}

/* Form fields — red focus ring to match brand */
.form-control:focus,
.form-select:focus {
  border-color: var(--up-red);
  box-shadow: 0 0 0 0.2rem rgba(179, 27, 0, 0.22);
}

/*
 * Form text + labels — force dark text (overrides any primary/red bleed into inputs).
 * Register / Settings / team forms live under main > .container.
 */
main .container input.form-control,
main .container textarea.form-control,
main .container select.form-select {
  color: #212529 !important;
  -webkit-text-fill-color: #212529 !important;
  caret-color: #212529;
}

main .container label.form-label,
main .container .form-label {
  color: #212529 !important;
}

/* Scoreboard — name links (light rows: dark text; dark theme: white — navbar has matching !important) */
.shecurity-scoreboard a.shecurity-sb-name {
  color: #212529 !important;
  font-weight: 600;
}

.shecurity-scoreboard a.shecurity-sb-name:hover {
  color: #000 !important;
}

html[data-bs-theme="dark"] .shecurity-scoreboard a.shecurity-sb-name {
  color: rgba(255, 255, 255, 0.92) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.92) !important;
}

html[data-bs-theme="dark"] .shecurity-scoreboard a.shecurity-sb-name:hover {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

.shecurity-fb-icon {
  color: var(--up-red);
}

/* Scoreboard — inline first blood / wrong flag next to name */
.shecurity-sb-user-cell {
  white-space: nowrap;
}

.shecurity-sb-inline-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.85rem;
  vertical-align: middle;
}

.shecurity-sb-stat-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--bs-body-color, #212529);
}

html[data-bs-theme="dark"] .shecurity-scoreboard .shecurity-sb-stat-num {
  color: rgba(255, 255, 255, 0.95) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.95) !important;
}

.shecurity-sb-fb-icon {
  color: #c41e3a;
  font-size: 0.95rem;
}

.shecurity-sb-wrong-icon {
  color: #c45c26;
  font-size: 0.95rem;
}

.shecurity-fb-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--up-red);
  margin-left: 0.1rem;
}

.shecurity-scoreboard .nav-pills .nav-link.active {
  background-color: var(--up-red) !important;
  color: #fff !important;
}

.shecurity-scoreboard .nav-pills .nav-link {
  color: var(--up-red);
}

/* Challenge grid — unsolved: red, solved: green */
.challenge-button.btn-dark:not(.challenge-solved) {
  background-color: var(--up-red) !important;
  border-color: var(--up-red) !important;
  color: #fff !important;
}

.challenge-button.btn-dark:not(.challenge-solved):hover {
  background-color: var(--up-red-dim) !important;
  border-color: var(--up-red-dim) !important;
}

.challenge-button.challenge-solved {
  background-color: #198754 !important;
  border-color: #157347 !important;
  color: #fff !important;
}

.challenge-button.challenge-solved:hover {
  background-color: #157347 !important;
  border-color: #146c43 !important;
  color: #fff !important;
}

/* User profile — SHEcurity first blood / incorrect counts (under place & points) */
.shecurity-profile-stats .shecurity-stat-fb {
  background-color: var(--up-blue);
  color: #fff;
  font-weight: 600;
}

.shecurity-profile-stats .shecurity-stat-wrong {
  background-color: #6c2a2a;
  color: #fff;
  font-weight: 600;
}

/* Extended scoreboard — filters, category columns */
.shecurity-sb-toolbar .form-label {
  font-weight: 600;
}

.shecurity-sb-scroll {
  /* Let the table use its full height; the page scrolls — no inner vertical pane. */
  max-height: none;
}

.shecurity-sb-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

/* Beat global table thead rules so Bootstrap text-* utilities win */
.shecurity-scoreboard .shecurity-sb-grid thead th.text-start {
  text-align: start !important;
}

.shecurity-scoreboard .shecurity-sb-grid thead th.text-end {
  text-align: end !important;
}

.shecurity-scoreboard .shecurity-sb-grid thead th.text-center {
  text-align: center !important;
}

.shecurity-sb-top {
  background-color: rgba(26, 74, 142, 0.06) !important;
}

.shecurity-sb-name {
  font-weight: 600;
}

.shecurity-sb-frac {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.shecurity-sb-grid .shecurity-frac-full {
  color: #198754;
}

.shecurity-sb-grid .shecurity-frac-partial {
  color: #0d9488;
}

.shecurity-sb-grid .shecurity-frac-none,
.shecurity-sb-grid .shecurity-frac-zero {
  color: #6c757d;
}

.shecurity-sb-cat-head {
  text-transform: lowercase;
  font-size: 0.85rem;
}

.shecurity-sb-nowrap {
  white-space: nowrap;
  font-size: 0.85rem;
}

/* Profile — awards table (force readable text; avoid invisible inherited colors) */
.shecurity-awards-table {
  --shecurity-award-text: #212529;
  color: var(--shecurity-award-text);
}

.shecurity-awards-table thead th {
  color: var(--shecurity-award-text);
}

.shecurity-awards-table tbody td:not(.text-success):not(.text-danger) {
  color: var(--shecurity-award-text);
}

.shecurity-awards-table tbody tr.shecurity-award-fb {
  box-shadow: inset 3px 0 0 0 #198754;
}

.shecurity-awards-table tbody tr.shecurity-award-wrong {
  box-shadow: inset 3px 0 0 0 var(--up-red);
}

/* Users listing (/users) — same toolbar + table layout as scoreboard */
.shecurity-users-page .shecurity-users-table-wrap {
  margin-top: 0.5rem;
}

/*
 * Profile name links must beat Bootstrap’s global `a { color: var(--bs-link-color) }` (blue).
 * Target first link in the User column + class-based fallbacks.
 */
.shecurity-users-page table.shecurity-users-table tbody tr > td:first-child > a:first-of-type,
.shecurity-users-page table tbody tr > td:first-child > a:first-of-type {
  color: #212529 !important;
  -webkit-text-fill-color: #212529 !important;
  font-weight: 600;
  text-decoration: none !important;
}

.shecurity-users-page table tbody tr > td:first-child > a:first-of-type:hover {
  color: #000 !important;
  -webkit-text-fill-color: #000 !important;
}

.shecurity-users-page a.shecurity-user-list-name,
.shecurity-users-page a.shecurity-sb-name {
  color: #212529 !important;
  -webkit-text-fill-color: #212529 !important;
  font-weight: 600;
  text-decoration: none !important;
}

.shecurity-users-page a.shecurity-user-list-name:hover,
.shecurity-users-page a.shecurity-sb-name:hover {
  color: #000 !important;
  -webkit-text-fill-color: #000 !important;
}

.shecurity-users-page span.shecurity-user-list-name {
  color: #212529;
  font-weight: 600;
}

.shecurity-users-pagination .shecurity-users-page-link {
  color: var(--up-blue);
  font-weight: 600;
  text-decoration: none;
}

.shecurity-users-pagination .shecurity-users-page-link:hover {
  color: var(--up-blue);
  filter: brightness(0.85);
  text-decoration: underline;
}

.shecurity-user-ext-link {
  color: var(--up-blue);
}
