/*
 * client-assist-download-glass.css
 * Stile per i pulsanti download assistenza remota nell'header del portale clienti.
 * Liquid glass — coerente con client-portal-chrome-glass.css.
 * v20260420ra-markup-fix
 */

/* ── Header right: forza riga singola per bottoni + Accedi ──────────────── */
#header-inner .pull-right.flush-right {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  float: right !important;
  position: relative !important;
  z-index: 10500 !important; /* sopra #nav-wrapper */
}

#header-inner .pull-right.flush-right > .portal-header-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-wrap: wrap !important;
  gap: 0.15rem !important;
  margin: 0 0 0 auto !important;
  padding: 0 !important;
  max-width: 100%;
  min-width: 0;
  position: relative;
  isolation: isolate;
  z-index: 1;
  white-space: nowrap !important;
  line-height: 1 !important;
}

/* Nome utente loggato: respiro rispetto ai pulsanti assistenza (evita “attaccato” al chevron Supremo) */
body.client-side[data-mp-logged="1"] #header-inner .pull-right.flush-right > .portal-header-actions > .portal-header-user {
  margin-left: 0.7rem !important;
}

/* ── Header sopra #nav-wrapper quando il dropdown è aperto ─────────────── */
/*
 * #nav-wrapper ha position:relative; z-index:4 (client-desktop.css) e viene DOPO
 * #header nel DOM → sovrasta qualsiasi figlio dell'header senza z-index esplicito.
 * Alzare il contesto di #header a z-index:10 risolve senza rompere nient'altro.
 */
/* z-index header/nav: allineato a client-portal-chrome-glass (--z-fixed 1200) */
body.client-side > #container > #header {
  position: relative !important;
  z-index: var(--z-fixed, 1200) !important;
}

#nav-wrapper {
  position: relative !important;
  z-index: calc(var(--z-fixed, 1200) - 1) !important;
}

/* Split button: no contain:paint — tagliava il bordo destro del chevron in responsive */
body.client-side .mp-ra-btn-group,
body.client-side .mp-ra-btn,
body.client-side .mp-ra-btn__chevron {
  contain: none !important;
}

/* ── Split button group ──────────────────────────────────────────────────── */
.mp-ra-btn-group {
  position: relative;
  isolation: isolate;
  contain: none;
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  flex-shrink: 0;
  margin: 0 0 0 0.35rem;
  vertical-align: middle;
}

/* Pulsante principale (link download) */
.mp-ra-btn-group > .mp-ra-btn {
  position: relative !important;
  top: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: clamp(0.22rem, 0.35vw + 0.12rem, 0.38rem) clamp(0.42rem, 0.9vw + 0.2rem, 0.65rem) !important;
  border-radius: clamp(5px, 0.5vw, 7px) 0 0 clamp(5px, 0.5vw, 7px) !important;
  min-height: clamp(26px, 3.2vw + 18px, 32px) !important;
  box-sizing: border-box !important;
  border: 1px solid var(--portal-chrome-header-control-border, rgba(130,190,255,0.35)) !important;
  border-right: none !important;
  background: var(--portal-chrome-header-control, rgba(30,80,160,0.55)) !important;
  backdrop-filter: none !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: var(--portal-chrome-bar-font-size, clamp(12px, 0.48rem + 0.4vw, 14px)) !important;
  text-decoration: none !important;
  letter-spacing: 0.01em !important;
  gap: 0.3em;
  white-space: nowrap;
}

/*
 * Gruppo “pill” (senza chevron nel markup): il link occupa tutto lo span.
 * Usa :has() per non dipendere da classi aggiunte via JS → primo paint corretto.
 */
.mp-ra-btn-group:not(:has(.mp-ra-btn__chevron)) > .mp-ra-btn {
  border-radius: clamp(5px, 0.5vw, 7px) !important;
  border-right: 1px solid var(--portal-chrome-header-control-border, rgba(130,190,255,0.35)) !important;
}

