/* ============================================================
   Sportiva Menu Widgets — Frontend CSS v1.1.0
   Naming convention: .spv-{component}-{element}--{modifier}
   Unified z-index hierarchy via CSS variables.
   ============================================================ */

:root {
  --spv-z-header: 100000;
  --spv-z-header-nav: 100010;
  --spv-z-mobile-backdrop: 2147481000;
  --spv-z-mobile-panel: 2147482000;
  --spv-z-dropdown: 2147483000;
}

/* ─── Reset base ─────────────────────────────────────────── */
.spv-mega-menu-wrap,
.spv-vertical-menu-wrap,
.spv-ham-wrap,
.spv-profile-menu-wrap,
.spv-wp-menu-wrap {
  box-sizing: border-box;
  position: relative;
}

/* ─── Nav list base ──────────────────────────────────────── */
.spv-nav-menu,
.spv-ham-nav,
.spv-profile-nav,
.spv-wp-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ─── Menu link base ─────────────────────────────────────── */
.spv-menu-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: color .2s, background .2s;
  position: relative;
}

/* ─── Icon ───────────────────────────────────────────────── */
.spv-menu-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ─── Badge ──────────────────────────────────────────────── */
.spv-menu-badge {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 10px;
  background: #e74c3c;
  color: #fff;
  white-space: nowrap;
  margin-left: auto;
}

/* ─── Description ────────────────────────────────────────── */
.spv-menu-description {
  display: block;
  font-size: .8em;
  opacity: .7;
  margin-top: 2px;
}

/* ─── Divider ────────────────────────────────────────────── */
.has-divider {
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}

/* ─── Submenu button ─────────────────────────────────────── */
.spv-submenu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 6px;
  margin-left: auto;
  transition: transform .2s;
  flex-shrink: 0;
}

.spv-submenu-btn[aria-expanded="true"] {
  transform: rotate(90deg);
}

/* ═══════════════════════════════════════════════════════════
   MEGA MENU HORIZONTAL
   ═══════════════════════════════════════════════════════════ */
.spv-mega-menu-wrap {
  position: relative;
}

.spv-nav-menu--horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.spv-nav-menu--horizontal>li {
  position: relative;
}

.spv-nav-menu--horizontal>li>.spv-menu-link {
  padding: 12px 16px;
  white-space: nowrap;
}

/* Standard dropdown */
.spv-nav-menu--horizontal li .spv-submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .12);
  border-radius: 4px;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  display: none;
  z-index: 1000;
}

.spv-nav-menu--horizontal li.is-open>.spv-submenu,
.spv-nav-menu--horizontal li:hover>.spv-submenu {
  display: block;
}

.spv-nav-menu--horizontal .spv-submenu .spv-menu-link {
  padding: 8px 16px;
  display: flex;
}

/* Nested submenu */
.spv-nav-menu--horizontal .spv-submenu .spv-submenu {
  top: 0;
  left: 100%;
}

/* ─── Megamenu Panel ──────────────────────────────────────── */
.spv-megamenu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 600px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
  border-radius: 4px;
  z-index: 1000;
  display: none;
}

.has-megamenu.is-open>.spv-megamenu-panel {
  display: block;
}

.spv-megamenu-panel.is-loading::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  margin: 40px auto;
  border: 3px solid #ccc;
  border-top-color: #3498db;
  border-radius: 50%;
  animation: spvSpin .8s linear infinite;
}

.spv-mm-panel--full {
  left: 0;
  right: 0;
  width: 100%;
}

.spv-megamenu-inner {
  padding: 20px;
}

/* ═══════════════════════════════════════════════════════════
   VERTICAL MENU
   ═══════════════════════════════════════════════════════════ */
.spv-vertical-menu-wrap {
  display: block;
}

.spv-nav-menu--vertical {
  display: block;
}

.spv-nav-menu--vertical>li {
  position: relative;
}

