/* Tournament Platform theme on top of Tabler 1.7.0, aligned to the Confcommercio Brand Book v1.8 (Inarea, gennaio 2026).
   Palette tav. 25, WCAG pairs tav. 26, typeface tav. 33. Only brand colours (and their tints) are used; the one exception
   is --tp-err, kept for form validation and destructive actions only.
   Load after tabler.min.css and fonts.css, before site.css. Theme is selected by data-bs-theme on <html> (theme-init.js). */

/* Brand palette (tav. 25). Fixed: never overridden per tenant. */
:root {
  --cc-blu-scuro: #041E42;      /* PANTONE 282 C */
  --cc-blu: #003B75;            /* PANTONE 654 C */
  --cc-indaco: #0050B5;         /* PANTONE 2388 C */
  --cc-celeste: #007ACC;        /* PANTONE 2173 C */
  --cc-celeste-chiaro: #56B7E6; /* PANTONE 2190 C */
  --cc-grigio: #808080;
  --cc-nero: #000000;
  --cc-bianco: #FFFFFF;

  /* Spacing scale: one rhythm for every gap, padding and margin. */
  --tp-s1: 4px;
  --tp-s2: 8px;
  --tp-s3: 12px;
  --tp-s4: 16px;
  --tp-s5: 24px;
  --tp-s6: 32px;
  --tp-s7: 48px;
  --tp-s8: 64px;
  --tp-radius: 4px;
  --tp-header-h: 80px;
}
@media (max-width: 767.98px) { :root { --tp-header-h: 64px; } }

/* Map the tokens onto Tabler. Same selectors as below so var() resolves per themed element. */
:root,
[data-bs-theme=light],
[data-bs-theme=dark] {
  --tblr-primary: var(--tp-primary);
  --tblr-primary-fg: #fff;
  --tblr-link-color: var(--tp-link);
  --tblr-link-hover-color: var(--tp-link-hover);
  --tblr-body-bg: var(--tp-ground);
  --tblr-body-color: var(--tp-ink);
  --tblr-heading-color: var(--tp-heading);
  --tblr-secondary-color: var(--tp-muted);
  --tblr-border-color: var(--tp-line);
  --tblr-bg-surface: var(--tp-paper);
  --tblr-card-bg: var(--tp-paper);
  --tblr-bg-surface-secondary: var(--tp-soft);
  --tblr-bg-surface-tertiary: var(--tp-soft);
  --tblr-success: var(--tp-ok);
  --tblr-warning: var(--tp-warn);
  --tblr-danger: var(--tp-err);
  --tblr-success-lt: var(--tp-okbg);
  --tblr-warning-lt: var(--tp-warnbg);
  --tblr-danger-lt: var(--tp-errbg);
  --tblr-font-sans-serif: var(--tp-font-body);
  --tblr-body-font-family: var(--tp-font-body);
  --tblr-body-font-size: 1rem;
  --tblr-body-line-height: 1.55;
  --tblr-border-radius: var(--tp-radius);
  --tblr-border-radius-lg: var(--tp-radius);
  --tblr-border-radius-sm: var(--tp-radius);
}

:root,
[data-bs-theme=light] {
  color-scheme: light;
  /* tenant-overridable (overridden per tenant by /theme.css) */
  --tp-primary: #003B75;              /* Blu Confcom */
  --tp-secondary: #007ACC;            /* Celeste Confcom */
  --tp-accent: #56B7E6;               /* Celeste chiaro Confcom: decorative only (rules, markers), never small text on white */
  /* named tokens */
  --tp-navy: var(--tp-primary);
  --tp-navy-2: var(--tp-secondary);
  --tp-navy-surface: var(--tp-primary);
  --tp-deep-surface: #041E42;         /* Blu scuro Confcom */
  --tp-link: #0050B5;                 /* Indaco: AAA on white (7.5:1) */
  --tp-link-hover: #003B75;
  --tp-label: #007ACC;                /* Celeste labels on white (4.5:1, tav. 26) */
  --tp-focus: #007ACC;
  --tp-heading: #003B75;
  --tp-ink: #041E42;
  --tp-muted: #4A5A72;                /* Blu scuro tint, 7:1 on white */
  --tp-line: #D3DEEA;
  --tp-ground: #F4F7FB;
  --tp-paper: #FFFFFF;
  --tp-soft: #EAF2FA;
  --tp-ok: #0050B5;
  --tp-warn: #003B75;
  --tp-err: #B3261E;
  --tp-okbg: #E1EEFA;
  --tp-warnbg: #EAF2FA;
  --tp-errbg: #FBE9E7;
  --tp-font-display: "Encode Sans Semi Condensed", Arial, sans-serif;
  --tp-font-body: "Encode Sans Semi Condensed", Arial, sans-serif;
  --tblr-primary-rgb: 0, 59, 117;
  --tblr-primary-darken: #041E42;
  --tblr-primary-lt: #EAF2FA;
  --tblr-primary-lt-rgb: 234, 242, 250;
}

