/* ============================================================
   Coppa Piemonte 2026 — Palette myfitri.it
   - Primary (header/titoli): blu navy #0d47a1 → #1565c0 gradient
   - Secondary (link/bottoni): blu Material #1976d2
   - Accent (banner/highlights): giallo #ffeb3b
   - Background: bianco / grigio chiaro #fafafa
   ============================================================ */
:root {
  --c-primary: #0d47a1;       /* blu navy myfitri */
  --c-primary-2: #1565c0;     /* gradient end */
  --c-secondary: #1976d2;     /* blu Material bottoni */
  --c-secondary-2: #1565c0;   /* hover scuro */
  --c-accent: #ffeb3b;        /* giallo banner */
  --c-accent-dark: #fbc02d;
  --c-bg: #fafafa;
  --c-text: #212121;
  --c-muted: #757575;
  --c-gold: #FFD700;
  --c-red: #c8102e;           /* FITRI red per badge/podio */
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  margin: 0;
}
.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

header {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-2) 100%);
  color: white;
  padding: 18px 0 0;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding-bottom: 14px; }
.brand-logo {
  display: flex; align-items: center; gap: 18px;
  text-decoration: none; color: white;
  flex: 1;
}
.brand-logo .logo-img {
  background: white;
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(0,0,0,.30);
  flex-shrink: 0;
}
.brand-logo .logo-fitri {
  height: 100px; width: auto; max-width: 130px;
}
.brand-logo .logo-regione,
.brand-logo img.logo-regione {
  height: 100px !important;
  width: 100px !important;
  max-height: 100px !important;
  max-width: 100px !important;
  background: white;
  padding: 6px;
  margin-left: auto;
  object-fit: contain;
  display: inline-block;
  flex: 0 0 auto;
}
.brand-text { flex: 1; min-width: 220px; }
.brand-text h1 {
  margin: 0; font-size: 28px; line-height: 1.1; font-weight: 800;
  letter-spacing: -0.3px;
}
.brand-text .brand-sub {
  font-size: 12px; opacity: 0.92; letter-spacing: 1.2px; text-transform: uppercase;
  font-weight: 600;
}
.brand-text .brand-giovani {
  display: inline-block;
  margin-top: 8px;
  background: linear-gradient(135deg, #28a745 0%, #198754 100%);
  color: white !important;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  border: 1.5px solid rgba(255,255,255,.4);
  transition: transform .12s, box-shadow .12s;
}
.brand-text .brand-giovani:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  background: linear-gradient(135deg, #34c759 0%, #1ea64a 100%);
}

/* Banner Circuito Giovani in home */
.giovani-banner {
  display: flex; align-items: center; gap: 18px;
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border: 2px solid #28a745;
  border-left: 8px solid #28a745;
  border-radius: 14px;
  padding: 18px 24px;
  margin: 18px 0 24px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 10px rgba(40,167,69,.18);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.giovani-banner::before {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0;
  width: 80px;
  background: linear-gradient(135deg, transparent 0%, rgba(40,167,69,.10) 100%);
  pointer-events: none;
}
.giovani-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(40,167,69,.28);
  background: linear-gradient(135deg, #d4edda 0%, #a8d8b0 100%);
}
.giovani-banner-ico { font-size: 54px; line-height: 1; flex-shrink: 0; }
.giovani-banner-text { flex: 1; }
.giovani-banner-text h3 {
  margin: 0 0 4px; color: #1b5e20; font-size: 20px; font-weight: 800;
  letter-spacing: -0.2px;
}
.giovani-banner-text p {
  margin: 0; color: #2e5d32; font-size: 14px; line-height: 1.45;
}
.giovani-banner-cta {
  background: #28a745; color: white; padding: 10px 18px;
  border-radius: 10px; font-weight: 700; font-size: 14px;
  white-space: nowrap; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.giovani-banner:hover .giovani-banner-cta {
  background: #1b5e20;
}
@media (max-width: 600px) {
  .giovani-banner { flex-direction: column; text-align: center; padding: 16px; }
  .giovani-banner-ico { font-size: 42px; }
  .giovani-banner-text h3 { font-size: 17px; }
}
header h1 { margin: 0 0 8px; font-size: 22px; }
header h1 a { color: white; text-decoration: none; }

/* Nav bar separata sotto, con sfondo trasparente + bordo dorato */
.nav-wrap {
  border-top: 3px solid var(--c-accent);
  padding-top: 10px; padding-bottom: 10px;
}

@media (max-width: 720px) {
  .header-top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .brand-logo { width: 100%; flex-wrap: wrap; }
  .brand-logo .logo-fitri { height: 72px; max-width: 96px; }
  .brand-logo .logo-regione { height: 72px !important; width: 72px !important; max-width: 72px !important; margin-left: 0; }
  .brand-text h1 { font-size: 22px; }
}
header nav a {
  color: white; text-decoration: none; margin-right: 8px;
  padding: 8px 14px; border-radius: 6px;
  font-size: 14px;
  display: inline-block;
  font-weight: 500;
  transition: background .15s, color .15s;
}
header nav a:hover {
  background: var(--c-accent);
  color: var(--c-primary);
  font-weight: 700;
}
/* ============ CIRCUIT TABS (barra "scegli circuito" sopra la nav) ============ */
.circuit-tabs {
  display: flex;
  gap: 14px;
  padding: 10px 20px 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.circuit-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-radius: 10px;
  text-decoration: none;
  color: white !important;
  border: 1.5px solid rgba(255,255,255,.4);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  line-height: 1.15;
  transition: transform .12s, box-shadow .12s;
  flex: 1 1 auto;
  max-width: 460px;
  min-width: 260px;
}
.circuit-tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(0,0,0,.30);
}
.circuit-tab.tab-age {
  background: linear-gradient(135deg, #c8102e 0%, #8b0019 100%);
  opacity: 0.62;
}
.circuit-tab.tab-age:hover { opacity: 0.85; }
.circuit-tab.tab-age.active {
  opacity: 1;
  border: 3px solid #ffeb3b;
  box-shadow: 0 0 0 3px rgba(255,235,59,.45), 0 6px 18px rgba(200,16,46,.55);
  transform: translateY(-2px) scale(1.02);
  z-index: 2;
}
.circuit-tab.tab-giovani {
  background: linear-gradient(135deg, #28a745 0%, #198754 100%);
  opacity: 0.62;
}
.circuit-tab.tab-giovani:hover { opacity: 0.85; }
.circuit-tab.tab-giovani.active {
  opacity: 1;
  border: 3px solid #ffeb3b;
  box-shadow: 0 0 0 3px rgba(255,235,59,.45), 0 6px 18px rgba(40,167,69,.55);
  transform: translateY(-2px) scale(1.02);
  z-index: 2;
}
.circuit-tab { position: relative; }

/* ============ SECTION TITLE (box titolo per home age e pagina giovani) ============ */
.section-title {
  padding: 18px 26px; border-radius: 10px;
  margin: 18px 0 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}
.section-title h2 {
  margin: 0; font-size: 26px; font-weight: 800;
  letter-spacing: -0.3px;
}
.section-subtitle {
  margin: 4px 0 0; font-size: 15px;
  font-style: italic; opacity: 0.95;
}
.section-title.section-title-giov {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border-left: 6px solid #28a745;
}
.section-title.section-title-giov h2 { color: #1b5e20; }
.section-title.section-title-giov .section-subtitle { color: #2e5d32; }
.section-title.section-title-age {
  background: linear-gradient(135deg, #fdecef 0%, #f8c5cc 100%);
  border-left: 6px solid #c8102e;
}
.section-title.section-title-age h2 { color: #8b0019; }
.section-title.section-title-age .section-subtitle { color: #6d000e; }
.circuit-ico {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
  flex-shrink: 0;
}
.circuit-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.circuit-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.circuit-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.95;
  letter-spacing: 0.1px;
}
@media (max-width: 720px) {
  .circuit-tabs { flex-direction: column; align-items: stretch; }
  .circuit-tab { max-width: 100%; min-width: 0; }
  .circuit-title { font-size: 12.5px; }
  .circuit-sub { font-size: 10.5px; }
}

header nav a.nav-giovani {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #28a745 0%, #198754 100%);
  color: white !important;
  padding: 6px 14px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(40,167,69,.40);
  border: 1.5px solid rgba(255,255,255,.35);
  letter-spacing: 0.2px;
  line-height: 1.15;
  vertical-align: middle;
}
header nav a.nav-giovani:hover {
  background: linear-gradient(135deg, #34c759 0%, #1ea64a 100%);
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(40,167,69,.55);
}
.nav-giovani-ico {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.30));
}
.nav-giovani-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.nav-giovani-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.nav-giovani-sub {
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.95;
  text-transform: none;
  letter-spacing: 0.1px;
}
.admin-badge { background: #28a745; color: white; padding: 4px 10px; border-radius: 12px;
               font-size: 12px; margin-left: 8px; font-weight: 600; }
.admin-login-link { background: rgba(255,255,255,.15); padding: 6px 12px !important;
                    border-radius: 5px; margin-left: 10px; font-weight: 600; }
.admin-login-link:hover { background: rgba(255,255,255,.30) !important; }
.fitri-link { background: #c8102e; color: white !important; border-color: #c8102e; }
.fitri-link:hover { background: #a00d24; }
.endu-link { background: #00838f; color: white !important; border-color: #00838f; }
.endu-link:hover { background: #006470; }
.giovani-btn { background: #28a745; color: white !important; border-color: #28a745; }
.giovani-btn:hover { background: #1e7e34; }

h2 { color: var(--c-primary); margin-top: 30px; border-bottom: 3px solid var(--c-secondary); padding-bottom: 6px; }
h3 { color: #2e5d8f; margin-top: 22px; }

table.rank, table.cal {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  margin: 12px 0 24px;
  font-size: 14px;
}
table.rank th, table.cal th {
  background: var(--c-primary); color: white; padding: 9px 8px; text-align: left;
}
table.rank td, table.cal td { padding: 8px; border-bottom: 1px solid #eee; }
table.rank tr:hover { background: #f6f9fc; }
table.rank .pos { text-align: center; font-weight: bold; width: 40px; }
table.rank .punti { text-align: right; font-size: 16px; color: var(--c-primary); }
table.rank .punti-prova { text-align: center; color: #555; min-width: 50px; }
table.rank .atleti { text-align: center; }
table.rank .team-name { font-weight: 500; }

tr.gold td { background: linear-gradient(90deg, #fff8dc 0%, white 50%); }
tr.gold td.pos { background: gold; color: #222; }
tr.silver td.pos { background: silver; color: #222; }
tr.bronze td.pos { background: #cd7f32; color: white; }

.btn {
  display: inline-block;
  padding: 7px 14px;
  background: #e9ecef;
  color: var(--c-primary);
  text-decoration: none;
  border-radius: 5px;
  font-size: 13px;
  border: 1px solid #c8d0d8;
  cursor: pointer;
}
.btn:hover { background: #d4dce6; }
.btn.primary { background: var(--c-secondary); color: white; border-color: var(--c-secondary); }
.btn.primary:hover { background: var(--c-primary); }
.btn.danger { background: #d9534f; color: white; border-color: #d9534f; }
.btn.small { padding: 4px 8px; font-size: 12px; }

.info-bar { margin: 10px 0 20px; }
.info-bar .btn { margin-right: 8px; }

.flash {
  background: #d4edda; color: #155724; border-left: 4px solid #28a745;
  padding: 10px 16px; margin: 12px 0; border-radius: 4px;
}

.muted { color: #888; }

.badge-ok { background: #28a745; color: white; padding: 3px 8px; border-radius: 3px; font-size: 12px; }
.badge-pending { background: #ffc107; color: #222; padding: 3px 8px; border-radius: 3px; font-size: 12px; }

.prova-form label { display: block; margin: 10px 0; }
.prova-form label span { display: block; font-weight: 600; margin-bottom: 4px; color: var(--c-primary); }
.prova-form input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; width: 100%; max-width: 700px; font-size: 14px; }
.prova-form button { margin-top: 12px; }

.info-box {
  background: #fff9e6; border: 1px solid #ffd54f; padding: 14px 20px;
  border-radius: 6px; margin: 16px 0;
}
.info-box code { background: #fff; padding: 1px 5px; border-radius: 3px; font-size: 13px; }

details summary {
  cursor: pointer; padding: 6px 0; font-weight: 600; color: var(--c-primary);
}
.mt-large { margin-top: 40px; }
pre { background: #2d3748; color: #e0e0e0; padding: 10px; border-radius: 5px; overflow-x: auto; font-size: 12px; }

footer { background: var(--c-primary); color: white; padding: 14px 0; margin-top: 50px; text-align: center; }
footer small { opacity: 0.8; }
