/* ==========================================================================
   WMB User Avatar — trigger + popup
   ========================================================================== */

/* ── Trigger wrapper ─────────────────────────────────────────────────────── */

.wmb-avatar-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.wmb-avatar-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* reset aggressivo — sovrascrive Elementor e temi */
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    line-height: 1;
    color: #273E4D;   /* stesso colore delle icone vicine nell'header */
    font: inherit;
    text-decoration: none !important;
}

.wmb-avatar-trigger:hover,
.wmb-avatar-trigger:focus,
.wmb-avatar-trigger:active {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: inherit;
}

.wmb-avatar-trigger:focus-visible {
    outline: 2px solid #555 !important;
    outline-offset: 3px;
    border-radius: 50% !important;
}

/* ── Avatar states ───────────────────────────────────────────────────────── */

.wmb-avatar--guest svg {
    width: 30px;
    height: 30px;
    display: block;
    color: inherit;   /* eredita il colore delle altre icone dell'header */
}

.wmb-avatar--user {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #f0f0f0;
    border: 2px solid #555;
    font-size: 12px;
    font-weight: 700;
    color: #333;
    letter-spacing: 0.04em;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.wmb-avatar-trigger:hover .wmb-avatar--user,
.wmb-avatar-trigger[aria-expanded="true"] .wmb-avatar--user {
    border-color: #222;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* Large variant (inside popup header) */
.wmb-avatar--lg {
    width: 56px;
    height: 56px;
    font-size: 19px;
    flex-shrink: 0;
    border: none;
    box-shadow: none;
    background-color: #e0e0e0;
    color: #444;
}
.wmb-avatar {
    color: #273E4D;
}
.wmb-avatar:hover {
    background-color: #D3521F !important;
}
.wmb-pwd-toggle:hover svg {
    color: white;
}
.wmb-pwd-toggle {
    border: 1px solid #D3521F;
    color: #D3521F !important;
    padding: 1px 0.7rem !important;
}
.wmb-pwd-toggle:hover {
    background-color: #D3521F !important;
}
.wmb-field__inner input {
    padding: .5rem 2rem !important;
}
.wmb-login-submit {
    border-color: #D3521F !important;
    color: #D3521F !important;
}
.wmb-login-submit:hover {
    background-color: #D3521F !important;
    color: white !important;
}
/* ==========================================================================
   Popup panel
   ========================================================================== */

#wmb-avatar-popup {
    position: fixed;      /* fixed: funziona anche dentro header sticky/Elementor */
    z-index: 999999;
    width: 320px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
    display: none;        /* nascosto di default — niente hidden attr */
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

#wmb-avatar-popup.wmb-avatar-popup--open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ── Arrow ───────────────────────────────────────────────────────────────── */

.wmb-avatar-popup__arrow {
    position: absolute;
    top: -7px;
    width: 13px;
    height: 7px;
    overflow: hidden;
    transform: translateX(-50%);
}

.wmb-avatar-popup__arrow::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #e2e2e2;
    top: 3px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 2px 0 0 0;
}

/* ── Close button ────────────────────────────────────────────────────────── */

.wmb-avatar-popup__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* reset completo — Elementor non deve toccare questo bottone */
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 6px;
    cursor: pointer;
    color: #666 !important;
    padding: 0 !important;
    transition: background 0.12s, color 0.12s;
}

.wmb-avatar-popup__close:hover,
.wmb-avatar-popup__close:focus {
    background: #f2f2f2 !important;
    color: #1a1a1a !important;
    outline: none !important;
    box-shadow: none !important;
}

.wmb-avatar-popup__close svg {
    width: 18px;
    height: 18px;
    display: block;
    pointer-events: none;
}

/* ── Popup head ──────────────────────────────────────────────────────────── */

.wmb-avatar-popup__head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 20px 20px;
    text-align: center;
}

/* Guest: big person icon */
.wmb-popup-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #f0f0f0;
    color: #666;
}

.wmb-popup-icon svg {
    width: 28px;
    height: 28px;
}

.wmb-popup-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

