/**
 * MG2025 Theme D - Detail Layout Specific
 * Layout 2 colonne SOLO per dettaglio utente e dettaglio foto
 * Optimized Version
 */

/* REGOLA GLOBALE: Nascondi sidebar nella pagina foto su mobile - RIMOSSA, gestita più sotto con selettori più specifici */

/* ============================================
   DETAIL LAYOUT CONTAINER
   ============================================ */

body .mg2025-detail-layout,
body .mg2025-profile-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
    background: var(--color-background);
    color: var(--color-text);
    gap: 0;
}

/* MOBILE: Override grid con flexbox - NASCONDI sidebar nelle pagine dettaglio utenti */
@media (max-width: 991px) {

    body .mg2025-detail-layout,
    body .mg2025-profile-layout {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
    }

    /* NASCONDI sidebar nelle pagine dettaglio utenti (photographer, model) */
    body .mg2025-detail-layout>.mg2025-sidebar {
        display: none !important;
    }

    /* Profile layout: mantieni sidebar visibile */
    body .mg2025-profile-layout>.mg2025-sidebar {
        order: 1 !important;
        position: static !important;
        width: 100% !important;
        height: auto !important;
    }

    body .mg2025-detail-layout>.mg2025-main,
    body .mg2025-profile-layout>.mg2025-main {
        order: 1 !important;
        width: 100% !important;
    }
}

/* ============================================
   SIDEBAR STICKY
   ============================================ */

body .mg2025-detail-layout .mg2025-sidebar,
body .mg2025-profile-layout .mg2025-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--color-background);
    border-right: 1px solid var(--color-border);
    padding: 0;
}

body .mg2025-detail-layout .mg2025-profile-card,
body .mg2025-profile-layout .mg2025-profile-card {
    padding: var(--padding-large) var(--padding-medium);
    background: var(--color-background);
}

/* ============================================
   PROFILE HEADER
   ============================================ */

body .mg2025-detail-layout .mg2025-profile-header,
body .mg2025-profile-layout .mg2025-profile-header {
    text-align: center;
    margin-bottom: var(--padding-medium);
}

body .mg2025-detail-layout .mg2025-avatar-container,
body .mg2025-profile-layout .mg2025-avatar-container {
    position: relative;
    display: inline-block;
    margin-bottom: var(--padding-small);
}

body .mg2025-detail-layout .mg2025-avatar,
body .mg2025-profile-layout .mg2025-avatar {
    width: 120px !important;
    height: 120px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-border);
}

body .mg2025-detail-layout .mg2025-profile-info,
body .mg2025-profile-layout .mg2025-profile-info {
    text-align: center;
}

body .mg2025-detail-layout .mg2025-name,
body .mg2025-profile-layout .mg2025-name {
    font-size: 24px;
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin: 0 0 8px 0;
}

body .mg2025-detail-layout .mg2025-role,
body .mg2025-profile-layout .mg2025-role {
    font-size: 16px;
    color: var(--color-text-muted);
    margin: 0 0 8px 0;
}

/* ============================================
   STATS
   ============================================ */

body .mg2025-detail-layout .mg2025-stats,
body .mg2025-profile-layout .mg2025-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--padding-small);
    margin-bottom: var(--padding-medium);
    padding: 20px 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    box-sizing: border-box;
}

body .mg2025-detail-layout .mg2025-stat,
body .mg2025-profile-layout .mg2025-stat {
    text-align: center;
}

body .mg2025-detail-layout .mg2025-stat-number,
body .mg2025-profile-layout .mg2025-stat-number {
    display: block;
    font-size: 20px;
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin-bottom: 4px;
}

body .mg2025-detail-layout .mg2025-stat-label,
body .mg2025-profile-layout .mg2025-stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   ACTIONS
   ============================================ */

body .mg2025-detail-layout .mg2025-actions,
body .mg2025-profile-layout .mg2025-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: var(--padding-medium);
}

body .mg2025-detail-layout .mg2025-btn,
body .mg2025-profile-layout .mg2025-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 160ms ease-out;
    text-decoration: none;
    width: 100%;
}

body .mg2025-detail-layout .mg2025-btn-primary,
body .mg2025-profile-layout .mg2025-btn-primary {
    background: var(--color-secondary);
    color: var(--color-primary);
}

