/* ===== RESET & BASE ===== */
* { box-sizing: border-box; }

body {
  font-family: sans-serif;
  max-width: 700px;
  margin: 0 auto;
  padding: 15px;
  font-size: 16px;
  line-height: 1.5;
  color: #f1f5f9;
  background: url('sfondo.png') no-repeat center center fixed;
  background-size: cover;
  min-height: 100vh;
}

h1, h2, h3 { color: #ffffff; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

/* ===== CARD ===== */
.card {
  background: rgba(15, 23, 42, 0.80);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 10px;
  padding: 15px;
  margin: 10px 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ===== ETICHETTE ===== */
label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: #cbd5e1;
  margin-top: 10px;
}

/* ===== INPUT & SELECT ===== */
input,
select,
textarea {
  width: 100%;
  padding: 12px;
  margin: 5px 0;
  font-size: 16px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: rgba(30, 41, 59, 0.9);
  color: #f1f5f9;
  font-family: inherit;
}
input::placeholder,
textarea::placeholder { color: #94a3b8; }
input:focus,
select:focus,
textarea:focus { outline: none; border-color: #3b82f6; }
textarea { resize: vertical; min-height: 72px; }

/* ===== PULSANTI ===== */
button {
  padding: 12px;
  margin: 5px 0;
  font-size: 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #2563eb;
  color: white;
  width: 100%;
}
button:hover { background: #1d4ed8; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.link {
  color: #60a5fa;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  padding: 0;
  width: auto;
  display: inline;
}
.link:hover { background: none; }

/* ===== UTILITY ===== */
.hidden { display: none; }
.hint { font-size: 12px; color: #94a3b8; margin: 2px 0 6px; }

/* ===== TAB BAR ===== */
.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 10px 0;
  border-bottom: 2px solid rgba(59, 130, 246, 0.4);
}
.tab-btn {
  flex: 1;
  min-width: 80px;
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  border: none;
  border-radius: 6px 6px 0 0;
  padding: 10px 8px;
  font-size: 14px;
  cursor: pointer;
  width: auto;
}
.tab-btn.active { background: #2563eb; color: white; }
.tab-content { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== TAB ADMIN ===== */
.tab-btn-admin {
  padding: 10px 16px;
  background: #334155;
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  margin-right: 5px;
  width: auto;
}
.tab-btn-admin.active { background: #2563eb; }
.tab-admin-content.hidden { display: none; }

/* ===== SEZIONI COLLASSABILI ===== */
details.sezione {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  margin: 8px 0;
  padding: 0 12px;
}
details.sezione > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: #93c5fd;
  padding: 12px 0;
  list-style: none;
}
details.sezione > summary::before { content: "▸ "; }
details.sezione[open] > summary::before { content: "▾ "; }
details.sezione > div { padding-bottom: 12px; }

/* ===== CHECKBOX GRUPPI ===== */
.chk-group { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0; }
.chk-group label {
  display: inline-flex;
  align-items: center;
  font-weight: normal;
  margin: 0;
  color: #e2e8f0;
}
.chk-group input { width: auto; margin-right: 4px; }

/* Checkbox giorni inline */
.card > div label { display: inline; font-weight: normal; margin-top: 0; color: #e2e8f0; }
label > input.giornoChk { width: auto; margin-right: 4px; }

/* ===== SERIE / PESO / REPS ===== */
.set-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 3px 0;
}
.set-row input { width: 100px; }
.set-row-allenamento {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.set-row-allenamento.is-compilato {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.4);
}
.set-check {
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
  font-size: 16px;
  min-width: 22px;
  text-align: center;
  display: inline-block;
}
.set-check.visible {
  opacity: 1;
  transform: scale(1);
}
.btn-inizia { background:#16a34a; }
.btn-inizia:hover { background:#15803d; }
.btn-riprendi { background:#f59e0b; color:#1e293b; }
.btn-riprendi:hover { background:#d97706; }
.btn-modifica { background:#475569; }
.btn-modifica:hover { background:#334155; }

/* ===== LISTA CLIENTI ===== */
.cliente-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  margin: 6px 0;
  background: rgba(30, 41, 59, 0.7);
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.cliente-info { flex: 1; min-width: 150px; }

/* ===== BADGE STATO ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-gestione { background: #f59e0b; color: #1e293b; }
.badge-attivo { background: #16a34a; color: white; }

/* ===== LOGO & TAGLINE ===== */
.logo { width: 140px; height: auto; margin: 10px auto 6px; display: block; }
.tagline {
  text-align: center;
  font-size: 16px;
  font-style: italic;
  font-weight: 700;
  color: #e2e8f0;
  max-width: 560px;
  margin: 0 auto 14px;
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  padding: 0 12px;
}

/* ===== NUTRIZIONE - TABELLA SETTIMANALE ===== */
body.wide { max-width: 1100px; }
.card--nutrition {
  padding: 12px;
  overflow: hidden;
}
.nutrition-hint {
  text-align: center;
  font-size: 12px;
  color: #93c5fd;
  margin: 6px 0 8px;
  display: none;
}
.nutrition-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.25);
  scrollbar-width: thin;
  scrollbar-color: #3b82f6 rgba(30,41,59,0.5);
}
.nutrition-scroll::-webkit-scrollbar { height: 8px; }
.nutrition-scroll::-webkit-scrollbar-thumb { background: #3b82f6; border-radius: 4px; }
.nutrition-scroll::-webkit-scrollbar-track { background: rgba(30,41,59,0.5); }
.nutrition-table {
  width: 100%;
  min-width: 1050px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.nutrition-table th,
.nutrition-table td {
  padding: 10px 8px;
  border: 1px solid #ddd;
  vertical-align: top;
  text-align: left;
}
.nutrition-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 700;
  white-space: nowrap;
}
.nutrition-table thead th:first-child {
  z-index: 4;
  left: 0;
}
.nutrition-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f8fafc;
  color: #1e293b;
  font-weight: 700;
  min-width: 130px;
}
.nutrition-table tbody td:not(:first-child) { color: #1e293b; }
.nutrition-table tbody tr:nth-child(even) td:not(:first-child) { background: #ffffff; }
.nutrition-table tbody tr:nth-child(odd) td:not(:first-child) { background: #f8fafc; }
.nutrition-table td.is-libero {
  background: #fff3cd !important;
  color: #856404 !important;
  font-weight: 700;
  text-align: center;
}
@media (max-width: 1100px) {
  .nutrition-hint { display: block; }
}
@media (max-width: 700px) {
  .nutrition-table { min-width: 980px; font-size: 12px; }
  .nutrition-table th, .nutrition-table td { padding: 7px 6px; }
}

/* ===== ESERCIZI MEDIA ===== */
.ex-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.3);
  background: rgba(30,41,59,0.5);
  flex-shrink: 0;
  cursor: pointer;
}
.ex-media {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(30,41,59,0.5);
  border: 1px solid rgba(71,85,105,0.4);
  font-size: 11px;
  color: #94a3b8;
}

/* ===== MODAL ZOOM ESERCIZIO ===== */
.ex-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  cursor: pointer;
}
.ex-zoom-overlay img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid rgba(148,163,184,0.3);
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}
.ex-zoom-close {
  position: absolute;
  top: 18px;
  right: 24px;
  color: #e2e8f0;
  font-size: 36px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.ex-zoom-close:hover {
  background: rgba(255,255,255,0.15);
}

/* ===== GRAFICI ===== */
canvas { max-width: 100%; }

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
  button { width: auto; }
  .card button { margin-right: 8px; }
  .tab-btn { width: auto; }
}