/* ── User popup head ─────────────────────────────────────────────────────── */

.wmb-avatar-popup--user .wmb-avatar-popup__head {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
    border-bottom: 1px solid #ebebeb;
    padding: 22px 20px 16px;
    gap: 14px;
}

.wmb-user-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    padding-top: 2px;
}

.wmb-user-info__name {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wmb-user-info__roles {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.wmb-user-info__email {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* ==========================================================================
   Login form
   ========================================================================== */

.wmb-login-form {
    padding: 0 20px 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wmb-login-error {
    background: #fff0f0;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    color: #b91c1c;
    font-size: 13px;
    padding: 8px 12px;
    margin: 0;
}

/* ── Field ───────────────────────────────────────────────────────────────── */

.wmb-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wmb-field label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wmb-field__inner {
    position: relative;
    display: flex;
    align-items: center;
}

.wmb-field__icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: #aaa;
    pointer-events: none;
    flex-shrink: 0;
}

.wmb-field__inner input {
    width: 100%;
    height: 40px;
    padding: 0 38px 0 34px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #1a1a1a;
    background: #fafafa;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.wmb-field__inner input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.12);
    background: #fff;
}

/* ── Password toggle ─────────────────────────────────────────────────────── */

.wmb-pwd-toggle {
    position: absolute;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 0;
    border-radius: 4px;
    transition: color 0.12s;
}

.wmb-pwd-toggle:hover {
    color: #555;
}

.wmb-pwd-toggle svg {
    width: 16px;
    height: 16px;
}

.wmb-eye-hide { display: none; }
.wmb-pwd-toggle--visible .wmb-eye-show { display: none; }
.wmb-pwd-toggle--visible .wmb-eye-hide { display: block; }

/* ── Remember me ─────────────────────────────────────────────────────────── */

.wmb-remember {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.wmb-remember input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: #0073aa;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Submit button ───────────────────────────────────────────────────────── */

.wmb-login-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 42px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}

.wmb-login-submit:hover {
    background: #005a87;
}

.wmb-login-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.wmb-login-submit__spinner {
    display: none;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wmbSpin 0.7s linear infinite;
}

.wmb-login-submit:disabled .wmb-login-submit__spinner {
    display: inline-block;
}

@keyframes wmbSpin {
    to { transform: rotate(360deg); }
}

/* ── Popup footer — guest (centered links) ───────────────────────────────── */

.wmb-popup-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px 18px;
    font-size: 12px;
    color: #888;
}

.wmb-popup-footer a {
    color: #0073aa;
    text-decoration: none;
}

.wmb-popup-footer a:hover {
    text-decoration: underline;
}

/* ── Popup footer — user (help left / logout right) ─────────────────────── */

.wmb-popup-footer--user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid #ebebeb;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
    gap: 0;
}

.wmb-popup-footer__help,
.wmb-popup-footer__logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
}

.wmb-popup-footer__help svg,
.wmb-popup-footer__logout svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.wmb-popup-footer__help {
    color: #555;
}

.wmb-popup-footer__help:hover {
    background: #efefef;
    color: #222;
}

.wmb-popup-footer__logout {
    color: #555;
}

.wmb-popup-footer__logout:hover {
    background: #efefef;
    color: #222;
}

/* ==========================================================================
   User panel — navigation (Moodle-style: text only, clean dividers)
   ========================================================================== */

.wmb-popup-nav {
    padding: 4px 0;
    border-bottom: 1px solid #ebebeb;
}

.wmb-popup-nav--secondary {
    border-bottom: none;
}

.wmb-popup-nav__item {
    display: block;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 400;
    color: #222;
    text-decoration: none;
    border-bottom: 1px solid #f2f2f2;
    transition: background 0.1s;
}

.wmb-popup-nav__item:last-child {
    border-bottom: none;
}

.wmb-popup-nav__item:hover {
    background: #f5f5f5;
    color: #222;
}
.wmb-avatar--guest svg {
    width: 28px;
    height: 27px;
    display: block;
    color: inherit;
}