.spv-nav-menu--vertical>li>.spv-menu-link {
  padding: 10px 16px;
  display: flex;
}

.spv-nav-menu--vertical .spv-submenu {
  list-style: none;
  margin: 0;
  padding-left: 16px;
  display: none;
}

.spv-nav-menu--vertical li.is-open>.spv-submenu {
  display: block;
}

/* Megamenu panel in vertical — fly-out right */
.spv-nav-menu--vertical .spv-megamenu-panel {
  position: absolute;
  top: 0;
  left: 100%;
  min-width: 400px;
}

/* ═══════════════════════════════════════════════════════════
   HAMBURGER MENU
   ═══════════════════════════════════════════════════════════ */

/* Toggle button */
.spv-ham-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  position: relative;
  z-index: 10001;
}

.spv-ham-toggle-text {
  font-size: .9em;
}

/* Loader spinner */
.spv-ham-loader {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, .2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spvSpin .7s linear infinite;
}

.spv-ham-wrap.is-loading .spv-ham-loader {
  display: inline-block;
}

/* Panel */
.spv-ham-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 320px;
  max-width: 90vw;
  background: #fff;
  z-index: var(--spv-z-mobile-panel);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
}

.spv-ham-panel--right {
  left: auto;
  right: 0;
  transform: translateX(100%);
}

.spv-ham-panel--left {
  left: 0;
  right: auto;
  transform: translateX(-100%);
}

.spv-ham-panel.is-open {
  transform: translateX(0) !important;
}

/* Layout: full screen */
.spv-ham-wrap .spv-ham-panel--full {
  width: 100vw;
  max-width: 100vw;
}

/* Nav controls bar */
.spv-ham-nav-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  gap: 8px;
  flex-shrink: 0;
}

.spv-ham-close,
.spv-ham-back {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  font-size: 18px;
  line-height: 1;
  transition: opacity .2s;
}

.spv-ham-close:hover,
.spv-ham-back:hover {
  opacity: .7;
}

.spv-ham-back {
  margin-right: auto;
}

/* Header template */
.spv-ham-header {
  flex-shrink: 0;
  padding: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}

/* Before/After items */
.spv-ham-before-items,
.spv-ham-after-items {
  padding: 12px 16px;
}

/* Nav list */
.spv-ham-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.spv-ham-nav>li {
  position: relative;
}

.spv-ham-nav .spv-menu-link {
  padding: 12px 16px;
  display: flex;
}

.spv-ham-nav .spv-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
}

.spv-ham-nav .spv-submenu.is-open {
  display: block;
}

.spv-ham-nav .spv-submenu .spv-menu-link {
  padding-left: 32px;
}

.spv-ham-nav .spv-submenu .spv-submenu .spv-menu-link {
  padding-left: 48px;
}

/* Breadcrumbs */
.spv-ham-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: .8em;
  padding: 4px 0;
  flex: 1;
  min-width: 0;
}

.spv-bc-item {
  cursor: pointer;
  opacity: .7;
  white-space: nowrap;
}

.spv-bc-item:hover {
  opacity: 1;
}

.spv-bc-current {
  opacity: 1;
  font-weight: 600;
  cursor: default;
}

.spv-bc-divider {
  opacity: .5;
}

/* Cover overlay */
.spv-ham-cover {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: var(--spv-z-mobile-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.spv-ham-cover.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Toggle position helpers */
.spv-ham-wrap--toggle-right {
  display: flex;
  justify-content: flex-end;
}

.spv-ham-wrap--toggle-center {
  display: flex;
  justify-content: center;
}

.spv-ham-wrap--toggle-left {
  display: flex;
  justify-content: flex-start;
}

/* ═══════════════════════════════════════════════════════════
   PROFILE MENU
   ═══════════════════════════════════════════════════════════ */
.spv-profile-menu-wrap {
  display: inline-block;
  position: relative;
}

.spv-profile-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background .2s;
  white-space: nowrap;
  position: relative;
  line-height: 1;
}

.spv-profile-trigger:hover {
  background: rgba(0, 0, 0, .05);
}

.spv-profile-trigger>span:first-child,
.spv-profile-trigger-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spv-profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spv-profile-arrow {
  font-size: 12px;
  transition: transform .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spv-profile-trigger[aria-expanded="true"] .spv-profile-arrow {
  transform: rotate(180deg);
}

.spv-profile-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, .07);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  z-index: var(--spv-z-dropdown);
  display: none;
  padding: 6px 0;
  overflow: hidden;
}

