/* ============================================================
   LIVE WIDGET – Stato apertura + Prossimo evento
   Widget fisso laterale destro
   ============================================================ */

/* ── Contenitore principale ───────────────────────────── */
#live-widget,
#live-widget.live-widget {
  /* Reset completo per evitare interferenze */
  all: initial;
  /* Posizionamento fisso con massima priorità */
  position: fixed !important;
  right: 1.5rem !important;
  bottom: 5rem !important;
  left: auto !important;
  top: auto !important;
  z-index: 99999 !important;
  /* Dimensioni */
  width: 240px !important;
  max-width: calc(100vw - 2rem) !important;
  /* Stile */
  background: #ffffff !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10) !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  overflow: hidden !important;
  font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
  font-size: 0.82rem !important;
  line-height: 1.5 !important;
  color: #1A1A1A !important;
  /* Assicura che non sia influenzato da transform del parent */
  transform: translateZ(0) !important;
  will-change: auto !important;
  /* Display */
  display: block !important;
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

#live-widget:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.22), 0 4px 12px rgba(0,0,0,0.12) !important;
}

/* ── Toggle button ────────────────────────────────────── */
.live-widget-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-secondary, #1A1A1A);
  border: none;
  cursor: pointer;
  color: #fff;
  font-family: var(--font-heading, 'Barlow Condensed', Arial, sans-serif);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.2s ease;
  user-select: none;
  text-align: left;
}

.live-widget-toggle:hover {
  background: #2a2a2a;
}

/* Freccia indicatore stato */
.live-widget-toggle::after {
  content: '▲';
  font-size: 0.55rem;
  opacity: 0.45;
  margin-left: auto;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.live-widget.collapsed .live-widget-toggle::after {
  transform: rotate(180deg);
}

/* ── Pallino stato ────────────────────────────────────── */
.toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toggle-dot.open {
  background: #22c55e;
  animation: lw-pulse 2s infinite;
}

.toggle-dot.closed {
  background: #94a3b8;
  animation: none;
}

@keyframes lw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.3); }
}

.toggle-label { flex: 1; }

/* ── Body (contenuto collassabile) ───────────────────── */
.live-widget-body {
  overflow: hidden;
  transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.28s ease;
  /* Default visibile — PHP aggiunge .open al caricamento */
  max-height: 700px;
  opacity: 1;
  pointer-events: auto;
}

/* Stato APERTO */
.live-widget.open .live-widget-body {
  max-height: 700px;
  opacity: 1;
  pointer-events: auto;
}

/* Stato CHIUSO: classe .collapsed aggiunta da JS */
.live-widget.collapsed .live-widget-body {
  max-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

/* ── Sezioni interne ──────────────────────────────────── */
.lw-section {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f0f0f0;
}

.lw-section:last-child { border-bottom: none; }

/* ── Status ───────────────────────────────────────────── */
.lw-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

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

.lw-status-indicator.open  .lw-dot { background: #22c55e; animation: lw-pulse 2s infinite; }
.lw-status-indicator.closed .lw-dot { background: #94a3b8; }

.lw-status-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.lw-status-text strong { font-size: 0.88rem; }
.lw-status-indicator.open  .lw-status-text strong { color: #16a34a; }
.lw-status-indicator.closed .lw-status-text strong { color: #64748b; }
.lw-status-text small { font-size: 0.72rem; color: #94a3b8; }

/* ── Label sezione ────────────────────────────────────── */
.lw-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading, 'Barlow Condensed', Arial, sans-serif);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

/* ── Prossima apertura ────────────────────────────────── */
.lw-value {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lw-value strong { font-size: 0.85rem; color: var(--color-secondary, #1A1A1A); }
.lw-value span   { font-size: 0.78rem; color: var(--color-primary, #E8320A); font-weight: 600; }

/* ── Orari ────────────────────────────────────────────── */
.lw-schedule-rows {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.lw-schedule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #64748b;
  padding: 0.15rem 0;
}

.lw-schedule-row.today {
  color: var(--color-secondary, #1A1A1A);
  font-weight: 600;
}

.lw-schedule-row.today .lw-time { color: var(--color-primary, #E8320A); }

.lw-time { font-weight: 600; color: var(--color-secondary, #1A1A1A); }

/* ── Evento ───────────────────────────────────────────── */
.lw-event-card {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 6px;
  background: var(--color-bg, #F4F1EC);
  border: 1px solid #e8e8e8;
  transition: all 0.2s ease;
}

.lw-event-card:hover {
  border-color: var(--color-primary, #E8320A);
  background: #fff5f3;
}

.lw-event-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-primary, #E8320A);
  color: #fff;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  min-width: 42px;
  text-align: center;
  flex-shrink: 0;
}

.lw-event-date span  { font-family: var(--font-heading, Arial, sans-serif); font-size: 0.78rem; font-weight: 800; line-height: 1.2; }
.lw-event-date small { font-size: 0.62rem; opacity: 0.85; }

.lw-event-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.lw-event-info strong { font-size: 0.78rem; color: var(--color-secondary, #1A1A1A); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lw-event-info small  { font-size: 0.68rem; color: #94a3b8; }

.lw-no-event { font-size: 0.75rem; color: #94a3b8; margin: 0; line-height: 1.5; }

/* ── CTA ──────────────────────────────────────────────── */
.lw-cta { background: #fafafa; }

.lw-btn {
  display: block;
  text-align: center;
  background: var(--color-primary, #E8320A);
  color: #fff;
  font-family: var(--font-heading, 'Barlow Condensed', Arial, sans-serif);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.lw-btn:hover { background: #c42a08; color: #fff; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .live-widget {
    right: 1rem;
    bottom: 4.5rem;
    width: 220px;
  }
}

@media (max-width: 480px) {
  .live-widget {
    right: 0.75rem;
    bottom: 4rem;
    width: calc(100vw - 1.5rem);
    max-width: 300px;
  }
}