@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-dark: #0a0e1a;
  --bg-card: #111827;
  --bg-sidebar: #0d1117;
  --bg-input: #1a2332;
  --border: #1e293b;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-teal: #14b8a6;
  --accent-red: #ef4444;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
}

[data-theme="light"] {
  --bg-dark: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #f1f5f9;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.2);
  --accent-red: #ef4444;
  --text: #1e293b;
  --text-dim: #475569;
  --text-muted: #94a3b8;
}

[data-theme="light"] .login-container {
  background: radial-gradient(ellipse at top, #e0e7ff 0%, #f1f5f9 70%);
}

[data-theme="light"] .login-box {
  box-shadow: 0 0 60px rgba(59, 130, 246, 0.06), 0 25px 50px rgba(0,0,0,0.08);
}

[data-theme="light"] .stat-card:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

[data-theme="light"] .stat-card.blue p { color: #2563eb; }
[data-theme="light"] .stat-card.green p { color: #059669; }
[data-theme="light"] .stat-card.orange p { color: #d97706; }
[data-theme="light"] .stat-card.purple p { color: #7c3aed; }
[data-theme="light"] .stat-card.teal p { color: #0d9488; }

[data-theme="light"] .status-attivo, [data-theme="light"] .status-confermata { background: rgba(16, 185, 129, 0.1); color: #059669; }
[data-theme="light"] .status-sospeso, [data-theme="light"] .status-in_attesa { background: rgba(245, 158, 11, 0.1); color: #d97706; }
[data-theme="light"] .status-inattivo, [data-theme="light"] .status-cancellata { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
[data-theme="light"] .status-completata { background: rgba(59, 130, 246, 0.1); color: #2563eb; }

[data-theme="light"] .btn-edit { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
[data-theme="light"] .btn-danger { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
[data-theme="light"] .btn-toggle { background: rgba(245, 158, 11, 0.1); color: #d97706; }

[data-theme="light"] .modal-content {
  box-shadow: 0 25px 60px rgba(0,0,0,0.15);
}

[data-theme="light"] thead th {
  background: rgba(59, 130, 246, 0.04);
}

[data-theme="light"] tbody tr:hover {
  background: rgba(59, 130, 246, 0.03);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

/* LOGIN */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #0f172a 0%, #0a0e1a 70%);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 0 60px rgba(59, 130, 246, 0.08), 0 25px 50px rgba(0,0,0,0.4);
}

.login-box h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin: 8px 0 32px;
}

#login-form input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#login-form button {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: transform 0.1s, box-shadow 0.2s;
}

#login-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.error { color: var(--accent-red); font-size: 13px; text-align: center; margin-top: 12px; }

/* LAYOUT */
#app {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 10;
}

.logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo h2 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar ul {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
}

.sidebar li {
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s;
  margin-bottom: 4px;
}

.sidebar li:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--text);
}

.sidebar li.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar li .icon {
  font-size: 10px;
  opacity: 0.7;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-footer button {
  width: 100%;
  padding: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.sidebar-footer button:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* CONTENT */
.content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; }

.page h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 { margin-bottom: 0; }

.page-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card.blue::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-card.green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card.orange::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card.purple::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.stat-card.teal::before { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }

.stat-card h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-card p {
  font-size: 32px;
  font-weight: 700;
}

.stat-card.blue p { color: #60a5fa; }
.stat-card.green p { color: #34d399; }
.stat-card.orange p { color: #fbbf24; }
.stat-card.purple p { color: #a78bfa; }
.stat-card.teal p { color: #2dd4bf; }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.mt { margin-top: 24px; }

/* CHART BARS */
.chart-bars {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  min-height: 120px;
}

.chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.chart-bar .bar {
  width: 100%;
  max-width: 60px;
  border-radius: 8px 8px 0 0;
  min-height: 8px;
  transition: height 0.5s ease;
}

.chart-bar .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.chart-bar .value {
  font-size: 14px;
  font-weight: 600;
}

/* TABLES */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

thead th {
  background: rgba(59, 130, 246, 0.06);
  padding: 14px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: rgba(59, 130, 246, 0.04); }
tbody tr:last-child td { border-bottom: none; }

/* STATUS BADGES */
.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-attivo, .status-confermata { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.status-sospeso, .status-in_attesa { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.status-inattivo, .status-cancellata { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.status-completata { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }

/* BUTTONS */
.btn-primary {
  padding: 10px 20px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-edit {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}

.btn-edit:hover { background: rgba(59, 130, 246, 0.25); }

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-success {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}

.btn-toggle {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

/* MODAL */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
}

#modal-body {
  padding: 24px;
}

#modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 16px;
}

#modal-body label:first-child { margin-top: 0; }

#modal-body input, #modal-body select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
}

#modal-body input:focus, #modal-body select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#modal-body button {
  margin-top: 24px;
  width: 100%;
}

/* THEME FAB */
.theme-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

.theme-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(59, 130, 246, 0.3);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="light"] .theme-fab {
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo h2, .sidebar .badge, .sidebar li span:not(.icon) { display: none; }
  .sidebar li { justify-content: center; padding: 12px; }
  .content { margin-left: 60px; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