[data-bs-theme=dark] {
  color-scheme: dark;
  /* Built on Blu scuro Confcom; pairs from tav. 26 (Celeste chiaro on Blu scuro: AAA). */
  --tp-primary: #007ACC;              /* buttons: white text 4.5:1, 3.7:1 against the ground */
  --tp-secondary: #56B7E6;
  --tp-accent: #56B7E6;
  --tp-navy-surface: #003B75;
  --tp-deep-surface: #020F22;
  --tp-link: #56B7E6;
  --tp-link-hover: #FFFFFF;
  --tp-label: #56B7E6;
  --tp-focus: #56B7E6;
  --tp-heading: #FFFFFF;
  --tp-ink: #EEF4FB;
  --tp-muted: #A9C3E0;
  --tp-line: #1E4A80;
  --tp-ground: #041E42;
  --tp-paper: #0A2A55;
  --tp-soft: #0F3466;
  --tp-ok: #56B7E6;
  --tp-warn: #FFFFFF;
  --tp-err: #FF8A80;
  --tp-okbg: #0F3466;
  --tp-warnbg: #0F3466;
  --tp-errbg: #3A1620;
  --tblr-primary-rgb: 0, 122, 204;
  --tblr-primary-darken: #0050B5;
  --tblr-link-hover-color: #FFFFFF;
  --tblr-primary-lt: #0F3466;
  --tblr-primary-lt-rgb: 15, 52, 102;
}

