:root {
  --bg: #0b0f12;
  --panel: #0f1417;
  --muted: #98a0a6;
  --accent: #6ee7b7;
  --accent-2: #60a5fa;
  --neon-activity: #7cfc00;
  --glass: rgba(255, 255, 255, 0.03);
  --card-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
  --radius: 12px;
  --text: #e6eef3;
}

[data-theme="light"] {
  --bg: #f6f9fb;
  --panel: #ffffff;
  --muted: #6b7280;
  --accent: #0ea5a6;
  --accent-2: #2563eb;
  --glass: rgba(2, 6, 23, 0.03);
  --card-shadow: 0 6px 18px rgba(14, 30, 37, 0.06);
  --text: #0b1320;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  padding: 28px 18px;
  background: linear-gradient(180deg, var(--panel), rgba(0, 0, 0, 0.02));
  border-right: 1px solid rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
}
.brand {
  font-weight: 700;
  font-size: 20px;
}
/* Lang reference */
.lang-ref {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 24px;
  color: var(--muted);
  font-size: 13px;
}
.lang-ref .lang {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.chat-widget .chat-toggle {
  gap: 6px;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
}
.lang-ref svg {
  border-radius: 4px;
}

/* Modal */
.modal.hidden {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
}
.chat-widget .chat-toggle .chat-logo-img {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
}
.modal-panel {
  position: relative;
  background: var(--panel);
  border-radius: 12px;
  padding: 18px;
  width: 420px;
  box-shadow: var(--card-shadow);
  z-index: 2;
}
.modal-close {
  position: absolute;
  right: 8px;
  top: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
.modal-panel h3 {
  margin-top: 0;
}
.modal-panel form label {
  display: block;
  margin: 8px 0;
}
.modal-panel input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
  color: var(--text);
}

/* Progress bar */
.progress {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 800ms cubic-bezier(0.2, 0.9, 0.2, 1);
}
.prog-label {
  position: absolute;
  right: 8px;
  top: -18px;
  font-size: 12px;
  color: var(--muted);
}

/* Count up animation helper (visually) */
.big.animated {
  transition: transform 0.35s;
  transform-origin: left;
}

.brand span {
  color: var(--accent);
  margin-left: 6px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar a {
  padding: 10px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.sidebar a.active {
  background: var(--glass);
  color: var(--text);
}
.sidebar-footer {
  margin-top: auto;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(6px);
}
.search input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
  color: var(--text);
  min-width: 220px;
}
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #041125;
  font-weight: 600;
}

.content {
  padding: 24px;
}
.page-title {
  margin: 0 0 18px 0;
}
.grid {
  display: grid;
  gap: 16px;
}
.cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 18px;
}
.card {
  background: var(--panel);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: visible;
  transition:
    transform 0.18s ease,
    box-shadow 0.25s ease;
}
.card h3 {
  margin: 0 0 10px 0;
  color: var(--muted);
  font-weight: 600;
}
.big {
  font-size: 22px;
  margin: 0;
}
.meta {
  color: var(--muted);
  margin-top: 8px;
  font-size: 13px;
}
.chart-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sparkline {
  height: 48px;
}

/* Neon / outline hover effect for cards */
.card::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: calc(var(--radius) + 6px);
  pointer-events: none;
  box-shadow:
    0 0 18px rgba(110, 231, 183, 0.06),
    0 0 34px rgba(96, 165, 250, 0.03);
  opacity: 0;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}
.card:hover::after,
.card:focus-within::after {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow:
    0 0 30px rgba(110, 231, 183, 0.12),
    0 0 46px rgba(96, 165, 250, 0.06);
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.7);
}

/* Sidebar menu hover/active neon */
.sidebar a {
  transition: all 0.18s ease;
}
.sidebar a:hover {
  color: var(--text);
  background: linear-gradient(
    90deg,
    rgba(110, 231, 183, 0.04),
    rgba(96, 165, 250, 0.03)
  );
  box-shadow:
    0 6px 20px rgba(96, 165, 250, 0.04),
    0 0 18px rgba(96, 165, 250, 0.06);
  transform: translateX(6px);
}
.sidebar a:focus {
  outline: 2px solid rgba(110, 231, 183, 0.12);
  outline-offset: 2px;
}
.sidebar a.active {
  box-shadow:
    0 6px 24px rgba(2, 6, 23, 0.6),
    0 0 20px rgba(110, 231, 183, 0.06);
}

.two-columns {
  grid-template-columns: 1fr 380px;
}
.panel {
  background: var(--panel);
  padding: 16px;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
.table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}
.table th {
  color: var(--muted);
  text-align: left;
  padding: 8px 6px;
  font-weight: 600;
}
.table td {
  padding: 8px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.02);
}
.activity {
  list-style: none;
  padding: 0;
  margin: 0;
}
.activity li {
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.02);
  color: var(--muted);
}

