/* ============================================================
   VIVAIO — Design System (Monti Rugby Rovigo Junior)
   Implementazione mockup statici — rif. 04a-design-system.md §12
   Solo CSS. Nessuna dipendenza. Mobile-first.
   ============================================================ */

/* ---------- 1. Variabili (Design System §12) ---------- */
:root {
  /* Brand — Rovigo Rugby colors (Bologna FC heritage) */
  --color-primary: #1E3A8A;         /* Rovigo Blue */
  --color-accent: #DC2626;          /* Rovigo Red */
  --color-primary-light: #3B82F6;   /* Sky Blue */
  --color-brand-white: #FFFFFF;     /* Rugby White */

  /* Neutrali */
  --color-neutral-50: #FAFAFA;
  --color-neutral-100: #F5F5F5;
  --color-neutral-200: #E5E5E5;
  --color-neutral-300: #D4D4D4;
  --color-neutral-500: #737373;
  --color-neutral-700: #404040;
  --color-neutral-900: #171717;

  /* Semantici */
  --color-success: #059669;
  --color-warning: #D97706;
  --color-danger: #DC2626;
  --color-info: #0284C7;

  /* Stati atleta */
  --state-present: #059669;
  --state-absent: #DC2626;
  --state-justified-bg: #FCA5A5;
  --state-justified-text: #991B1B;
  --state-sick: #D97706;
  --state-injured: #EA580C;
  --state-unavailable: #737373;
  --state-called-up: #3B82F6;

  /* Tipografia */
  --font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);

  /* Spacing (base 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* Layout */
  --sidebar-w: 240px;
  --bottomnav-h: 64px;
}

