@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;600&display=swap');

:root {
  --bg: #07080f;
  --panel: #0e1020;
  --border: #1f1a30;
  --accent: #aaff00;
  --accent2: #cc44ff;
  --green: #aaff00;
  --red: #ff2255;
  --orange: #ffaa00;
  --text: #c8d0e8;
  --dim: #4a5270;
}

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

/* Toast notifica */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-msg {
  background: var(--panel);
  border: 1px solid var(--accent2);
  border-radius: 10px;
  padding: 12px 18px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 0 20px rgba(204,68,255,0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
  letter-spacing: 0.5px;
}

.toast-msg .toast-icon { font-size: 18px; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(30px); }
}

/* Scrollbar custom */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent2); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  min-height: 100vh;
  padding: 24px;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(170,255,0,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(204,68,255,0.04) 0%, transparent 50%);
}

header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  height: 52px;
  width: auto;
}

h1 {
  font-family: 'Orbitron', monospace;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  text-shadow: none;
}

.logo-lizard {
  background: linear-gradient(180deg, #ccff00 0%, #66cc00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 8px rgba(150,255,0,0.8)) drop-shadow(0 0 20px rgba(150,255,0,0.4));
}

.logo-game {
  background: linear-gradient(180deg, #cc44ff 0%, #7700cc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 8px rgba(180,0,255,0.8)) drop-shadow(0 0 20px rgba(180,0,255,0.4));
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.online-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 1px;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.nav-tab {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--dim);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-tab:hover { border-color: var(--accent); color: var(--accent); }

.nav-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(170,255,0,0.08);
  box-shadow: 0 0 12px rgba(170,255,0,0.15);
}

.btn-logout {
  background: rgba(255,34,85,0.1);
  border: 1px solid rgba(255,34,85,0.3);
  color: var(--red);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-logout:hover { background: rgba(255,34,85,0.25); transform: translateY(-1px); }

.btn-stats {
  background: rgba(170,255,0,0.08);
  border: 1px solid rgba(170,255,0,0.3);
  color: var(--accent);
  width: 34px; height: 34px;
  border-radius: 8px; font-size: 16px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-stats:hover { background: rgba(170,255,0,0.2); transform: translateY(-1px); }

.btn-multi {
  background: rgba(255,170,0,0.08);
  border: 1px solid rgba(255,170,0,0.35);
  color: var(--orange);
  height: 34px; padding: 0 12px;
  border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px;
  transition: all 0.2s; font-family: 'Orbitron', monospace;
  display: flex; align-items: center; gap: 6px;
}
.btn-multi:hover, .btn-multi.active {
  background: rgba(255,170,0,0.25);
  border-color: var(--orange);
}

#multi-bar {
  background: rgba(255,170,0,0.06);
  border: 2px solid rgba(255,170,0,0.4);
  border-radius: 14px;
  padding: 16px 24px;
  margin: 0 0 20px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
#multi-count {
  font-family: 'Orbitron', monospace; font-size: 18px;
  font-weight: 900; color: var(--orange); letter-spacing: 2px;
}

.pc-card.multi-selected {
  border-color: var(--orange) !important;
  box-shadow: 0 0 0 3px rgba(255,170,0,0.3);
  transform: translateY(-2px);
}
.pc-card.multi-selected::before { background: var(--orange) !important; }

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.kpi-label { font-size: 14px; letter-spacing: 2px; color: var(--dim); margin-bottom: 10px; font-weight: 700; }
.kpi-value { font-family: 'Orbitron', monospace; font-size: 40px; font-weight: 900; }
.kpi-value.green  { color: var(--accent); }
.kpi-value.purple { color: var(--accent2); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.white  { color: var(--text); }

.chart-row { display: flex; align-items: center; gap: 12px; }
.chart-label { font-size: 16px; font-weight: 700; min-width: 110px; color: var(--text); }
.chart-bar-wrap { flex: 1; background: var(--border); border-radius: 6px; height: 26px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 6px; transition: width 0.6s ease; }
.chart-val { font-family: 'Orbitron', monospace; font-size: 14px; color: var(--dim); min-width: 44px; text-align: right; }

.session-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 17px;
}
.session-row .sr-time { font-family: 'Orbitron', monospace; font-size: 14px; color: var(--dim); min-width: 55px; }
.session-row .sr-device { font-weight: 700; flex: 1; }
.session-row .sr-dur { font-family: 'Orbitron', monospace; font-size: 15px; color: var(--accent); font-weight: 700; }

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.5s infinite;
}

.live-clock {
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  color: var(--dim);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  width: 108px;
  flex-shrink: 0;
  text-align: right;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.stat-icon-circle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-num {
  font-family: 'Orbitron', monospace;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--dim);
  text-transform: uppercase;
  margin-top: 4px;
}

.stat.active .stat-num { color: var(--green); }
.stat.locked .stat-num { color: var(--red); }
.stat.idle   .stat-num { color: var(--dim); }

.stat.active .stat-icon-circle { background: rgba(170,255,0,0.12); color: var(--green); }
.stat.locked .stat-icon-circle { background: rgba(255,34,85,0.12); color: var(--red); }
.stat.idle   .stat-icon-circle { background: rgba(255,255,255,0.06); color: var(--dim); }

/* Sezioni sala */
.room-section {
  margin-bottom: 32px;
}

.room-title {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--accent2);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* PC Grid */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.pc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.3s, background 0.3s;
  position: relative;
  overflow: hidden;
  width: 300px;
  flex-shrink: 0;
}

.pc-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}