/* Pulsante chevron (▾) */
.mp-ra-btn__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  min-width: 28px;
  padding: 0 0.45rem;
  min-height: clamp(26px, 3.2vw + 18px, 32px);
  border: 1px solid var(--portal-chrome-header-control-border, rgba(130,190,255,0.35));
  border-left: 1px solid rgba(255,255,255,0.12);
  border-radius: 0 clamp(5px, 0.5vw, 7px) clamp(5px, 0.5vw, 7px) 0;
  background: var(--portal-chrome-header-control, rgba(30,80,160,0.55));
  color: rgba(255,255,255,0.85);
  font-size: 0.7rem;
  cursor: pointer;
  box-sizing: border-box;
  line-height: 1;
  contain: none;
  /* Nessun effetto “animato” al click/apertura menu (rotazione, transition, tap highlight) */
  transition: none !important;
  animation: none !important;
  transform: none !important;
  -webkit-tap-highlight-color: transparent;
}

.mp-ra-btn-group > .mp-ra-btn:hover,
.mp-ra-btn-group > .mp-ra-btn:focus-visible {
  background: rgba(255,255,255,0.18) !important;
  border-color: rgba(180,220,255,0.55) !important;
  color: #ffffff !important;
  text-decoration: none !important;
  outline: none !important;
}

.mp-ra-btn__chevron:hover,
.mp-ra-btn__chevron:focus-visible {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  outline: none;
}

/* Menu aperto: solo stato colore (niente rotazione ▾→▴: evita effetto di movimento al click) */
.mp-ra-btn__chevron[aria-expanded="true"] {
  background: rgba(255,255,255,0.15);
  color: #ffffff;
}

/* ── Dropdown menu — liquid glass (allineato a staff-global-liquid-glass / customQ-dropdown) ── */
.mp-ra-menu {
  /* position/top/left gestiti via JS portal (position:fixed in document.body) */
  position: absolute; /* fallback se JS non caricato */
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  min-width: 200px;
  max-width: 280px;
  margin: 0;
  padding: 0.42rem 0;
  list-style: none;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(
    165deg,
    rgba(20, 34, 56, 0.94) 0%,
    rgba(12, 24, 44, 0.96) 48%,
    rgba(8, 16, 32, 0.98) 100%
  );
  -webkit-backdrop-filter: blur(var(--portal-chrome-blur, 18px)) saturate(160%);
  backdrop-filter: blur(var(--portal-chrome-blur, 18px)) saturate(160%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 20px 52px rgba(0, 4, 22, 0.52),
    0 8px 24px rgba(0, 12, 40, 0.35);
  z-index: 9999;
  transform-origin: top right; /* JS imposta top left / top right in base al viewport */
  color: var(--portal-chrome-text, #f1f5f9);
}

/* Stato nascosto (hidden rimosso via JS → si usa solo display block / hidden attr) */
.mp-ra-menu[hidden] {
  display: none !important;
}

.mp-ra-menu li {
  margin: 0;
  padding: 0;
}

.mp-ra-menu a[role="menuitem"] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  color: rgba(226, 232, 240, 0.95);
  text-decoration: none;
  font-size: clamp(12px, 0.46rem + 0.5vw, 14px);
  font-weight: 500;
  letter-spacing: 0.01em;
  gap: 0.5rem;
  border-radius: 10px;
  margin: 0.08rem 0.4rem;
  border: 1px solid transparent;
  transition: none;
}

.mp-ra-menu a[role="menuitem"]:hover:not(.mp-ra-menu__item--current),
.mp-ra-menu a[role="menuitem"]:focus-visible:not(.mp-ra-menu__item--current) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  outline: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.mp-ra-menu a[role="menuitem"]:focus-visible:not(.mp-ra-menu__item--current) {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 0 3px rgba(96, 165, 250, 0.35);
}

/* Versione software */
.mp-ra-version {
  color: rgba(147, 197, 253, 0.7);
  font-size: 0.75em;
  margin-left: auto;
}

/* Separatore tra voci */
.mp-ra-menu li + li::before {
  content: '';
  display: block;
  height: 1px;
  margin: 0.2rem 0.65rem;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1) 20%,
    rgba(255, 255, 255, 0.1) 80%,
    transparent
  );
}

/* ── Senza chevron: pulsante singolo ha angoli completi ───────────────────── */
.mp-ra-btn-group > .mp-ra-btn:only-child {
  border-radius: clamp(5px, 0.5vw, 7px) !important;
  border-right: 1px solid var(--portal-chrome-header-control-border, rgba(130,190,255,0.35)) !important;
}