/* ---------- 2. Reset e base ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-neutral-700);
  background: var(--color-neutral-50);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }

a { color: var(--color-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul { margin: 0; padding: 0; list-style: none; }

/* Icone Lucide (SVG via CDN lucide-static) */
.icon { width: 20px; height: 20px; stroke-width: 2; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- 3. Tipografia (§3) ---------- */
.t-display { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: var(--color-neutral-900); }
.t-h1 { font-size: 1.25rem; font-weight: 700; line-height: 1.2; color: var(--color-neutral-900); }
.t-h2 { font-size: 1.125rem; font-weight: 600; line-height: 1.2; color: var(--color-neutral-900); }
.t-h3 { font-size: 1rem; font-weight: 600; line-height: 1.3; color: var(--color-neutral-900); }
.t-body { font-size: 1rem; font-weight: 400; }
.t-body-strong { font-size: 1rem; font-weight: 600; color: var(--color-neutral-900); }
.t-small { font-size: 0.875rem; line-height: 1.4; }
.t-caption { font-size: 0.75rem; font-weight: 500; line-height: 1.4; color: var(--color-neutral-500); }
.t-numeric { font-variant-numeric: tabular-nums; font-weight: 600; }
.t-muted { color: var(--color-neutral-500); }

@media (min-width: 640px) {
  .t-display { font-size: 2rem; }
  .t-h1 { font-size: 1.5rem; }
  .t-h2 { font-size: 1.25rem; }
  .t-h3 { font-size: 1.125rem; }
}

/* ---------- 4. Mockup header (barra navigazione review) ---------- */
/* Visivamente distinto dall'app: grigio scuro, testo bianco.
   Serve solo per la review, NON fa parte dell'app simulata. */
.mockup-header {
  background: var(--color-neutral-900);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.875rem;
}
.mockup-header a { color: #fff; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.mockup-header a:hover { color: var(--color-primary-light); text-decoration: none; }
.mockup-header .mh-num {
  background: rgba(255,255,255,0.15);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.mockup-header .mh-device { color: var(--color-neutral-300); }
.mockup-header .mh-name { color: #fff; font-weight: 600; margin-left: auto; }

/* ---------- 5. Pulsanti (§5.1) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease-in-out, box-shadow 150ms ease-in-out;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: #182f6e; }

.btn-secondary { background: #fff; color: var(--color-neutral-900); border-color: var(--color-neutral-300); }
.btn-secondary:hover { background: var(--color-neutral-100); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost { background: transparent; color: var(--color-neutral-700); }
.btn-ghost:hover { background: var(--color-neutral-100); }

.btn-lg { height: 48px; padding: 0 20px; font-size: 1rem; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.875rem; }
.btn-block { width: 100%; }

.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 6. Card (§5.3) ---------- */
.card {
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-md);
  padding: 16px;
}
@media (min-width: 640px) { .card { padding: 24px; } }

.card-clickable { display: block; transition: box-shadow 150ms, border-color 150ms; }
.card-clickable:hover { box-shadow: var(--shadow-sm); border-color: var(--color-neutral-300); text-decoration: none; }

.card-title { font-size: 1rem; font-weight: 600; color: var(--color-neutral-900); }

/* Stat card (dashboard) */
.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--color-neutral-900); font-variant-numeric: tabular-nums; }
.stat-card .stat-label { font-size: 0.875rem; color: var(--color-neutral-500); }

/* ---------- 7. Badge / Pill stato (§5.4, §2.4) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; }

.badge-present    { background: #d1fae5; color: #065f46; }
.badge-absent     { background: #fee2e2; color: #991b1b; }
.badge-justified  { background: var(--state-justified-bg); color: var(--state-justified-text); }
.badge-sick       { background: #fef3c7; color: #92400e; }
.badge-injured    { background: #ffedd5; color: #9a3412; }
.badge-unavailable{ background: var(--color-neutral-200); color: var(--color-neutral-700); }
.badge-called-up  { background: #dbeafe; color: #1e40af; }

/* Badge tipo evento */
.badge-training  { background: #dbeafe; color: #1e40af; }
.badge-festival  { background: #d1fae5; color: #065f46; }
.badge-tournament{ background: #fef3c7; color: #92400e; }

/* Badge generici */
.badge-neutral { background: var(--color-neutral-200); color: var(--color-neutral-700); }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-mobile  { background: #e0e7ff; color: #3730a3; }
.badge-desktop { background: #f1f5f9; color: #334155; }

/* ---------- 8. Form (§5.2) ---------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-neutral-700);
  margin-bottom: 6px;
}
.form-label .req { color: var(--color-danger); margin-left: 2px; }

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-neutral-900);
  background: #fff;
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
}
.form-control:focus {
  outline: 2px solid var(--color-primary-light);
  outline-offset: -1px;
  border-color: var(--color-primary-light);
}
textarea.form-control { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-hint { font-size: 0.75rem; color: var(--color-neutral-500); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--color-danger); margin-top: 4px; display: flex; align-items: center; gap: 4px; }

.form-row { display: grid; gap: 16px; }
@media (min-width: 640px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

@media (max-width: 639px) { .form-control { height: 48px; } }

.input-group { display: flex; gap: 8px; }
.input-group .form-control { flex: 1; }

/* Checkbox / radio */
.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.check-row input[type="checkbox"], .check-row input[type="radio"] { width: 20px; height: 20px; accent-color: var(--color-primary); }

/* ---------- 9. App shell — Desktop (sidebar) §5.7 ---------- */
.app-desktop { display: flex; min-height: calc(100vh - 44px); background: var(--color-neutral-50); }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: calc(100vh - 44px);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
/* Logo su header blu: chip bianco per far risaltare il logo (che ha sfondo bianco) */
.sidebar-brand .logo { height: 40px; width: auto; background: #fff; padding: 4px 6px; border-radius: var(--radius-md); }
.sidebar-brand .brand-text { font-weight: 700; font-size: 1.125rem; }
.sidebar-brand .brand-sub { font-size: 0.6875rem; color: rgba(255,255,255,0.7); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.85);
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.1); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,0.16); color: #fff; }

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .avatar { width: 36px; height: 36px; border-radius: var(--radius-md); background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; }
.sidebar-user .u-name { font-size: 0.875rem; font-weight: 600; }
.sidebar-user .u-role { font-size: 0.75rem; color: rgba(255,255,255,0.7); }

.main-desktop { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--color-neutral-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--color-neutral-500); }
.breadcrumb .sep { color: var(--color-neutral-300); }
.breadcrumb .current { color: var(--color-neutral-900); font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-neutral-200);
  background: #fff;
  border-radius: var(--radius-md);
  color: var(--color-neutral-700);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--color-neutral-100); }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--color-accent); border-radius: 50%; border: 1.5px solid #fff; }

.page-content { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--color-neutral-500); font-size: 0.9375rem; margin-top: 2px; }