body .mg2025-detail-layout .mg2025-btn-primary:hover,
body .mg2025-profile-layout .mg2025-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

body .mg2025-detail-layout .mg2025-btn-secondary,
body .mg2025-profile-layout .mg2025-btn-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

body .mg2025-detail-layout .mg2025-btn-secondary:hover,
body .mg2025-profile-layout .mg2025-btn-secondary:hover {
    background: var(--color-hover-overlay);
}

/* ============================================
   TAGS
   ============================================ */

body .mg2025-detail-layout .mg2025-tags,
body .mg2025-profile-layout .mg2025-tags {
    margin-bottom: var(--padding-medium);
}

body .mg2025-detail-layout .mg2025-tags-title,
body .mg2025-profile-layout .mg2025-tags-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body .mg2025-detail-layout .mg2025-tags-list,
body .mg2025-profile-layout .mg2025-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

body .mg2025-detail-layout .mg2025-tag,
body .mg2025-profile-layout .mg2025-tag {
    display: inline-block;
    padding: 4px 8px;
    background: var(--color-border);
    /* fallback/alt */
    color: var(--color-text);
    font-size: 12px;
    border-radius: 0;
    border: 1px solid var(--color-border);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

body .mg2025-detail-layout .mg2025-main,
body .mg2025-profile-layout .mg2025-main {
    padding: 0;
    background: var(--color-background);
}

body .mg2025-detail-layout .mg2025-gallery-container,
body .mg2025-profile-layout .mg2025-gallery-container {
    padding: 32px;
    background: var(--color-background);
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* MOBILE LAYOUT */
@media (max-width: 991px) {

    html body .mg2025-detail-layout,
    html body .mg2025-profile-layout,
    body .mg2025-detail-layout,
    body .mg2025-profile-layout,
    html .mg2025-detail-layout,
    html .mg2025-profile-layout {
        grid-template-columns: unset !important;
        grid-template-rows: unset !important;
        grid-auto-flow: unset !important;
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }

    /* Detail layout (pagine utente): NASCONDI sidebar su mobile - MASSIMA SPECIFICITÀ */
    html body .mg2025-detail-layout .mg2025-sidebar,
    html body .mg2025-detail-layout>.mg2025-sidebar,
    html body .mg2025-detail-layout>aside.mg2025-sidebar,
    html body .mg2025-detail-layout aside.mg2025-sidebar,
    html body aside.mg2025-sidebar.mg2025-sidebar,
    body .mg2025-detail-layout .mg2025-sidebar,
    html .mg2025-detail-layout .mg2025-sidebar,
    .mg2025-detail-layout .mg2025-sidebar,
    .mg2025-detail-layout aside.mg2025-sidebar {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }

    html body .mg2025-detail-layout>.mg2025-main,
    html body .mg2025-detail-layout>main.mg2025-main,
    html body .mg2025-detail-layout main.mg2025-main,
    html body main.mg2025-main.mg2025-main,
    body .mg2025-detail-layout .mg2025-main,
    html .mg2025-detail-layout .mg2025-main {
        width: 100% !important;
        max-width: 100% !important;
        order: 2 !important;
        -webkit-order: 2 !important;
        -ms-flex-order: 2 !important;
    }

    /* EVENTI E LOCATION: nascondi sidebar originale su mobile */
    body .mg2025-profile-layout.mg2025-event-detail>.mg2025-sidebar,
    html .mg2025-profile-layout.mg2025-event-detail>.mg2025-sidebar,
    body .mg2025-profile-layout.mg2025-location-detail>.mg2025-sidebar,
    html .mg2025-profile-layout.mg2025-location-detail>.mg2025-sidebar {
        display: none !important;
    }

    /* Mostra box utente dentro main su mobile per eventi e location */
    body .mg2025-profile-layout.mg2025-event-detail .mg2025-profile-card-mobile,
    html .mg2025-profile-layout.mg2025-event-detail .mg2025-profile-card-mobile,
    body .mg2025-profile-layout.mg2025-location-detail .mg2025-profile-card-mobile,
    html .mg2025-profile-layout.mg2025-location-detail .mg2025-profile-card-mobile {
        display: block !important;
        margin-top: 24px;
        padding-top: 24px;
        border-top: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
    }

    /* Profile layout: sidebar prima, main (con gallery) dopo */
    body .mg2025-profile-layout .mg2025-sidebar,
    html .mg2025-profile-layout .mg2025-sidebar,
    body .mg2025-profile-layout>.mg2025-sidebar,
    html .mg2025-profile-layout>.mg2025-sidebar,
    body .mg2025-profile-layout aside.mg2025-sidebar,
    html .mg2025-profile-layout aside.mg2025-sidebar {
        position: static !important;
        height: auto !important;
        border-right: none !important;
        border-bottom: 1px solid var(--color-border);
        width: 100% !important;
        max-width: 100% !important;
        order: 1 !important;
        -webkit-order: 1 !important;
        -ms-flex-order: 1 !important;
    }

    body .mg2025-profile-layout .mg2025-main,
    html .mg2025-profile-layout .mg2025-main,
    body .mg2025-profile-layout>.mg2025-main,
    html .mg2025-profile-layout>.mg2025-main,
    body .mg2025-profile-layout main.mg2025-main,
    html .mg2025-profile-layout main.mg2025-main {
        width: 100% !important;
        max-width: 100% !important;
        order: 2 !important;
        -webkit-order: 2 !important;
        -ms-flex-order: 2 !important;
    }

    /* Gallery dentro main - RIMOSSO: gestito dal plugin gallery */

    /* Photo detail layout: main prima, sidebar dopo (eccezione) */
    body .mg2025-detail-layout.mg2025-page-photo-detail .mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-page-photo-detail .mg2025-sidebar {
        position: static !important;
        height: auto !important;
        border-right: none !important;
        border-bottom: 1px solid var(--color-border);
        width: 100% !important;
        order: 2 !important;
    }

    body .mg2025-detail-layout.mg2025-page-photo-detail .mg2025-main,
    html .mg2025-detail-layout.mg2025-page-photo-detail .mg2025-main {
        width: 100% !important;
        order: 1 !important;
    }


    body .mg2025-detail-layout .mg2025-gallery-container,
    body .mg2025-profile-layout .mg2025-gallery-container {
        padding: 20px;
    }

    /* NASCONDI SIDEBAR NELLE PAGINE DETTAGLIO UTENTI SU MOBILE */
    body .mg2025-detail-layout .mg2025-sidebar,
    html .mg2025-detail-layout .mg2025-sidebar {
        display: none !important;
    }

    /* Photo detail: margin-top 0 - PRIORITÀ MASSIMA */
    body .mg2025-profile-layout.mg2025-photo-detail,
    html body .mg2025-profile-layout.mg2025-photo-detail,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail,
    html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail {
        margin-top: 0 !important;
    }
}

/* Tablet: margin-top per photo detail - PRIORITÀ MASSIMA */
@media (max-width: 991.98px) {

    body .mg2025-profile-layout.mg2025-photo-detail,
    html body .mg2025-profile-layout.mg2025-photo-detail,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail,
    html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail {
        display: flex !important;
        flex-direction: column !important;
        margin-top: 0 !important;
        grid-template-columns: none !important;
    }
}

/* Desktop: nascondi box mobile e mostra sidebar originale */
@media (min-width: 992px) {

    body .mg2025-profile-layout.mg2025-event-detail .mg2025-profile-card-mobile,
    html .mg2025-profile-layout.mg2025-event-detail .mg2025-profile-card-mobile,
    body .mg2025-profile-layout.mg2025-location-detail .mg2025-profile-card-mobile,
    html .mg2025-profile-layout.mg2025-location-detail .mg2025-profile-card-mobile {
        display: none !important;
    }

    body .mg2025-profile-layout.mg2025-event-detail>.mg2025-sidebar,
    html .mg2025-profile-layout.mg2025-event-detail>.mg2025-sidebar,
    body .mg2025-profile-layout.mg2025-location-detail>.mg2025-sidebar,
    html .mg2025-profile-layout.mg2025-location-detail>.mg2025-sidebar {
        display: block !important;
    }
}

@media (max-width: 767px) {

    /* NASCONDI SOLO l'aside nella pagina foto su mobile - PRIORITÀ MASSIMA - DEVE essere PRIMA delle regole che mostrano la sidebar */
    body .mg2025-detail-layout.mg2025-photo-detail aside.mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-page-photo-detail aside.mg2025-sidebar,
    body .mg2025-profile-layout.mg2025-photo-detail aside.mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail aside.mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-page-photo-detail aside.mg2025-sidebar,
    aside.mg2025-sidebar-photo-detail,
    body aside.mg2025-sidebar.mg2025-sidebar-photo-detail,
    html body aside.mg2025-sidebar.mg2025-sidebar-photo-detail,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail aside.mg2025-sidebar.mg2025-sidebar-photo-detail,
    html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail aside.mg2025-sidebar.mg2025-sidebar-photo-detail,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail aside[style*="display: none"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* NASCONDI SOLO l'aside nella pagina collection su mobile - PRIORITÀ MASSIMA - DEVE essere PRIMA delle regole che mostrano la sidebar */
    body .mg2025-detail-layout.mg2025-collection-detail aside.mg2025-sidebar,
    body .mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar-collection-detail,
    html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar-collection-detail,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside[style*="display: none"],
    html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside[style*="display: none"],
    body aside.mg2025-sidebar-collection-detail,
    html body aside.mg2025-sidebar-collection-detail,
    body aside.mg2025-sidebar.mg2025-sidebar-collection-detail,
    html body aside.mg2025-sidebar.mg2025-sidebar-collection-detail {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Mostra sidebar nei profili utente (NON nelle pagine foto) - PRIORITÀ MASSIMA - DEVE essere DOPO le regole che nascondono */
    /* Regola per layout con mg2025-profile-layout */
    body .mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) .mg2025-sidebar,
    html body .mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) .mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) .mg2025-sidebar,
    body .mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) aside.mg2025-sidebar,
    html body .mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) aside.mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) aside.mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) aside.mg2025-sidebar {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        position: static !important;
        left: auto !important;
        overflow: visible !important;
        padding: 0;
        margin: 0;
    }

    /* Mostra sidebar anche in mg2025-detail-layout quando NON è pagina foto o collection (per template photographer/model detail) - PRIORITÀ MASSIMA */
    body .mg2025-detail-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail):not(.mg2025-mobile-template) .mg2025-sidebar,
    html body .mg2025-detail-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail):not(.mg2025-mobile-template) .mg2025-sidebar,
    body .mg2025-detail-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail):not(.mg2025-mobile-template) aside.mg2025-sidebar,
    html body .mg2025-detail-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail):not(.mg2025-mobile-template) aside.mg2025-sidebar {
        display: block !important;
        width: 100%;
        max-width: 100%;
        padding: 0;
    }

    /* Mostra sidebar nel template mobile quando è profilo utente (NON pagina foto o collection) - PRIORITÀ MASSIMA */
    body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail) .mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail) .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail) aside.mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail) aside.mg2025-sidebar {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        position: static !important;
        left: auto !important;
        order: 1 !important;
        padding: 0;
    }

    /* Mostra sidebar nel template mobile quando è profilo utente (NON pagina foto) - PRIORITÀ MASSIMA - DEVE essere PRIMA delle regole che nascondono */
    body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) .mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) aside.mg2025-sidebar,
    html body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail) aside.mg2025-sidebar {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        position: static !important;
        left: auto !important;
        top: auto !important;
        right: auto !important;
        order: 1 !important;
        padding: 16px !important;
    }

    /* Assicura che il contenuto della sidebar sia visibile */
    body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail) .mg2025-sidebar .mg2025-profile-card,
    html body .mg2025-detail-layout.mg2025-mobile-template.mg2025-profile-layout:not(.mg2025-photo-detail):not(.mg2025-page-photo-detail):not(.mg2025-collection-detail) .mg2025-sidebar .mg2025-profile-card {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
    }

    /* Nascondi sidebar nella pagina di dettaglio foto su mobile - DEVE essere dopo la regola sopra */
    /* Regola generica per tutte le pagine foto */
    body .mg2025-photo-detail .mg2025-sidebar,
    html .mg2025-photo-detail .mg2025-sidebar,
    body .mg2025-page-photo-detail .mg2025-sidebar,
    html .mg2025-page-photo-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-photo-detail .mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-photo-detail .mg2025-sidebar,
    body .mg2025-profile-layout.mg2025-photo-detail .mg2025-sidebar,
    html .mg2025-profile-layout.mg2025-photo-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail .mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-page-photo-detail .mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-page-photo-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail aside.mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail aside.mg2025-sidebar {
        display: none !important;
    }

    /* Nascondi sidebar nella pagina di dettaglio collection su mobile - DEVE essere dopo la regola sopra */
    /* Regola generica per tutte le pagine collection */
    body .mg2025-collection-detail .mg2025-sidebar,
    html .mg2025-collection-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-collection-detail .mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-collection-detail .mg2025-sidebar,
    body .mg2025-profile-layout.mg2025-collection-detail .mg2025-sidebar,
    html .mg2025-profile-layout.mg2025-collection-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail .mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail .mg2025-sidebar,
    body .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar,
    html .mg2025-detail-layout.mg2025-profile-layout.mg2025-collection-detail aside.mg2025-sidebar {
        display: none !important;
    }

    body .mg2025-detail-layout .mg2025-profile-card,
    body .mg2025-profile-layout .mg2025-profile-card {
        padding: 20px 2px;
        width: 100%;
    }

    body .mg2025-detail-layout .mg2025-avatar,
    body .mg2025-profile-layout .mg2025-avatar {
        width: 80px;
        height: 80px;
    }

    body .mg2025-detail-layout .mg2025-name,
    body .mg2025-profile-layout .mg2025-name {
        font-size: 20px;
    }

    body .mg2025-detail-layout .mg2025-stats,
    body .mg2025-profile-layout .mg2025-stats,
    body .mg2025-detail-layout .mg2025-profile-card .mg2025-stats,
    body .mg2025-profile-layout .mg2025-profile-card .mg2025-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 0px !important;
        column-gap: 0px !important;
        row-gap: 0px !important;
        padding: 4px 0px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        display: grid !important;
    }

    body .mg2025-detail-layout .mg2025-stat,
    body .mg2025-profile-layout .mg2025-stat {
        padding: 0 !important;
        margin: 0 !important;
        min-width: 0 !important;
        width: auto !important;
        flex: 0 1 auto !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    body .mg2025-detail-layout .mg2025-stat-number,
    body .mg2025-profile-layout .mg2025-stat-number {
        font-size: 27px !important;
        margin-bottom: 0px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        padding: 0 !important;
    }

    body .mg2025-detail-layout .mg2025-stat-label,
    body .mg2025-profile-layout .mg2025-stat-label {
        font-size: 10px !important;
        letter-spacing: 0 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Gallery: rimuovi padding laterale per full-width */
    body .mg2025-detail-layout .mg2025-gallery-container,
    body .mg2025-profile-layout .mg2025-gallery-container {
        padding: 0;
        width: 100%;
        max-width: 100%;
    }

    body .mg2025-detail-layout .mg2025-main,
    body .mg2025-profile-layout .mg2025-main {
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
}

/* ============================================
   PROFILE LAYOUT - MOBILE COMPACT
   ============================================ */

/* Sidebar spacing */
body .mg2025-profile-layout .mg2025-sidebar,
body .mg2025-detail-layout .mg2025-sidebar {
    margin-top: 40px;
    margin-bottom: 0;
    margin-left: 0;
    margin-right: 0;
    padding: 4px 0px;
}

/* Profile card padding */
body .mg2025-profile-card {
    padding-bottom: 2px;
}

/* Profile card links padding */
body .mg2025-profile-card a {
    padding: 0px 0px;
}

/* Profile header spacing */
body .mg2025-profile-layout .mg2025-profile-header {
    margin-bottom: 9px;
}

/* Login CTA in fondo alla galleria */
body .mg2025-gallery-login-cta {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    margin-top: 40px;
}

body .mg2025-btn-large {
    padding: 16px 32px;
    font-size: 16px;
    min-width: 250px;
}

/* Role + Location unified */
body .mg2025-profile-layout .mg2025-role-location {
    font-size: 16px;
    color: var(--color-text-muted);
    margin: 0;
    text-align: center;
}

/* Mobile: ottimizzazioni compatte */
@media (max-width: 767px) {

    /* Layout orizzontale: avatar a sinistra + info a destra */
    body .mg2025-profile-layout .mg2025-profile-header,
    body .mg2025-detail-layout .mg2025-profile-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        text-align: left;
    }

    body .mg2025-profile-layout .mg2025-avatar-container,
    body .mg2025-detail-layout .mg2025-avatar-container {
        flex-shrink: 0;
        margin-bottom: 0;
    }

    body .mg2025-profile-layout .mg2025-avatar,
    body .mg2025-detail-layout .mg2025-avatar {
        width: 80px;
        height: 80px;
    }

    body .mg2025-profile-layout .mg2025-profile-info,
    body .mg2025-detail-layout .mg2025-profile-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        flex: 1;
    }

    body .mg2025-profile-layout .mg2025-name,
    body .mg2025-detail-layout .mg2025-name {
        font-size: 20px;
        text-align: left;
    }

    body .mg2025-profile-layout .mg2025-role-location,
    body .mg2025-detail-layout .mg2025-role {
        font-size: 14px;
        text-align: left;
    }

    /* Photo detail: descrizione e condividi sotto foto */
    body .mg2025-description-mobile {
        display: block;
        padding: 20px 16px;
        text-align: left;
    }

    body .mg2025-description-mobile .mg2025-description-title {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 12px;
        color: var(--color-text);
    }

    body .mg2025-description-mobile .mg2025-description-content {
        font-size: 14px;
        line-height: 1.6;
        color: var(--color-text-muted);
    }

    body .mg2025-share-mobile {
        display: flex;
        justify-content: center;
        padding: 0 16px 24px;
    }

    body .mg2025-share-mobile .mg2025-btn {
        width: 100%;
        max-width: 400px;
    }

    /* Photo detail: nascondi sidebar content */
    body .mg2025-detail-layout .mg2025-sidebar .mg2025-stats,
    body .mg2025-detail-layout .mg2025-description,
    body .mg2025-detail-layout .mg2025-tags {
        display: none;
    }

    /* Stats sotto la foto */
    body .mg2025-stats-mobile {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
    }

    /* ============================================
   OVERRIDE FINALE MOBILE - PRIORITÀ MASSIMA
   Deve venire DOPO tutte le altre regole per garantire che funzioni
   anche se altri CSS vengono caricati dopo
   ============================================ */

    @media (max-width: 991px) {

        /* FORZA LAYOUT FLEXBOX COLUMN - PRIORITÀ MASSIMA */
        html body .mg2025-detail-layout,
        html body body .mg2025-detail-layout {
            display: flex !important;
            flex-direction: column !important;
            grid-template-columns: unset !important;
            grid-template-rows: unset !important;
        }

        /* SIDEBAR PRIMA - ORDINE 1 - PRIORITÀ MASSIMA */
        html body .mg2025-detail-layout>.mg2025-sidebar,
        html body .mg2025-detail-layout>aside.mg2025-sidebar,
        html body .mg2025-detail-layout .mg2025-sidebar,
        html body body .mg2025-detail-layout .mg2025-sidebar {
            order: 1 !important;
            -webkit-order: 1 !important;
            width: 100% !important;
            max-width: 100% !important;
            position: static !important;
            height: auto !important;
            display: block !important;
        }

        /* MAIN DOPO - ORDINE 2 - PRIORITÀ MASSIMA */
        html body .mg2025-detail-layout>.mg2025-main,
        html body .mg2025-detail-layout>main.mg2025-main,
        html body .mg2025-detail-layout .mg2025-main,
        html body body .mg2025-detail-layout .mg2025-main {
            order: 2 !important;
            -webkit-order: 2 !important;
            width: 100% !important;
            max-width: 100% !important;
        }
    }

    /* OVERRIDE FINALE GALLERY 2 COLONNE MOBILE - PRIORITÀ MASSIMA */
    @media (max-width: 767px) {

        /* FORZA 2 COLONNE - PRIORITÀ MASSIMA */
        html body .mg2025-detail-layout .mg2025-photo-gallery,
        html body .mg2025-detail-layout #user-gallery,
        html body body .mg2025-detail-layout .mg2025-photo-gallery,
        html body body .mg2025-detail-layout #user-gallery {
            display: block !important;
            -webkit-column-count: 2 !important;
            -moz-column-count: 2 !important;
            column-count: 2 !important;
            -webkit-column-gap: 10px !important;
            -moz-column-gap: 10px !important;
            column-gap: 10px !important;
        }

        /* ELEMENTI FOTO - PRIORITÀ MASSIMA */
        html body .mg2025-detail-layout .mg2025-photo-gallery>*,
        html body .mg2025-detail-layout #user-gallery>*,
        html body body .mg2025-detail-layout .mg2025-photo-gallery>*,
        html body body .mg2025-detail-layout #user-gallery>* {
            display: inline-block !important;
            width: 100% !important;
            margin: 0 0 10px 0 !important;
            break-inside: avoid !important;
            -webkit-column-break-inside: avoid !important;
            page-break-inside: avoid !important;
            box-sizing: border-box !important;
            align-items: center;
            gap: 4px;
            padding: 15px 8px;
            margin: 0;
            border-top: 1px solid var(--color-border);
            border-bottom: 1px solid var(--color-border);
        }

        body .mg2025-stats-mobile .mg2025-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            flex: 1;
            padding: 0 2px;
        }

        body .mg2025-stats-mobile .mg2025-stat-number {
            font-size: 16px;
            font-weight: 700;
            color: var(--color-text);
            margin-bottom: 2px;
            display: block;
        }

        body .mg2025-stats-mobile .mg2025-stat-label {
            font-size: 9px;
            color: var(--color-text-muted);
            text-transform: uppercase;
            letter-spacing: 0.2px;
            display: block;
            line-height: 1.2;
        }
    }

    /* Desktop: nascondi stats mobile */
    @media (min-width: 768px) {

        body .mg2025-stats-mobile,
        body .mg2025-description-mobile,
        body .mg2025-share-mobile {
            display: none;
        }

        body .mg2025-profile-layout .mg2025-stats {
            display: flex;
            flex-direction: row;
            justify-content: space-around;
            align-items: center;
            gap: 20px;
            padding: 16px 0;
            margin-bottom: 20px;
            border-top: 1px solid var(--color-border);
            border-bottom: 1px solid var(--color-border);
        }

        body .mg2025-profile-layout .mg2025-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            flex: 1;
        }

        body .mg2025-profile-layout .mg2025-stat-number {
            font-size: 18px;
            font-weight: 700;
            color: var(--color-text);
            margin-bottom: 4px;
            display: block;
        }

        body .mg2025-profile-layout .mg2025-stat-label {
            font-size: 10px;
            color: var(--color-text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: block;
        }
    }

    /* ============================================
   OVERRIDE FINALE: margin-top 0 per photo detail
   Deve essere ALLA FINE per massima priorità
   ============================================ */
    @media (max-width: 991.98px) {

        body .mg2025-profile-layout.mg2025-photo-detail,
        html body .mg2025-profile-layout.mg2025-photo-detail,
        body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail,
        html body .mg2025-detail-layout.mg2025-profile-layout.mg2025-photo-detail,
        .mg2025-profile-layout.mg2025-photo-detail,
        body .mg2025-profile-layout.mg2025-photo-detail>*,
        body .mg2025-profile-layout.mg2025-photo-detail .mg2025-main,
        body .mg2025-profile-layout.mg2025-photo-detail .mg2025-sidebar {
            margin-top: 0 !important;
        }
    }

    /* FORCE HIDE ASIDE IN COLLECTIONS ON MOBILE - APPENDED FIX */
    @media (max-width: 991px) {

        html body .mg2025-detail-layout.mg2025-collection-detail .mg2025-sidebar,
        html body .mg2025-detail-layout.mg2025-page-collection .mg2025-sidebar,
        html body .mg2025-page-collection aside,
        html body .mg2025-collection-detail aside {
            display: none !important;
            visibility: hidden !important;
            width: 0 !important;
            height: 0 !important;
            padding: 0 !important;
            margin: 0 !important;
            position: absolute !important;
            left: -9999px !important;
        }

        /* DIRECT TARGET FIX FOR USER REQUEST */
        .mg2025-sidebar-collection-detail,
        aside.mg2025-sidebar-collection-detail {
            display: none !important;
            width: 0 !important;
            height: 0 !important;
            overflow: hidden !important;
            padding: 0 !important;
            margin: 0 !important;
            border: none !important;
        }
    }