.footer {
  padding: 12px 24px;
  color: var(--muted);
  font-size: 13px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 24px;
  transition: all 0.25s;
}
.slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: all 0.25s;
}
.switch input:checked + .slider {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.switch input:checked + .slider:before {
  transform: translateX(18px);
  background: #04202b;
}

/* Progetti recenti: effetto box neon più evidente */
.two-columns .panel:first-child {
  position: relative;
  overflow: visible;
  transition:
    transform 0.18s ease,
    box-shadow 0.25s ease;
}
.two-columns .panel:first-child::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 16px;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 10px rgba(110, 231, 183, 0.04);
}
.two-columns .panel:first-child:hover::after {
  opacity: 1;
  box-shadow:
    0 6px 36px rgba(110, 231, 183, 0.12),
    0 0 26px rgba(96, 165, 250, 0.06);
}
.two-columns .panel:first-child:hover {
  transform: translateY(-6px);
}

/* Effetto neon per il secondo pannello (Attività recente) */
.two-columns .panel:last-child {
  position: relative;
  overflow: visible;
  transition:
    transform 0.18s ease,
    box-shadow 0.25s ease;
}
.two-columns .panel:last-child::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 18px;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 18px rgba(124, 252, 0, 0.06);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    box-shadow 0.22s ease;
  z-index: 0;
}
.two-columns .panel:last-child:hover::after,
.two-columns .panel:last-child:focus-within::after {
  opacity: 1;
  box-shadow:
    0 8px 44px rgba(124, 252, 0, 0.18),
    0 0 36px rgba(124, 252, 0, 0.08);
  transform: translateY(-2px);
}
.two-columns .panel:last-child:hover,
.two-columns .panel:last-child:focus-within {
  transform: translateY(-6px);
  z-index: 2;
}

/* Rinforzo visibile: box-shadow e bordo neon diretto sul pannello */
.two-columns .panel:last-child:hover,
.two-columns .panel:last-child:focus-within {
  box-shadow:
    0 18px 60px rgba(124, 252, 0, 0.18),
    0 0 40px rgba(124, 252, 0, 0.08);
  border: 1px solid rgba(124, 252, 0, 0.12);
}

/* Evidenzia le voci interne durante hover */
.two-columns .panel:last-child:hover .activity li,
.two-columns .panel:last-child:focus-within .activity li {
  color: var(--neon-activity);
  transition: color 0.18s ease;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer .demo-link,
.sidebar-footer .logout {
  display: inline-flex;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}
.sidebar-footer .demo-link:hover {
  color: var(--text);
  background: linear-gradient(
    90deg,
    rgba(110, 231, 183, 0.03),
    rgba(96, 165, 250, 0.02)
  );
  transform: translateX(6px);
}
.sidebar-footer .logout {
  justify-self: flex-end;
}

/* JS official link subtle highlight */
.lang-ref .js-official:hover {
  color: var(--text);
}

/* Topbar JS icon */
.topbar .top-js {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  margin-right: 8px;
}
.topbar .top-js svg {
  display: block;
}
.topbar .top-js:hover {
  color: var(--text);
  background: linear-gradient(
    90deg,
    rgba(110, 231, 183, 0.03),
    rgba(96, 165, 250, 0.02)
  );
  box-shadow:
    0 6px 18px rgba(96, 165, 250, 0.04),
    0 0 14px rgba(110, 231, 183, 0.04);
  transform: translateY(-2px);
}
.topbar .top-js:focus {
  outline: 2px solid rgba(110, 231, 183, 0.12);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .two-columns {
    grid-template-columns: 1fr;
  }
  .app {
    flex-direction: column;
  }
  .topbar {
    padding: 12px;
  }
}

/* Chat widget styles */
.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 120;
  font-family: inherit;
}
.chat-widget .chat-toggle {
  position: relative;
  z-index: 6;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #041125;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(2, 6, 23, 0.4);
}
.chat-widget .chat-panel {
  width: 340px;
  height: 440px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s ease;
}
.chat-widget.closed .chat-panel {
  opacity: 0;
  transform: translateY(18px) scale(0.98);
}
.chat-widget:not(.closed) .chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent);
}
.chat-title {
  font-weight: 700;
}
.chat-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
.chat-messages {
  flex: 1;
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-form {
  display: flex;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.02);
  gap: 8px;
}
.chat-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
  color: var(--text);
}
.chat-form .chat-send {
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #041125;
  cursor: pointer;
}
.msg {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 10px;
  line-height: 1.3;
}
.msg.outgoing {
  align-self: flex-end;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #041125;
}
.msg.incoming {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.msg.small {
  font-size: 13px;
  padding: 8px 10px;
}
.typing {
  display: inline-block;
  width: 40px;
}
.typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  margin-right: 6px;
  animation: blink 1s infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes blink {
  0% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.25;
  }
}

@media (max-width: 480px) {
  .chat-widget .chat-panel {
    width: 92vw;
    right: 6px;
    height: 60vh;
  }
}