/* ── Link "Accedi" / "Sign In": stessa altezza dei bottoni download ──────── */
#header-inner .pull-right.flush-right > .portal-header-actions > a:not([role]) {
  display: inline-flex !important;
  align-items: center !important;
  min-height: clamp(26px, 3.2vw + 18px, 32px) !important;
  padding: clamp(0.22rem, 0.35vw + 0.12rem, 0.38rem) clamp(0.42rem, 0.9vw + 0.2rem, 0.65rem) !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  font-size: var(--portal-chrome-bar-font-size, clamp(12px, 0.48rem + 0.4vw, 14px)) !important;
  white-space: nowrap !important;
}

/* ── Mobile sheet: varianti assistenza ───────────────────────────────────── */
@media screen and (max-width: 768px) {
  /* Nei menu mobile, il dropdown assoluto non funziona — usiamo <details> */
  .mp-ra-btn-group {
    display: none !important; /* nasconde il split button dell'header su mobile */
  }

  li.mp-ra-mobile-tool {
    padding: 0;
  }

  li.mp-ra-mobile-tool > a {
    display: block;
    padding: 0.6rem 1rem;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
  }

  .mp-ra-mobile-variants {
    padding: 0 0.5rem 0.4rem 1rem;
    font-size: 0.9em;
  }

  .mp-ra-mobile-variants summary {
    cursor: pointer;
    color: rgba(147,197,253,0.85);
    padding: 0.2rem 0;
    list-style: none;
  }

  .mp-ra-mobile-variants summary::-webkit-details-marker {
    display: none;
  }

  .mp-ra-mobile-variants summary::before {
    content: '▾ ';
    font-size: 0.8em;
  }

  .mp-ra-mobile-variants[open] summary::before {
    content: '▴ ';
  }

  .mp-ra-mobile-variants ul {
    list-style: none;
    padding: 0.25rem 0 0 0.75rem;
    margin: 0;
  }

  .mp-ra-mobile-variants ul li a {
    display: block;
    padding: 0.3rem 0;
    color: rgba(200,220,255,0.9);
    text-decoration: none;
    font-size: 0.92em;
  }
}

/* Desktop: nascondi le voci mobile-only nel body del menu hamburger */
@media screen and (min-width: 769px) {
  li.mp-ra-mobile-tool {
    display: none !important;
  }
}

/* ── Motion reduced ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mp-ra-btn-group > .mp-ra-btn,
  .mp-ra-btn__chevron,
  .mp-ra-menu {
    transition: none !important;
  }
  .mp-ra-btn__chevron[aria-expanded="true"] {
    transform: none;
  }
}

/* ── Focus visibile WCAG AA ──────────────────────────────────────────────── */
.mp-ra-btn-group > .mp-ra-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.8) !important;
  outline-offset: 2px !important;
}

.mp-ra-btn__chevron:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.8);
  outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════════════════
   Audit 2026-04-18 — feedback UX: loading, toast, voce corrente evidenziata
   ════════════════════════════════════════════════════════════════════════ */

/*
 * Voce rilevata — stesso linguaggio CTA della home:
 * body.client-side.index-page .glass-actions … div#sign-in-button (client-index-glass.css)
 * Shine come strati background (no ::before/::after) così il testo resta sempre leggibile.
 */
.mp-ra-menu__item--current {
  position: relative !important;
  overflow: hidden !important;
  border-radius: calc(var(--glass-radius-sm, 15px) + 2px) !important;
  border: 1px solid rgba(255, 255, 255, 0.32) !important;
  background:
    radial-gradient(
      ellipse 100% 100% at 50% 0%,
      rgba(255, 255, 255, 0.45),
      transparent 72%
    ),
    linear-gradient(
      118deg,
      rgba(255, 255, 255, 0.38) 0%,
      rgba(255, 255, 255, 0.08) 38%,
      transparent 58%
    ),
    linear-gradient(
      168deg,
      rgba(120, 200, 255, 0.42) 0%,
      rgba(55, 130, 240, 0.38) 38%,
      rgba(28, 72, 200, 0.62) 100%
    ) !important;
  background-blend-mode: overlay, soft-light, normal !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 8, 28, 0.35);
  -webkit-backdrop-filter: blur(14px) saturate(175%);
  backdrop-filter: blur(14px) saturate(175%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 0 0 1px rgba(56, 145, 255, 0.18) inset,
    0 12px 32px rgba(12, 48, 140, 0.48),
    0 4px 14px rgba(0, 20, 80, 0.28) !important;
  transition: none !important;
}

.mp-ra-menu li a[role="menuitem"].mp-ra-menu__item--current {
  padding: 0.55rem 0.95rem !important;
}

