/* ============================================================
   Iron Tour Portal - Stile sportivo (Iron Tour + Spartacus Events)
   Palette: rosso #c8102e (IronTour), blu navy #153c51 (Spartacus),
            cyan #3fb7f8 (accenti), oro #d4af37 (premi)
   Font: Lato (sportivo, leggibile)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&family=Roboto+Mono:wght@500;700&display=swap');

:root {
  --rosso: #c8102e;
  --rosso-scuro: #9b0c24;
  --blu: #153c51;
  --blu-medio: #1f5577;
  --blu-chiaro: #3fb7f8;
  --cyan: #00bcd4;
  --oro: #d4af37;
  --argento: #c0c0c0;
  --bronzo: #cd7f32;
  --grigio-bg: #f4f6f9;
  --grigio-card: #ffffff;
  --grigio-bordo: #dde2e8;
  --grigio-testo: #2c3742;
  --grigio-muted: #7a8590;
  --ombra: 0 4px 12px rgba(21,60,81,0.10);
  --ombra-hover: 0 8px 24px rgba(21,60,81,0.16);
  --bordo: 1px solid var(--grigio-bordo);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--grigio-bg); color: var(--grigio-testo);
  margin: 0; line-height: 1.55; font-weight: 400;
}
.container { max-width: 1500px; margin: 0 auto; padding: 0 16px; }

/* ============ HEADER ============ */
.main-header {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  border-bottom: 4px solid var(--rosso);
  position: sticky; top: 0; z-index: 100;
}
.header-content {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; flex-wrap: nowrap; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand:hover { opacity: 0.85; }
.logo-img { height: 52px; width: auto; max-width: 200px; }
.brand-text {
  font-size: 13px; font-weight: 900; color: var(--blu);
  text-transform: uppercase; letter-spacing: 2px;
}
.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a {
  color: var(--blu); text-decoration: none; padding: 10px 14px;
  border-radius: 6px; font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  transition: background .15s, color .15s;
}
.main-nav a:hover { background: var(--rosso); color: #fff; }
.admin-badge {
  background: #28a745; color: #fff; padding: 5px 12px; border-radius: 14px;
  font-size: 11px; font-weight: 900; margin-left: 8px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-login {
  background: rgba(200,16,46,.1); color: var(--rosso) !important;
  text-transform: uppercase;
}
.menu-toggle {
  display: none; font-size: 28px; background: none; border: none; cursor: pointer;
  color: var(--rosso); padding: 4px 10px; line-height: 1;
}

/* ============ ELEMENTI BASE ============ */
h1, h2, h3, h4 { font-family: 'Lato', sans-serif; font-weight: 900;
                 letter-spacing: -0.5px; }
h1 { color: var(--rosso); margin: 18px 0 10px; font-size: 2.1em; line-height: 1.15; }
h2 { color: var(--blu); margin: 28px 0 14px; padding-bottom: 8px;
     border-bottom: 4px solid var(--rosso); font-size: 1.5em;
     text-transform: uppercase; letter-spacing: 1px; }
h3 { color: var(--rosso); margin: 18px 0 8px; font-size: 1.2em;
     text-transform: uppercase; letter-spacing: 0.5px; }
h4 { color: var(--blu-medio); margin: 12px 0 6px; font-size: 1.05em; }

p { margin: 0.6em 0; }
a { color: var(--rosso); }
a:hover { color: var(--rosso-scuro); }

/* ============ HERO ============ */
.hero {
  background: linear-gradient(135deg, var(--blu) 0%, var(--blu-medio) 50%, var(--blu-chiaro) 100%);
  color: white; padding: 36px 28px; border-radius: 14px;
  margin: 18px 0; box-shadow: var(--ombra);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -50px; top: -50px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(200,16,46,.5) 0%, transparent 70%);
  pointer-events: none;
}
.hero h1, .hero h2 { color: white; border: none; margin: 0 0 12px; }
.hero p { font-size: 17px; opacity: 0.95; margin: 10px 0 18px; }
.hero .btn { margin-right: 8px; margin-top: 6px; }

/* ============ BOTTONI ============ */
.btn {
  display: inline-block; padding: 11px 22px;
  background: white; color: var(--blu);
  text-decoration: none; border-radius: 8px;
  font-size: 14px; font-weight: 700;
  border: 2px solid var(--grigio-bordo); cursor: pointer;
  touch-action: manipulation; min-height: 42px;
  transition: all .15s;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.btn:hover { border-color: var(--blu); transform: translateY(-1px); box-shadow: var(--ombra); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--rosso) 0%, var(--rosso-scuro) 100%);
  color: white; border-color: var(--rosso);
  box-shadow: 0 3px 8px rgba(200,16,46,.3);
}
.btn.primary:hover { box-shadow: 0 6px 16px rgba(200,16,46,.5); transform: translateY(-2px); }
.btn.secondary {
  background: linear-gradient(135deg, var(--blu) 0%, var(--blu-medio) 100%);
  color: white; border-color: var(--blu);
}
.btn.danger { background: #dc3545; color: white; border-color: #dc3545; }
.btn.small { padding: 7px 14px; font-size: 12px; min-height: 32px; }
.btn.big { padding: 16px 32px; font-size: 16px; font-weight: 900; }
.btn.huge { padding: 20px 40px; font-size: 18px; font-weight: 900; border-radius: 12px; }

.info-bar { margin: 16px 0 28px; display: flex; flex-wrap: wrap; gap: 10px; }
.info-bar form { margin: 0; }

.flash {
  background: linear-gradient(90deg, #d4edda 0%, white 100%);
  color: #155724; border-left: 5px solid #28a745;
  padding: 14px 20px; margin: 14px 0; border-radius: 8px; font-weight: 700;
}
.muted { color: var(--grigio-muted); }
.small { font-size: 12px; }
.empty-state {
  background: white; padding: 36px; border-radius: 10px; text-align: center;
  border: 2px dashed var(--grigio-bordo); margin: 20px 0;
}

footer {
  background: var(--blu); color: #c5cbd1;
  padding: 24px 0; margin-top: 50px; text-align: center;
}
footer small { opacity: 0.75; font-size: 13px; }

/* ============ CARD GRID ============ */
.manif-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px; margin: 24px 0;
}
.manif-card {
  background: white; padding: 22px; border-radius: 12px;
  box-shadow: var(--ombra); border-top: 5px solid var(--rosso);
  text-decoration: none; color: inherit;
  transition: transform .18s, box-shadow .18s;
  display: block; position: relative; overflow: hidden;
}
.manif-card::before {
  content: ""; position: absolute; top: 0; right: 0; width: 80px; height: 80px;
  background: radial-gradient(circle at top right, rgba(200,16,46,.08) 0%, transparent 70%);
}
.manif-card:hover { transform: translateY(-4px); box-shadow: var(--ombra-hover); }
.manif-card h3 { margin: 0 0 8px; color: var(--rosso); border: none; padding: 0;
                  text-transform: none; letter-spacing: 0; }
.manif-card .meta { color: var(--grigio-muted); font-size: 14px; margin: 8px 0; }
.tappe-bar { display: flex; gap: 6px; margin: 12px 0 6px; flex-wrap: wrap; }
.tappa-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: var(--grigio-bordo); color: var(--grigio-muted);
  border-radius: 50%; font-weight: 900; font-size: 13px;
  transition: all .15s;
}
.tappa-dot.done {
  background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
  color: white; box-shadow: 0 2px 6px rgba(40,167,69,.4);
}

/* ============ TABELLE ============ */
table.rank, table.tappe-tab, table.classifica-gen, table.atleti-list {
  width: 100%; border-collapse: collapse; background: white;
  box-shadow: var(--ombra); margin: 14px 0 24px; font-size: 14px;
  border-radius: 8px; overflow: hidden;
}
table.rank th, table.tappe-tab th, table.classifica-gen th, table.atleti-list th {
  background: linear-gradient(180deg, var(--blu) 0%, var(--blu-medio) 100%);
  color: white; padding: 12px 10px; text-align: left;
  font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; font-size: 12px;
}
table.rank td, table.tappe-tab td, table.classifica-gen td, table.atleti-list td {
  padding: 10px; border-bottom: 1px solid var(--grigio-bordo); vertical-align: middle;
}
table.rank tr:hover, table.classifica-gen tr:hover, table.atleti-list tr:hover {
  background: #f6f9fc;
}
table.rank tr:last-child td, table.atleti-list tr:last-child td,
table.tappe-tab tr:last-child td, table.classifica-gen tr:last-child td {
  border-bottom: none;
}
table.rank .pos {
  text-align: center; font-weight: 900; width: 50px; font-size: 17px;
  font-family: 'Roboto Mono', monospace;
}
.pett-col {
  font-size: 17px; font-weight: 900; color: var(--rosso); min-width: 50px;
  font-family: 'Roboto Mono', monospace;
}
.tempo-tot {
  font-size: 15px; color: var(--rosso); font-weight: 900;
  font-family: 'Roboto Mono', monospace;
}
.gap { color: var(--grigio-muted); font-size: 13px;
       font-family: 'Roboto Mono', monospace; }
.tappa-time {
  color: #444; font-size: 13px; text-align: center; min-width: 70px;
  font-family: 'Roboto Mono', monospace;
}
.tappa-col { font-size: 12px; }

.cat-pill {
  background: linear-gradient(135deg, var(--blu) 0%, var(--blu-medio) 100%);
  color: white; padding: 3px 10px; border-radius: 14px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.regione-pill {
  color: white; padding: 3px 10px; border-radius: 14px; font-size: 11px;
  font-weight: 700; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.age-pill {
  background: var(--grigio-muted); color: white; padding: 3px 10px; border-radius: 14px;
  font-size: 12px; font-weight: 700;
  font-family: 'Roboto Mono', monospace;
}
.fitri-pill {
  background: var(--oro); color: var(--blu); padding: 3px 10px; border-radius: 14px;
  font-size: 12px; font-weight: 900;
}

tr.gold td.pos { background: linear-gradient(135deg, var(--oro) 0%, #f0d77a 100%); color: var(--blu); }
tr.silver td.pos { background: linear-gradient(135deg, var(--argento) 0%, #e8e8e8 100%); color: var(--blu); }
tr.bronze td.pos { background: linear-gradient(135deg, var(--bronzo) 0%, #d99a5b 100%); color: white; }

.badge-ok {
  background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
  color: white; padding: 4px 11px; border-radius: 4px; font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}
.badge-pending {
  background: linear-gradient(135deg, #ffc107 0%, #ffaa00 100%);
  color: #5a4500; padding: 4px 11px; border-radius: 4px; font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}
.endu-link {
  background: linear-gradient(135deg, #00838f 0%, #006470 100%) !important;
  color: white !important; border-color: #00838f !important;
}
.endu-link:hover { box-shadow: 0 4px 10px rgba(0,131,143,.4); }

/* ============ FILTRI ============ */
.filtri { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.filtri input, .filtri select {
  padding: 11px 14px; border: 2px solid var(--grigio-bordo);
  border-radius: 8px; font-size: 14px;
  min-height: 44px; background: white;
  font-family: 'Lato', sans-serif; font-weight: 700;
  transition: border-color .15s;
}
.filtri input:focus, .filtri select:focus {
  outline: none; border-color: var(--rosso);
}
.filtri input { flex: 1; min-width: 200px; }

/* ============ FORM ============ */
.prova-form label { display: block; margin: 14px 0; }
.prova-form label span {
  display: block; font-weight: 900; margin-bottom: 6px;
  color: var(--blu); text-transform: uppercase; font-size: 13px; letter-spacing: 0.5px;
}
.prova-form input, .prova-form textarea, .prova-form select {
  padding: 12px 14px; border: 2px solid var(--grigio-bordo); border-radius: 8px;
  width: 100%; max-width: 700px; font-size: 15px; min-height: 46px;
  font-family: 'Lato', sans-serif;
}
.prova-form input:focus, .prova-form textarea:focus {
  outline: none; border-color: var(--rosso);
}
.prova-form button { margin-top: 18px; }
.info-box {
  background: linear-gradient(90deg, #e7f3ff 0%, white 100%);
  border-left: 5px solid var(--blu-chiaro);
  padding: 16px 20px; margin: 18px 0; border-radius: 8px;
}
.progress-box {
  background: linear-gradient(90deg, #fff8e1 0%, white 100%);
  border-left: 5px solid var(--oro);
  padding: 16px 20px; margin: 18px 0; border-radius: 8px;
}
details { margin: 22px 0; }
details summary {
  cursor: pointer; padding: 10px 0; color: var(--blu); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ============ MANIF HEADER ============ */
.manif-header {
  background: white; padding: 24px 28px; border-radius: 12px; margin: 18px 0;
  border-left: 6px solid var(--rosso); box-shadow: var(--ombra);
}
.manif-header h1 { margin: 0; color: var(--rosso); border: none; padding: 0; }
.manif-header h1 small {
  color: var(--grigio-muted); font-weight: normal; font-size: 55%;
  margin-left: 8px; letter-spacing: 0;
}
.manif-header .meta {
  color: var(--grigio-testo); font-size: 16px; margin: 10px 0;
  font-weight: 700;
}
.manif-header .descr { color: var(--grigio-muted); font-style: italic; }

/* ============ SCHEDA ATLETA standalone ============ */
.scheda-header {
  display: flex; align-items: center; gap: 24px; background: white;
  padding: 22px; border-radius: 12px; box-shadow: var(--ombra);
  margin-bottom: 16px; border-left: 6px solid var(--rosso); flex-wrap: wrap;
}
.pettorale-big {
  font-size: 80px; font-weight: 900; color: var(--rosso); line-height: 1;
  min-width: 130px; text-align: center;
  font-family: 'Roboto Mono', monospace;
}
.big-rank { font-size: 17px; color: var(--blu); margin: 10px 0 0; }
.big-rank b { color: var(--rosso); }

/* ============ MOBILE ============ */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .main-nav {
    display: none; position: absolute; top: 100%; right: 0; left: 0;
    background: white; flex-direction: column; align-items: stretch; padding: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15); border-top: 2px solid var(--rosso);
  }
  .main-nav a { padding: 14px 18px; font-size: 15px; border-radius: 0;
                 border-bottom: 1px solid var(--grigio-bordo); }
  body.nav-open .main-nav { display: flex; }
  .logo-img { height: 40px; max-width: 140px; }
  .brand-text { display: none; }

  .container { padding: 0 10px; }
  h1 { font-size: 1.5em; }
  h2 { font-size: 1.2em; }

  .hero { padding: 22px 18px; }
  .hero p { font-size: 15px; }

  table.rank, table.atleti-list, table.classifica-gen, table.tappe-tab {
    font-size: 13px; display: block; overflow-x: auto; white-space: nowrap;
  }

  .filtri { flex-direction: column; }
  .filtri input, .filtri select { width: 100%; }

  .scheda-header { flex-direction: column; text-align: center; }
  .pettorale-big { font-size: 60px; min-width: auto; }

  .info-bar { flex-direction: column; align-items: stretch; }
  .info-bar .btn, .info-bar form { width: 100%; }
  .info-bar form button { width: 100%; }

  .manif-card { padding: 16px; }
  .manif-grid { grid-template-columns: 1fr; gap: 12px; }

  .prova-form input, .prova-form textarea, .prova-form select { max-width: 100%; }
}