.spv-profile-dropdown.is-open {
  display: block;
}

.spv-profile-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.spv-profile-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  text-decoration: none;
  font-size: 14px;
  color: #1a1a1a;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.spv-profile-nav a:hover {
  background: rgba(0, 0, 0, .06);
  color: var(--spv-color-primary, #2563eb);
}

/* Separatore e stile voce logout */
.spv-profile-nav li.spv-profile-logout {
  border-top: 1px solid rgba(0, 0, 0, .07);
  margin-top: 4px;
  padding-top: 4px;
}

.spv-profile-nav li.spv-profile-logout > a {
  color: #c0392b;
}

.spv-profile-nav li.spv-profile-logout > a:hover {
  background: #fff5f5;
  color: #c0392b;
}

/* Modalità SEPARATE: due link top-level affiancati (fix gap) */
.spv-profile-guest--separate {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spv-profile-guest-link {
  white-space: nowrap;
  font-size: 14px;
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 6px;
  transition: background .15s, color .15s, opacity .15s;
}

/* "Accedi" ghost */
.spv-profile-guest-link--login {
  border: 1px solid rgba(0, 0, 0, .25);
  color: inherit;
}

.spv-profile-guest-link--login:hover {
  background: rgba(0, 0, 0, .05);
}

/* "Registrati" filled */
.spv-profile-guest-link--register {
  background: var(--spv-color-primary, #2563eb);
  color: #ffffff !important;
  border: 1px solid transparent;
}

.spv-profile-guest-link--register:hover {
  opacity: .88;
}

/* Voci operative (Pannello Operatore / Crea evento / Richiedi evento) */
.spv-profile-nav .spv-op-item > a,
.spv-profile-nav .spv-op-item.is-disabled > span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: .9em;
  font-weight: 600;
}
.spv-profile-nav .spv-op-item__icon {
  font-size: 1em;
  line-height: 1;
}
.spv-profile-nav .spv-op-item.is-disabled > span {
  opacity: .5;
  cursor: not-allowed;
}

/* Mobile visibility: hide profile menu inside hamburger panel */
body.spv-ham-open .spv-profile-mobile--header_only {
  display: none !important;
}

/* Mobile visibility: always visible (default behavior preserved) */
.spv-profile-mobile--always {
  display: inline-block;
}

/* ROBUST FIX: Hide profile dropdown when hamburger menu is open (independent of Elementor control) */
body.spv-ham-open .spv-profile-dropdown {
  display: none !important;
  pointer-events: none !important;
}

/* ═══════════════════════════════════════════════════════════
   WP MENU (advanced)
   ═══════════════════════════════════════════════════════════ */
.spv-wp-menu-wrap {
  display: block;
}

.spv-wp-menu--horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.spv-wp-menu--vertical {
  display: block;
  list-style: none;
  margin: 0;
  padding: 0;
}

.spv-wp-menu--horizontal .spv-menu-link {
  padding: 10px 14px;
  white-space: nowrap;
}

.spv-wp-menu--vertical .spv-menu-link {
  padding: 8px 14px;
}

.spv-wp-menu .spv-submenu {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .1);
  border-radius: 4px;
}

.spv-wp-menu--horizontal li .spv-submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  display: none;
  z-index: 999;
}

.spv-wp-menu--horizontal li.is-open>.spv-submenu,
.spv-wp-menu--horizontal li:hover>.spv-submenu {
  display: block;
}