/* ---------- 10. App shell — Mobile (bottom nav) §5.7 ---------- */
.app-mobile {
  max-width: 420px;
  margin: 0 auto;
  min-height: calc(100vh - 44px);
  background: var(--color-neutral-50);
  display: flex;
  flex-direction: column;
  position: relative;
  border-left: 1px solid var(--color-neutral-200);
  border-right: 1px solid var(--color-neutral-200);
}
.mobile-topbar {
  height: 56px;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.mobile-topbar .logo { height: 34px; width: auto; background: #fff; padding: 3px 5px; border-radius: var(--radius-sm); }
.mobile-topbar .m-title { font-size: 1.125rem; font-weight: 700; }
.mobile-topbar .m-action { margin-left: auto; color: #fff; display: inline-flex; }
.mobile-topbar .icon-btn { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.12); color: #fff; }
.mobile-topbar .icon-btn:hover { background: rgba(255,255,255,0.2); }
.mobile-back { color: #fff; display: inline-flex; align-items: center; }

.mobile-content { flex: 1; padding: 16px; padding-bottom: calc(var(--bottomnav-h) + 16px); }

.bottom-nav {
  position: sticky;
  bottom: 0;
  height: var(--bottomnav-h);
  background: #fff;
  border-top: 1px solid var(--color-neutral-200);
  display: flex;
  align-items: stretch;
  z-index: 5;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--color-neutral-500);
  font-size: 0.6875rem;
  font-weight: 500;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a.active { color: var(--color-primary); }

/* Barra azione fissa in basso (sopra bottom nav), es. Salva presenze */
.mobile-action-bar {
  position: sticky;
  bottom: var(--bottomnav-h);
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--color-neutral-200);
  box-shadow: 0 -2px 6px rgba(0,0,0,0.04);
}

/* ---------- 11. Tabelle (§5.5) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-neutral-200); border-radius: var(--radius-md); background: #fff; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.data-table thead th {
  position: sticky; top: 0;
  background: var(--color-neutral-100);
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-neutral-500);
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-neutral-200);
  white-space: nowrap;
}
.data-table thead th .th-sort { display: inline-flex; align-items: center; gap: 4px; }
.data-table tbody td { padding: 10px 16px; border-bottom: 1px solid var(--color-neutral-200); height: 48px; vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: var(--color-neutral-50); }
.data-table tbody tr:hover { background: #eff3fb; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .cell-strong { font-weight: 600; color: var(--color-neutral-900); }
.row-actions { display: flex; gap: 6px; }

/* ---------- 12. Foto atleta (§8.1) ---------- */
.avatar-photo {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--color-neutral-200);
  flex-shrink: 0;
}
.avatar-photo.lg { width: 96px; height: 96px; }
.avatar-initials {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: #dbe3f5;
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 0.9375rem;
  flex-shrink: 0;
}
.avatar-initials.lg { width: 96px; height: 96px; font-size: 1.75rem; }
.avatar-initials.round { border-radius: var(--radius-pill); }
.avatar-photo.round { border-radius: var(--radius-pill); }

/* ---------- 13. Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.grid { display: grid; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-muted { color: var(--color-neutral-500); }
.divider { height: 1px; background: var(--color-neutral-200); border: 0; margin: 24px 0; }

.section { margin-bottom: 32px; }
.section-title { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-neutral-500); margin-bottom: 12px; }

/* Grid responsive per card riepilogo */
.grid-cards { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-cards.c-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-cards.c-3 { grid-template-columns: repeat(3, 1fr); } .grid-cards.c-4 { grid-template-columns: repeat(4, 1fr); } }

/* Filtri barra */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-neutral-500); }
.search-input .form-control { padding-left: 38px; }

/* ---------- 14. Auth layout (schermate 01-03) ---------- */
.auth-wrap {
  min-height: calc(100vh - 44px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--color-neutral-100);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px 28px;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.auth-brand .logo { height: 68px; width: auto; }
.auth-brand .app-name { font-size: 1.5rem; font-weight: 700; color: var(--color-primary); letter-spacing: -0.01em; }
.auth-brand .app-sub { font-size: 0.8125rem; color: var(--color-neutral-500); }
.auth-title { font-size: 1.25rem; font-weight: 700; color: var(--color-neutral-900); margin-bottom: 4px; text-align: center; }
.auth-desc { font-size: 0.9375rem; color: var(--color-neutral-500); text-align: center; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.875rem; }

/* Logo placeholder finché logo-monti.jpg non è fornito */
.logo-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-md);
}

/* Toast (statico, dimostrativo) */
.toast {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow-md);
}
.toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* Note box informativo (es. placeholder R2, avvisi) */
.notice {
  display: flex; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.45;
}
.notice-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.notice-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.notice-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.notice .icon { margin-top: 1px; }

/* Empty state / placeholder */
.placeholder-box {
  border: 1px dashed var(--color-neutral-300);
  border-radius: var(--radius-md);
  padding: 32px 24px;
  text-align: center;
  color: var(--color-neutral-500);
  background: var(--color-neutral-50);
}
.placeholder-box .icon-lg { margin: 0 auto 8px; color: var(--color-neutral-300); }
