:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #ebf5ff;
  --success: #0e9f6e;
  --success-light: #f3faf7;
  --warning: #c27803;
  --warning-light: #fdfdea;
  --danger: #e02424;
  --danger-light: #fdf2f2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* ── UTILITY ── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-gray { color: var(--gray-500); }
.rounded { border-radius: var(--radius); }

/* ── LAYOUT ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* ── CARD ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card-lg { padding: 2rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #057a55; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c81e1e; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover:not(:disabled) { background: #b45309; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover:not(:disabled) { background: var(--gray-50); }
.btn-lg { padding: 1rem 2rem; font-size: 1.125rem; border-radius: 10px; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-icon { padding: 0.5rem; }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}
.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
}
.form-control.error { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── ALERTS ── */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert-danger { background: var(--danger-light); color: #9b1c1c; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #03543f; border: 1px solid #84e1bc; }
.alert-warning { background: var(--warning-light); color: #723b13; border: 1px solid #fcd34d; }
.alert-info { background: var(--primary-light); color: #1e429f; border: 1px solid #93c5fd; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #def7ec; color: #03543f; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fde8e8; color: #9b1c1c; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ── NAVBAR ── */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar-brand span.club-badge {
  font-size: 0.7rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead th {
  background: var(--gray-50);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ── TABS ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.5rem;
  gap: 0.25rem;
}
.tab-btn {
  padding: 0.625rem 1.25rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-btn:hover:not(.active) { color: var(--gray-700); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.125rem; font-weight: 700; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── STATS CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.success { border-color: var(--success); }
.stat-card.warning { border-color: #d97706; }
.stat-card.danger { border-color: var(--danger); }
.stat-card .stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--gray-500); letter-spacing: 0.05em; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--gray-900); margin-top: 0.25rem; }
.stat-card .stat-sub { font-size: 0.75rem; color: var(--gray-400); margin-top: 0.25rem; }

/* ── FILTERS ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-group label { font-size: 0.75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em; }
.filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: #fff;
  min-width: 140px;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

/* ── KIOSK SPECIFIC ── */
.kiosk-body {
  background: linear-gradient(135deg, #1a56db 0%, #1e429f 100%);
  min-height: 100vh;
}
.kiosk-header {
  background: rgba(255,255,255,0.1);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(4px);
}
.kiosk-title { font-size: 1.25rem; font-weight: 700; }
.kiosk-content { padding: 1.5rem; max-width: 700px; margin: 0 auto; }
.turno-card {
  background: rgba(255,255,255,0.95);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  border-left: 5px solid var(--primary);
}
.turno-card.confirmed { border-color: var(--success); }
.turno-card.discrepanza { border-color: var(--danger); }
.turno-info { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 0.5rem; }
.turno-orario { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.turno-meta { font-size: 0.875rem; color: var(--gray-500); margin-top: 0.25rem; }
.turno-actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.timeout-bar {
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.timeout-progress {
  height: 100%;
  background: #fff;
  transition: width 1s linear;
}

/* ── LOGIN SPECIFIC ── */
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 0.75rem;
}
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.login-logo p { color: var(--gray-500); font-size: 0.875rem; margin-top: 0.25rem; }
.tab-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1.5rem;
}
.tab-toggle button {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.15s;
}
.tab-toggle button.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ── ADMIN SIDEBAR ── */
.admin-layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: #fff;
  padding: 1rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.sidebar-section { margin-bottom: 0.5rem; }
.sidebar-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-400);
  padding: 0.5rem 1rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: var(--gray-300);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; }
.sidebar-link .icon { font-size: 1.1rem; width: 20px; flex-shrink: 0; }
.admin-main { flex: 1; padding: 1.5rem; overflow-x: hidden; min-width: 0; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap; padding: 0.5rem; }
  .sidebar-label { display: none; }
  .sidebar-link { padding: 0.5rem 0.75rem; font-size: 0.75rem; flex-direction: column; gap: 0.2rem; }
  .sidebar-link .icon { font-size: 1.25rem; }
  .admin-main { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { max-width: 100%; }
  .filters { flex-direction: column; }
  .filter-select { min-width: 100%; }
}
@media (max-width: 480px) {
  .login-card { padding: 1.5rem 1.25rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .btn-lg { padding: 0.875rem 1.5rem; font-size: 1rem; }
}

/* ── SPINNER ── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-dark {
  border-color: rgba(0,0,0,0.1);
  border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.875rem; }