.pc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--dim);
  transition: background 0.3s;
}

.pc-card.running::before { background: linear-gradient(90deg, #aaff00, #66cc00); }
.pc-card.warning::before { background: var(--orange); }
.pc-card.locked::before  { background: var(--red); }

.pc-card.running {
  border-color: rgba(170,255,0,0.25);
  background: linear-gradient(145deg, rgba(170,255,0,0.07), var(--panel) 55%);
}
.pc-card.warning {
  border-color: rgba(255,170,0,0.2);
  background: linear-gradient(145deg, rgba(255,170,0,0.08), var(--panel) 55%);
}
.pc-card.locked {
  border-color: rgba(255,34,85,0.2);
  background: linear-gradient(145deg, rgba(255,34,85,0.08), var(--panel) 55%);
}

.pc-card.running:hover { box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 22px rgba(170,255,0,0.12); }
.pc-card.warning:hover { box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 22px rgba(255,170,0,0.12); }
.pc-card.locked:hover  { box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 22px rgba(255,34,85,0.12); }

.pc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pc-name {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
}

.type-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 6px;
  padding: 3px;
  margin-right: 2px;
  vertical-align: middle;
}

.type-icon-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status-led {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.led-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.led-idle    { color: var(--dim); }
.led-idle    .led-dot { background: var(--dim); }

.led-running { color: var(--green); }
.led-running .led-dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.5s infinite; }

.led-warning { color: var(--orange); }
.led-warning .led-dot { background: var(--orange); box-shadow: 0 0 8px var(--orange); animation: pulse 1s infinite; }

.led-locked  { color: var(--red); }
.led-locked  .led-dot { background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 0.8s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes card-shake {
  0%,100% { transform: translateX(0); }
  15%     { transform: translateX(-7px); }
  30%     { transform: translateX(7px); }
  45%     { transform: translateX(-5px); }
  60%     { transform: translateX(5px); }
  75%     { transform: translateX(-3px); }
  90%     { transform: translateX(3px); }
}

@keyframes screen-flash {
  0%   { opacity: 0; }
  15%  { opacity: 0.22; }
  50%  { opacity: 0.12; }
  100% { opacity: 0; }
}

.expired-flash {
  animation: card-shake 0.6s ease;
  border-color: rgba(255,34,85,0.8) !important;
  box-shadow: 0 0 30px rgba(255,34,85,0.5) !important;
}

#screen-flash {
  position: fixed;
  inset: 0;
  background: #ff2255;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
}

#screen-flash.active {
  animation: screen-flash 1s ease forwards;
}

/* Timer ring */
.timer-ring-wrap {
  display: flex;
  justify-content: center;
  margin: 14px 0;
}

.timer-ring {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  transition: background 1s linear, box-shadow 0.4s;
}

.timer-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', monospace;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1px;
}

.timer-ring-inner.green  { color: var(--green); text-shadow: 0 0 14px rgba(170,255,0,0.5); }
.timer-ring-inner.orange { color: var(--orange); text-shadow: 0 0 14px rgba(255,170,0,0.5); }
.timer-ring-inner.red    { color: var(--red); text-shadow: 0 0 14px rgba(255,34,85,0.5); }
.timer-ring-inner.dim    { color: var(--dim); }