/* Typography (tav. 33): Bold for titles, Regular for text, Light for large leads. Sentence case, as in the brand book. */
body { font-family: var(--tp-font-body); font-size: 1rem; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .page-title, .card-title, .navbar-brand {
  font-family: var(--tp-font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.005em;
  color: var(--tp-heading);
}
h1 { font-size: clamp(32px, 4.5vw, 44px); margin-bottom: var(--tp-s4); }
h2, .page-title { font-size: clamp(24px, 3vw, 30px); margin-bottom: var(--tp-s3); }
h3, .card-title { font-size: 20px; margin-bottom: var(--tp-s2); }
h4 { font-size: 17px; }
p { margin-bottom: var(--tp-s4); }
strong, b { font-weight: 700; }

:focus-visible {
  outline: 3px solid var(--tp-focus) !important;
  outline-offset: 2px;
  box-shadow: none !important;
}

mark { background: var(--tp-soft); color: inherit; padding: 0 2px; border-radius: 2px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Page frame: generous air around the content. */
.page-header { padding-block: var(--tp-s6) var(--tp-s2); margin: 0; }
.page-body { margin-block: var(--tp-s5) var(--tp-s7); }
.container-xl { padding-inline: var(--tp-s5); }
@media (max-width: 575.98px) { .container-xl { padding-inline: var(--tp-s4); } }

/* Components */
.btn {
  font-family: var(--tp-font-body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .01em;
  border-radius: var(--tp-radius);
  padding: 10px 20px;
  min-height: 44px;
  box-shadow: none;
}
.btn-sm { padding: 6px 12px; font-size: 14px; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 17px; }
.btn-primary { --tblr-btn-bg: var(--tp-primary); --tblr-btn-border-color: var(--tp-primary); --tblr-btn-color: #fff; --tblr-btn-hover-bg: #0050B5; --tblr-btn-hover-border-color: #0050B5; --tblr-btn-hover-color: #fff; --tblr-btn-active-bg: #041E42; --tblr-btn-active-border-color: #041E42; }
[data-bs-theme=dark] .btn-primary { --tblr-btn-hover-bg: #0050B5; --tblr-btn-hover-border-color: #0050B5; }
/* Call to action (iscrizione): Celeste Confcom, white text (tav. 26: AA). */
.btn-cta { background: #007ACC; color: #fff; border: 1px solid #007ACC; }
.btn-cta:hover, .btn-cta:focus-visible, .btn-cta:active { background: #0050B5; border-color: #0050B5; color: #fff; }
.btn-outline-primary { --tblr-btn-color: var(--tp-heading); --tblr-btn-border-color: var(--tp-heading); --tblr-btn-hover-bg: var(--tp-heading); --tblr-btn-hover-border-color: var(--tp-heading); --tblr-btn-hover-color: var(--tp-paper); border-width: 1.5px; }
.btn-outline-secondary { background: transparent; color: var(--tp-link); border: 1.5px solid var(--tp-line); }
.btn-outline-secondary:hover { background: var(--tp-soft); color: var(--tp-heading); border-color: var(--tp-line); }
.btn-outline-light { color: #fff; border: 1.5px solid rgba(255, 255, 255, .7); background: transparent; }
.btn-outline-light:hover, .btn-outline-light:focus-visible { background: #fff; color: #003B75; border-color: #fff; }
.btn-outline-danger { color: var(--tp-err); border: 1.5px solid var(--tp-err); background: transparent; }

.card { border: 1px solid var(--tp-line); border-radius: var(--tp-radius); box-shadow: none; background: var(--tp-paper); }
.card-header { padding: var(--tp-s4) var(--tp-s5); border-bottom: 1px solid var(--tp-line); }
.card-body { padding: var(--tp-s5); }
.card-footer { padding: var(--tp-s4) var(--tp-s5); background: transparent; border-top: 1px solid var(--tp-line); }
.row.g-3, .row-cards { --tblr-gutter-x: var(--tp-s5); --tblr-gutter-y: var(--tp-s5); }

.form-control, .form-select {
  border: 1px solid var(--tp-line);
  border-radius: var(--tp-radius);
  background-color: var(--tp-paper);
  color: var(--tp-ink);
  font-size: 15px;
  padding: 10px 12px;
  min-height: 44px;
}
.form-select { padding-right: 40px; background-position: right 12px center; }
.form-control:focus, .form-select:focus { border-color: var(--tp-focus); }
.form-label { font-size: 14px; font-weight: 700; color: var(--tp-heading); margin-bottom: 6px; }
.form-hint, .form-text { color: var(--tp-muted); font-size: 13.5px; }
.mb-3 { margin-bottom: var(--tp-s5) !important; }
.is-invalid, .input-validation-error { border-color: var(--tp-err); }
.field-validation-error, .validation-summary-errors { color: var(--tp-err); font-size: 13.5px; }

/* overflow-x:auto alone computes overflow-y to auto too: a 1px sub-pixel overflow (scrollHeight = clientHeight + 1) then shows a vertical scrollbar. */
.table-responsive { background: var(--tp-paper); border: 1px solid var(--tp-line); border-radius: var(--tp-radius); overflow-x: auto; overflow-y: hidden; }
.table { margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 12px 16px; border-bottom: 1px solid var(--tp-line); vertical-align: middle; white-space: nowrap; background-color: transparent; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table thead th {
  font-family: var(--tp-font-body);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1.2;
  background: var(--tp-soft);
  color: var(--tp-heading);
  position: sticky;
  top: 0;
}
.table-hover tbody tr:hover > * { background: var(--tp-soft); }

/* Status labels (A7 3.6): text always shown, colour from the brand blues only. */
.badge { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 4px 8px; border-radius: var(--tp-radius); background: var(--tp-soft); color: var(--tp-heading); border: 1px solid transparent; }
.badge-ok { background: #1F7A40; color: #fff; }
.badge-warn { background: #FFF1D6; color: #8A5A00; border-color: #E8C27A; }
.badge-err { background: var(--tp-deep-surface); color: #fff; }
[data-bs-theme=dark] .badge-ok { background: #3FBF6B; color: #041E42; }
[data-bs-theme=dark] .badge-err { background: #EEF4FB; color: #041E42; }

.alert { border: 0; border-left: 4px solid var(--tp-secondary); background: var(--tp-soft); border-radius: 0 var(--tp-radius) var(--tp-radius) 0; font-size: 15px; color: var(--tp-ink); padding: var(--tp-s4) var(--tp-s5); margin-bottom: var(--tp-s5); }
.alert-danger { border-left-color: var(--tp-err); background: var(--tp-errbg); }
.alert-success { border-left-color: var(--tp-secondary); }
.toast { background: var(--tp-deep-surface); color: #fff; border-radius: var(--tp-radius); box-shadow: 0 8px 24px rgba(4, 30, 66, .3); font-weight: 500; }

.tp-tile { background: var(--tp-paper); border: 1px solid var(--tp-line); border-top: 3px solid var(--tp-secondary); border-radius: var(--tp-radius); padding: var(--tp-s5); }
.tp-tile b { display: block; font: 700 36px/1 var(--tp-font-display); color: var(--tp-heading); font-variant-numeric: tabular-nums; margin-bottom: var(--tp-s2); }
.tp-tile small { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tp-muted); }
.tp-mt { border: 1px solid var(--tp-line); border-radius: var(--tp-radius); background: var(--tp-paper); font-size: 14.5px; }
.list-group-item { background: var(--tp-paper); border-color: var(--tp-line); padding: var(--tp-s3) var(--tp-s4); }
.nav-tabs { border-bottom: 1px solid var(--tp-line); gap: var(--tp-s1); margin-bottom: var(--tp-s5); }
.nav-tabs .nav-link { font-weight: 500; color: var(--tp-muted); border: 0; border-bottom: 3px solid transparent; padding: var(--tp-s3) var(--tp-s4); }
.nav-tabs .nav-link.active { color: var(--tp-heading); font-weight: 700; border-bottom-color: var(--tp-secondary); background: transparent; }

/* Standings (A7 3.9): compact table, numeric columns right-aligned, points emphasised, leader marked */
.tp-standings th.num, .tp-standings td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tp-standings td.tp-pts { font-weight: 700; color: var(--tp-heading); }
.tp-standings tbody tr:first-child td:first-child { box-shadow: inset 4px 0 0 var(--tp-secondary); }
.tp-standings td:nth-child(2) { font-weight: 500; }

/* Empty state (A7 3.10) */
.tp-empty-state { text-align: center; padding: var(--tp-s8) var(--tp-s5); background: var(--tp-paper); border: 1px dashed var(--tp-line); border-radius: var(--tp-radius); }
.tp-empty-state .empty-icon { font-size: 2.5rem; color: var(--tp-secondary); margin-bottom: var(--tp-s3); }
.tp-empty-state .empty-title { font: 700 20px/1.2 var(--tp-font-display); color: var(--tp-heading); margin-bottom: var(--tp-s2); }
.tp-empty-state .empty-subtitle { color: var(--tp-muted); font-size: 15px; }

/* Layout helpers (no inline styles under the CSP) */
.tp-filters { display: flex; gap: var(--tp-s3); flex-wrap: wrap; align-items: center; margin-bottom: var(--tp-s5); }
.tp-narrow { max-width: 560px; }
.tp-match-score { font-variant-numeric: tabular-nums; font-weight: 700; }

@media print {
  :root, [data-bs-theme=dark] { color-scheme: light; --tblr-bg-surface: #fff; --tblr-card-bg: #fff; --tblr-body-bg: #fff; --tblr-body-color: #000; --tblr-heading-color: #003B75; --tblr-border-color: #999;
    /* printing from the dark theme: links and muted text must not stay pale on white */
    --tblr-link-color: #003B75; --tblr-link-hover-color: #003B75; --tblr-secondary-color: #444; --tp-ink: #000; --tp-heading: #003B75; --tp-muted: #444; --tp-line: #999; --tp-paper: #fff; --tp-soft: #eee; --tp-secondary: #003B75; --tp-link: #003B75; --tp-ok: #003B75; --tp-warn: #003B75; --tp-err: #8e1c15; --tp-okbg: #fff; --tp-warnbg: #fff; --tp-errbg: #fff; }
  .tp-topbar, .tp-sidebar, .tp-public-header, .btn, .toast, .filters, .tp-filters, .actions { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #003B75; text-decoration: none; }
  .text-secondary, .text-muted { color: #444 !important; }
  .card, .table-responsive { border: 0; box-shadow: none; }
  .table thead th { position: static; color: #000; }
  .badge { border: 1px solid #999; background: #fff; color: #000; }
  thead { display: table-header-group; }
  tr, .tp-mt { break-inside: avoid; }
  @page { size: A4; margin: 12mm; }
}

/* Province + comune selects (Views/Shared/_PlaceSelects.cshtml) in back-office forms */
.tp-place { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--tp-s4); }
