/* ===========================================================================
   Biglietteria Fortitudo Agrigento — design system
   Identita' "matchday": biancazzurro, tipografia atletica (Archivo + Inter),
   dashboard a sidebar, verdetto scanner stile tabellone.
   =========================================================================== */
:root {
  --ink:      #0A1A36;   /* navy quasi nero — testo, superfici scure */
  --blu:      #1B43C0;   /* blu societario — primario */
  --blu-700:  #16379C;
  --azz:      #36A6F2;   /* azzurro accento — energia, gradienti */
  --carta:    #EEF2F9;   /* sfondo carta freddo */
  --bianco:   #FFFFFF;
  --linea:    #E2E8F2;   /* bordi tenui */
  --testo:    #16233D;
  --muto:     #61708C;   /* testo secondario */
  --verde:    #12894A;
  --verde-2:  #0C6E3A;
  --rosso:    #C92A33;
  --rosso-2:  #9E1E27;
  --giallo:   #E7A100;
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(10,26,54,.06), 0 1px 3px rgba(10,26,54,.08);
  --shadow:    0 6px 18px -6px rgba(10,26,54,.18), 0 2px 6px rgba(10,26,54,.06);
  --shadow-lg: 0 24px 48px -12px rgba(10,26,54,.28);
  --sidebar-w: 264px;
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  background: var(--carta);
  color: var(--testo);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  margin: 0;
}
h1,h2,h3,h4,.h1,.h2,.h3 { font-family: var(--font-display); letter-spacing: -.01em; }
.text-fa { color: var(--blu) !important; }
a { color: var(--blu); }

/* ============================ App shell ================================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(54,166,242,.22), transparent 60%),
    linear-gradient(180deg, #0E2148 0%, #08152C 100%);
  background-color: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  overflow: hidden;
}
/* sash diagonale stile maglia */
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 62%, rgba(27,67,192,.55) 62.4%, rgba(54,166,242,.55) 64%, transparent 64.4%);
  pointer-events: none;
  opacity: .6;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 18px; position: relative; z-index: 1;
}
.brand img { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 3px 8px rgba(0,0,0,.45)); }
.brand-txt { line-height: 1.05; }
.brand-txt b { font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; letter-spacing: .02em; display: block; }
.brand-txt span { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--azz); font-weight: 600; }

.side-nav { position: relative; z-index: 1; margin-top: 6px; }
.side-nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.side-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--r-sm);
  color: #C5D2EA; font-weight: 500; font-size: .95rem; text-decoration: none;
  transition: background .15s, color .15s, transform .05s;
}
.side-nav .nav-link svg { width: 19px; height: 19px; flex: 0 0 19px; opacity: .9; }
.side-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav .nav-link.active {
  background: linear-gradient(90deg, var(--blu), var(--blu-700));
  color: #fff; box-shadow: var(--shadow-sm);
}
.side-nav .nav-link.active svg { opacity: 1; }

.side-foot { margin-top: auto; position: relative; z-index: 1; padding-top: 16px; }
.side-foot .user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.05); font-size: .85rem; color: #DCE6F7; margin-bottom: 10px;
}
.side-foot .user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 800;
  background: linear-gradient(135deg, var(--azz), var(--blu)); color: #fff; font-size: .8rem;
}
.btn-logout {
  width: 100%; border: 1px solid rgba(255,255,255,.18); background: transparent; color: #C5D2EA;
  padding: 9px; border-radius: var(--r-sm); font-weight: 600; font-size: .85rem; cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 40;
}
.topbar .menu-toggle {
  background: rgba(255,255,255,.1); border: 0; color: #fff; width: 42px; height: 42px;
  border-radius: 10px; font-size: 1.3rem; cursor: pointer; display: grid; place-items: center;
}
.topbar .brand-txt b { font-size: .95rem; }
.view { padding: 30px clamp(16px, 3vw, 40px); max-width: 1180px; width: 100%; }

/* page header (h1 dentro alle view) */
.view > h1, .view .h3 { font-weight: 800; font-size: clamp(1.5rem, 2.4vw, 2rem); color: var(--ink); margin: 0; }
.view > .d-flex { margin-bottom: 22px !important; }