.session-times {
  font-size: 15px;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: 1px;
  margin: 6px 0 8px;
  font-family: 'Orbitron', monospace;
  display: flex;
  gap: 12px;
}
.session-times .st-start { color: #88cc44; }
.session-times .st-end   { color: #ff8844; }

/* Buttons */
.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn:hover  { transform: translateY(-1px); filter: brightness(1.2); }
.btn:active { transform: translateY(0); }

.btn-start  { background: linear-gradient(135deg, #aaff00, #66cc00); color: #000; flex: 1; }
.btn-unlock { background: linear-gradient(135deg, #cc44ff, #7700cc); color: #fff; flex: 1; }
.btn-add    { background: rgba(204,68,255,0.15); color: var(--accent2); border: 1px solid rgba(204,68,255,0.35); }
.btn-stop   { background: rgba(255,34,85,0.15); color: var(--red); border: 1px solid rgba(255,34,85,0.3); }

.btn-row {
  display: flex;
  gap: 6px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }
#modal-alert, #modal-confirm { z-index: 200; }

.modal {
  background: var(--panel);
  border: 1px solid var(--accent2);
  border-radius: 16px;
  padding: 32px;
  width: 420px;
  box-shadow: 0 0 40px rgba(204,68,255,0.2);
}

.modal h2 {
  font-family: 'Orbitron', monospace;
  color: var(--accent2);
  font-size: 16px;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 18px 12px;
  border-radius: 10px;
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(170,255,0,0.06);
}

.custom-input {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.custom-input input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 10px;
  font-family: 'Orbitron', monospace;
  font-size: 18px;
}

.custom-input input:focus { outline: none; border-color: var(--accent2); }

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-cancel  { background: transparent; border: 1px solid var(--dim); color: var(--dim); flex: 1; }
.btn-confirm { background: linear-gradient(135deg, #aaff00, #66cc00); color: #000; flex: 2; font-weight: 700; }

/* Log */
.log-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.log-title {
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--dim);
  margin-bottom: 12px;
}

.log-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

.log-list li {
  font-size: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.log-time { color: var(--dim); font-family: 'Orbitron', monospace; font-size: 14px; min-width: 60px; }
.log-msg  { color: var(--text); }
.log-list li:last-child { border-bottom: none; }

/* ---- Form generici (usati da tessere e tornei) ---- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 15px; letter-spacing: 2px; color: var(--dim); text-transform: uppercase; }

input, select, textarea {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  border-radius: 8px;
}

input::placeholder { color: var(--dim); opacity: 1; }
input:focus, select:focus { outline: none; border-color: var(--accent2); }

/* Override autofill colore sfondo */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 17px;
  width: 100%;
}
.form-input:focus { outline: none; border-color: var(--accent2); }

/* ===================== MOBILE ===================== */
@media (max-width: 768px) {

  body { padding: 12px; }

  /* Header */
  header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .header-logo { gap: 8px; }
  .logo-img { height: 36px; }
  h1 { font-size: 18px; }

  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .live-clock { font-size: 14px; width: 86px; }
  .online-badge { font-size: 13px; }

  .nav-tabs { gap: 4px; position: static; transform: none; }
  .nav-tab { font-size: 13px; padding: 6px 10px; }

  /* Stats */
  .stats-bar { gap: 8px; margin-bottom: 16px; }
  .stat { padding: 8px 10px; }
  .stat-num { font-size: 22px; }
  .stat-label { font-size: 13px; }

  /* Griglia PC — 2 colonne su mobile */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .pc-card { padding: 12px; }
  .pc-name { font-size: 14px; }
  .timer-ring { width: 96px; height: 96px; }
  .timer-ring-inner { font-size: 20px; }

  .btn { font-size: 14px; padding: 6px 8px; }

  /* Sezioni */
  .room-section { margin-bottom: 20px; }
  .room-title { font-size: 14px; }

  /* Modal */
  .modal {
    width: calc(100vw - 32px);
    padding: 20px 16px;
    margin: 0 16px;
  }

  .modal-grid { gap: 8px; }
  .preset-btn { padding: 14px 8px; font-size: 15px; }

  .modal-dettaglio { width: calc(100vw - 32px); max-height: 90vh; }

  /* Log */
  .log-list { max-height: 100px; }

  /* Toast */
  #toast { bottom: 12px; right: 12px; left: 12px; }
  .toast-msg { font-size: 15px; }
}

@media (max-width: 480px) {

  /* Griglia PC — 1 colonna su schermi piccoli */
  .grid { grid-template-columns: 1fr; }

  h1 { font-size: 16px; }
  .logo-img { height: 30px; }

  .header-right { gap: 6px; }
  .live-clock { display: none; }

  .nav-tab { font-size: 13px; padding: 5px 8px; }

  .modal { padding: 16px 12px; }
}
