/* ============================================================
       SPINNER OVERLAY - Full Screen
    ============================================================ */
.spinner-overlay {
  display: none; /* Nascosto di default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

.spinner-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================
       SPINNER CONTAINER
    ============================================================ */
.spinner-container {
  background: white;
  padding: 3rem 2rem;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  animation: slideUp 0.3s ease-out;
}

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

/* ============================================================
       SPINNER ANIMATIONS - 3 Tipi
    ============================================================ */

/* Tipo 1: Spinner Circolare (Stile AudioLex) */
.spinner-circle {
  width: 60px;
  height: 60px;
  margin: 0 auto 1.5rem;
  border: 4px solid #e5e7eb;
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Tipo 2: Spinner Gradient */
.spinner-gradient {
  width: 60px;
  height: 60px;
  margin: 0 auto 1.5rem;
  border: 4px solid transparent;
  border-top: 4px solid #667eea;
  border-right: 4px solid #764ba2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Tipo 3: Dots Spinner */
.spinner-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 auto 1.5rem;
}

.spinner-dots span {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.spinner-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.spinner-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Tipo 4: Progress Ring */
.spinner-ring {
  width: 60px;
  height: 60px;
  margin: 0 auto 1.5rem;
  position: relative;
}

.spinner-ring::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid #e5e7eb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
}

/* ============================================================
       SPINNER TEXT
    ============================================================ */
.spinner-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.spinner-message {
  font-size: 1rem;
  color: #666;
  margin-bottom: 1rem;
}

.spinner-progress {
  font-size: 0.875rem;
  color: var(--accent);
  font-weight: 600;
}

/* ============================================================
       PROGRESS BAR (Opzionale)
    ============================================================ */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-bar {
  height: 100%;
  background: var(--gradient);
  width: 0%;
  transition: width 0.3s ease;
  animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* ============================================================
       DEMO SECTION
    ============================================================ */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.demo-card {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.demo-card h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.btn {
  display: inline-block;
  padding: 1rem 2rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
}

.btn:hover {
  background: #0077ed;
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  background: #059669;
}

/* Button con spinner interno */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  right: 1rem;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

code {
  background: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  color: #dc2626;
}