/* ============================ Bottoni =================================== */
.btn { font-weight: 600; border-radius: var(--r-sm); }
.btn-fa, .btn-fa:focus {
  background: linear-gradient(180deg, var(--blu), var(--blu-700));
  border: 0; color: #fff; padding: .6rem 1.15rem; box-shadow: var(--shadow-sm);
}
.btn-fa:hover { background: linear-gradient(180deg, var(--blu-700), #102b7d); color: #fff; transform: translateY(-1px); }
.btn-fa:active { transform: translateY(0); }
.btn-sm { border-radius: 8px; }
.btn-outline-secondary { color: var(--blu); border-color: var(--linea); background: #fff; }
.btn-outline-secondary:hover { background: var(--blu); border-color: var(--blu); color: #fff; }
.btn-outline-primary { color: var(--blu); border-color: var(--blu); }
.btn-outline-primary:hover { background: var(--blu); color: #fff; }
.btn-outline-danger { color: var(--rosso); border-color: #F0C7CA; background:#fff; }
.btn-outline-danger:hover { background: var(--rosso); border-color: var(--rosso); color: #fff; }
.btn-link { color: var(--blu); font-weight: 600; text-decoration: none; }

/* ============================ Card ====================================== */
.card {
  background: #fff; border: 1px solid var(--linea); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card.p-3 { padding: 1.25rem !important; }
.card h2.h5, .card h2.h6 {
  font-family: var(--font-display); font-weight: 700; color: var(--ink);
  letter-spacing: .01em; margin-bottom: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--linea);
  display: flex; align-items: center; gap: .5rem;
}
.card h2.h6 { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muto); }

/* ============================ Tabelle =================================== */
.table-responsive {
  background: #fff; border: 1px solid var(--linea); border-radius: var(--r);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.table { margin: 0; color: var(--testo); }
.table > thead th {
  background: #F7F9FD; border-bottom: 1px solid var(--linea) !important;
  font-family: var(--font-ui); font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muto); padding: .85rem 1.1rem; font-style: normal;
}
.table > tbody td { padding: .95rem 1.1rem; border-color: var(--linea); vertical-align: middle; }
.table > tbody tr:last-child td { border-bottom: 0; }
.table > tbody tr { transition: background .12s; }
.table > tbody tr:hover { background: #F6F9FE; }
.table .text-muted { color: var(--muto) !important; }

/* ============================ Badge / pill ============================== */
.badge {
  font-family: var(--font-ui); font-weight: 600; font-size: .7rem; letter-spacing: .04em;
  padding: .4em .7em; border-radius: 999px; text-transform: uppercase;
}
.badge.bg-success { background: rgba(18,137,74,.12) !important; color: var(--verde) !important; }
.badge.bg-secondary { background: rgba(97,112,140,.14) !important; color: var(--muto) !important; }
.badge.bg-warning { background: rgba(231,161,0,.16) !important; color: #9a6b00 !important; }
.badge.bg-primary { background: rgba(27,67,192,.12) !important; color: var(--blu) !important; }
.badge.bg-info { background: rgba(54,166,242,.16) !important; color: #0d6fb0 !important; }
.badge.bg-danger { background: rgba(201,42,51,.12) !important; color: var(--rosso) !important; }
.text-danger { color: var(--rosso) !important; }
.text-success { color: var(--verde) !important; }

/* ============================ Form ====================================== */
.form-label { font-weight: 600; font-size: .82rem; color: var(--ink); margin-bottom: .35rem; }
.form-control, .form-select {
  border: 1px solid var(--linea); border-radius: var(--r-sm); padding: .6rem .8rem;
  background: #fff; color: var(--testo); font-size: .95rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--azz); box-shadow: 0 0 0 4px rgba(54,166,242,.18); outline: none;
}
.form-control::placeholder { color: #9aa7bd; }

/* stat card (report) */
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: #fff; border: 1px solid var(--linea); border-radius: var(--r);
  box-shadow: var(--shadow-sm); padding: 20px; position: relative; overflow: hidden;
}
.stat .n { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; line-height: 1; }
.stat .l { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muto); margin-top: 6px; }
.stat::after { content:""; position:absolute; left:0; top:0; bottom:0; width:5px; }
.stat.v::after { background: var(--verde); } .stat.v .n { color: var(--verde); }
.stat.r::after { background: var(--rosso); } .stat.r .n { color: var(--rosso); }
.stat.t::after { background: var(--blu); }   .stat.t .n { color: var(--ink); }

/* ============================ Login ===================================== */
.login-wrap { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 100vh; }
.login-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(110% 80% at 90% 10%, rgba(54,166,242,.35), transparent 55%),
    linear-gradient(160deg, var(--blu) 0%, var(--ink) 70%);
}
.login-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(118deg, transparent 58%, rgba(255,255,255,.10) 58.3%, rgba(54,166,242,.55) 60%, transparent 60.3%);
}
.login-hero .lh-top { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.login-hero .lh-top img { width: 60px; height: 60px; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0,0,0,.5)); }
.login-hero .lh-top span { font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--azz); font-weight: 700; }
.login-hero h1 {
  position: relative; z-index: 1; font-weight: 900; font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: .98; letter-spacing: -.02em; margin: 0;
}
.login-hero h1 em { font-style: normal; color: var(--azz); display: block; }
.login-hero .lh-sub { position: relative; z-index: 1; color: #C5D2EA; max-width: 34ch; font-size: 1rem; }
.login-panel { display: grid; place-items: center; padding: 32px; background: var(--carta); }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-weight: 800; color: var(--ink); font-size: 1.4rem; margin-bottom: 4px; }
.login-card .sub { color: var(--muto); font-size: .9rem; margin-bottom: 24px; }

/* ============================ Scanner =================================== */
.scan-shell { max-width: 460px; margin: 0 auto; }
.scan-event {
  background: #fff; border: 1px solid var(--linea); border-radius: var(--r);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 18px;
}
#reader {
  border-radius: var(--r-lg) !important; overflow: hidden; border: 2px solid var(--linea) !important;
  box-shadow: var(--shadow); background: #000;
}

/* ============================ Verdetto (tabellone) ====================== */
.scan-result {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  flex-direction: column; z-index: 1080; color: #fff; text-align: center; padding: 2rem;
  font-family: var(--font-display);
}
.scan-result.show { display: flex; animation: verdetto .28s cubic-bezier(.2,.7,.3,1); }
@keyframes verdetto { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.scan-result.verde { background: radial-gradient(120% 90% at 50% 0%, #19A859, var(--verde-2)); }
.scan-result.rosso { background: radial-gradient(120% 90% at 50% 0%, #E2434B, var(--rosso-2)); }
.scan-result::before {
  content: ""; width: clamp(96px,26vw,150px); height: clamp(96px,26vw,150px);
  border-radius: 50%; margin-bottom: 28px; background: rgba(255,255,255,.16);
  background-repeat: no-repeat; background-position: center; background-size: 52%;
}
.scan-result.verde::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.scan-result.rosso::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}
.scan-result .big { font-size: clamp(3.4rem, 19vw, 8.5rem); font-weight: 900; letter-spacing: .03em; line-height: .9; }
.scan-result .nome { font-family: var(--font-ui); font-size: clamp(1.1rem, 5.5vw, 1.9rem); font-weight: 600; margin-top: 8px; }
.scan-result .motivo {
  font-family: var(--font-ui); font-weight: 600; font-size: 1rem; margin-top: 16px;
  background: rgba(0,0,0,.18); padding: .5em 1.1em; border-radius: 999px;
}
.scan-result .motivo:empty { display: none; }
.scan-result #scanAgain {
  margin-top: 38px; font-family: var(--font-ui); font-weight: 700; border: 0;
  background: #fff; padding: .8rem 1.8rem; border-radius: 999px; box-shadow: var(--shadow);
}
.scan-result.verde #scanAgain { color: var(--verde-2); }
.scan-result.rosso #scanAgain { color: var(--rosso-2); }

/* ============================ Accessibilita' / motion =================== */
a:focus-visible, button:focus-visible, .form-control:focus-visible, .form-select:focus-visible, .nav-link:focus-visible {
  outline: 3px solid var(--azz); outline-offset: 2px; border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================ Bottom tab bar (app) ====================== */
.tabbar { display: none; }
.topbar-logo { width: 30px; height: 30px; object-fit: contain; }

/* ============================ Responsive ================================ */
@media (max-width: 860px) {
  .app { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content:""; position: fixed; inset: 0; background: rgba(10,26,54,.5); z-index: 55; }
  .topbar { display: flex; padding-top: calc(12px + env(safe-area-inset-top)); }
  .view { padding: 16px 14px calc(80px + env(safe-area-inset-bottom)); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 26px; padding-top: calc(26px + env(safe-area-inset-top)); }
  .login-panel { padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
  .stat-grid { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; } .stat .n { font-size: 1.7rem; }

  /* tap target piu' generosi */
  .btn { padding-top: .55rem; padding-bottom: .55rem; }
  .form-control, .form-select { font-size: 16px; padding: .7rem .85rem; }   /* 16px = niente zoom iOS */

  /* tab bar fissa in basso, voce centrale "Scansiona" rialzata */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--linea);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -6px 20px rgba(10,26,54,.10);
  }
  .tabbar .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
    padding: 9px 2px 8px; min-height: 58px;
    color: var(--muto); text-decoration: none; font-size: .64rem; font-weight: 600; letter-spacing: .01em;
  }
  .tabbar .tab svg { width: 22px; height: 22px; }
  .tabbar .tab.active { color: var(--blu); }
  .tabbar .tab-scan svg {
    width: 50px; height: 50px; padding: 13px; margin-top: -26px; border-radius: 50%; color: #fff;
    background: linear-gradient(180deg, var(--blu), var(--blu-700));
    box-shadow: 0 8px 20px -4px rgba(27,67,192,.6); border: 3px solid #fff;
  }
  .tabbar .tab-scan { color: var(--blu); }

  /* tabelle -> card impilate */
  .table-responsive { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .table { background: transparent; }
  .table thead { display: none; }
  .table, .table tbody { display: block; width: 100%; }
  .table > tbody tr {
    display: block; background: #fff; border: 1px solid var(--linea);
    border-radius: var(--r); box-shadow: var(--shadow-sm); margin-bottom: 12px; padding: 4px 14px;
  }
  .table > tbody tr:hover { background: #fff; }
  .table > tbody td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: .55rem 0 !important; border: 0 !important; text-align: right;
  }
  .table > tbody td::before {
    content: attr(data-label); font-weight: 600; font-size: .7rem; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muto); text-align: left;
  }
  .table > tbody td.cell-actions {
    justify-content: stretch; gap: 8px; border-top: 1px solid var(--linea) !important;
    margin-top: .3rem; padding-top: .7rem !important;
  }
  .table > tbody td.cell-actions::before { content: ""; display: none; }
  .table > tbody td.cell-actions .btn { flex: 1; }
}