.mp-ra-menu__item--current .mp-ra-version {
  color: rgba(255, 255, 255, 0.82) !important;
  text-shadow: 0 1px 1px rgba(0, 8, 28, 0.25);
}

.mp-ra-menu a[role="menuitem"].mp-ra-menu__item--current:hover {
  border-color: rgba(255, 255, 255, 0.45) !important;
  background:
    radial-gradient(
      ellipse 100% 100% at 50% 0%,
      rgba(255, 255, 255, 0.48),
      transparent 72%
    ),
    linear-gradient(
      118deg,
      rgba(255, 255, 255, 0.42) 0%,
      rgba(255, 255, 255, 0.12) 38%,
      transparent 58%
    ),
    linear-gradient(
      168deg,
      rgba(140, 215, 255, 0.5) 0%,
      rgba(70, 150, 255, 0.44) 40%,
      rgba(36, 92, 220, 0.68) 100%
    ) !important;
  background-blend-mode: overlay, soft-light, normal !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.34) inset,
    0 0 0 1px rgba(120, 190, 255, 0.28) inset,
    0 16px 40px rgba(14, 64, 180, 0.55),
    0 0 28px rgba(56, 145, 255, 0.22) !important;
  outline: none;
}

.mp-ra-menu a[role="menuitem"].mp-ra-menu__item--current:focus-visible {
  outline: none !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.34) inset,
    0 0 0 1px rgba(120, 190, 255, 0.28) inset,
    0 16px 40px rgba(14, 64, 180, 0.55),
    0 0 0 3px rgba(56, 145, 255, 0.35),
    0 0 28px rgba(56, 145, 255, 0.22) !important;
}

@media (prefers-reduced-transparency: reduce) {
  .mp-ra-menu__item--current {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: linear-gradient(168deg, #2a7fe0 0%, #2456c8 52%, #1c4cb0 100%) !important;
    background-blend-mode: normal !important;
  }

  .mp-ra-menu a[role="menuitem"].mp-ra-menu__item--current:hover,
  .mp-ra-menu a[role="menuitem"].mp-ra-menu__item--current:focus-visible {
    background: linear-gradient(168deg, #3190f0 0%, #2865d8 52%, #2058c8 100%) !important;
    background-blend-mode: normal !important;
  }
}

/* Stato loading (durante il redirect) */
.mp-ra-btn--loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
}
.mp-ra-btn--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(168, 220, 255, 0.25) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: mp-ra-loading-shimmer 1.1s linear infinite;
  pointer-events: none;
}
@keyframes mp-ra-loading-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast notification */
.mp-ra-toast {
  position: fixed;
  isolation: isolate;
  contain: paint;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 9999;
  max-width: min(360px, 92vw);
  padding: 0.7rem 1rem;
  background: rgba(15, 25, 45, 0.95);
  color: #ffffff;
  border: 1px solid rgba(168, 220, 255, 0.35);
  border-radius: 10px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  font-family: "Montserrat", "Open Sans", system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mp-ra-toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.mp-ra-toast--success { border-color: rgba(74, 222, 128, 0.45); }
.mp-ra-toast--error   { border-color: rgba(248, 113, 113, 0.45); }

@media (prefers-reduced-motion: reduce) {
  .mp-ra-btn--loading::after,
  .mp-ra-toast { animation: none !important; transition: opacity 0.1s !important; }
}

@media (max-width: 640px) {
  .mp-ra-toast { right: 0.6rem; bottom: 0.6rem; left: 0.6rem; max-width: none; }
}

/*
 * Tablet / desktop stretto (901–1280px): evita che max-width 520px su .pull-right
 * comprima i gruppi Rustdesk/Supremo e tagli il chevron destro (contain:paint + overflow-x body).
 */
@media screen and (min-width: 901px) and (max-width: 1280px) {
  #header-inner .pull-right.flush-right > .portal-header-actions {
    row-gap: 0.35rem !important;
    column-gap: 0.38rem !important;
  }

  .mp-ra-btn-group {
    margin-left: 0.25rem;
  }

  .mp-ra-btn-group > .mp-ra-btn {
    padding-left: clamp(0.35rem, 0.7vw + 0.15rem, 0.55rem) !important;
    padding-right: clamp(0.35rem, 0.7vw + 0.15rem, 0.55rem) !important;
  }
}