.spv-wp-menu--vertical .spv-submenu {
  display: none;
  padding-left: 14px;
  box-shadow: none;
}

.spv-wp-menu--vertical li.is-open>.spv-submenu {
  display: block;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */
@keyframes spvSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .spv-nav-menu--horizontal {
    flex-direction: column;
  }

  .spv-nav-menu--horizontal li .spv-submenu,
  .spv-megamenu-panel {
    position: static;
    box-shadow: none;
    min-width: 0;
    width: 100%;
  }

  /* ─── FIX mobile: pannello menu profilo ───────────────────────
     Su mobile il dropdown (position:absolute) restava intrappolato nello
     stacking context dell'header Elementor: loghi/"Download" trapelavano
     sopra il pannello. Lo trasformiamo in un pannello FIXED opaco che esce
     dallo stacking dell'header e copre in modo pulito. */
  .spv-profile-menu-wrap {
    z-index: var(--spv-z-dropdown);
  }

  .spv-profile-dropdown.is-open {
    position: fixed;
    top: 64px;                 /* sotto la riga utente dell'header (regolabile) */
    right: 12px;
    left: auto;
    width: min(88vw, 320px);
    min-width: 0;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;       /* opacita' garantita: niente bleed-through */
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
    z-index: var(--spv-z-dropdown);
  }
}

/* ═══════════════════════════════════════════════════════════
   ELEMENTOR EDITOR utils
   ═══════════════════════════════════════════════════════════ */
.elementor-editor-active .spv-ham-panel {
  position: relative;
  transform: none !important;
  display: flex;
}

.elementor-editor-active .spv-ham-cover {
  display: none !important;
}

/* Profile dropdown: nascosto nel canvas editor Elementor.
   Preveniva overlap con il pannello dei controlli (inline style display:block
   da preview_state='open' nel renderer). Apertura solo via clic JS su trigger.
   Per vedere il dropdown aperto: usa "Anteprima nel browser". */
.elementor-editor-active .spv-profile-dropdown {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   SPORTIVA HEADER LAYER FIX — ultra-specific portal selectors
   Panel/cover portaled to document.body in JS.
   Selectors cover both .spv-ham-panel and .spv-ham-panel--left variants.
   ═══════════════════════════════════════════════════════════ */

body.spv-ham-open {
  overflow: hidden !important;
}

/* Panel: closed state — common structural */
body>.spv-ham-panel {
  position: fixed !important;
  top: 0 !important;
  max-width: 86vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  z-index: 2147483646 !important;
  overflow-y: auto !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: transform .25s ease, visibility .25s ease !important;
}

/* Left panel (default) — slides in from left */
body>.spv-ham-panel:not(.spv-ham-panel--right),
body>.spv-ham-panel--left {
  left: 0 !important;
  right: auto !important;
  transform: translateX(-100%) !important;
}

/* Right panel — slides in from right */
body>.spv-ham-panel--right {
  right: 0 !important;
  left: auto !important;
  transform: translateX(100%) !important;
}

/* Panel: open state */
body.spv-ham-open>.spv-ham-panel,
body>.spv-ham-panel.is-open {
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Cover/overlay */
body>.spv-ham-cover {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483645 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity .25s ease !important;
}

body>.spv-ham-cover.is-visible {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Admin bar: WordPress adds "admin-bar" class to <body> */
body.admin-bar>.spv-ham-panel,
body.admin-bar>.spv-ham-panel--left,
body.admin-bar>.spv-ham-panel--right {
  top: 32px !important;
  height: calc(100vh - 32px) !important;
}

@media (max-width: 782px) {

  body.admin-bar>.spv-ham-panel,
  body.admin-bar>.spv-ham-panel--left,
  body.admin-bar>.spv-ham-panel--right {
    top: 46px !important;
    height: calc(100vh - 46px) !important;
  }
}