/* === SINGLE AD PROFILE === */
/* ========================================================================== */
/* SINGLE AD PROFILE PAGE STYLES */
/* ========================================================================== */

.single-ad-action-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    width: 100%;
    max-width: 900px;
    /* Let it stretch nicely */
}

.back-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

.back-link:hover {
    color: var(--accent-pink);
}

.action-label-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
    padding: 0;
}

.action-label-btn:hover {
    color: var(--accent-pink);
}

.action-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
}

.claim-ad-link {
    color: var(--text-muted);
    font-size: 0.95rem;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

.claim-ad-link strong {
    color: var(--accent-pink);
    font-weight: 600;
}

.claim-ad-link:hover {
    color: white;
}

.claim-ad-link:hover strong {
    text-decoration: underline;
}

.mobile-cat-title {
    display: none;
}

.mami-mobile-only {
    display: none;
}
.mami-desktop-only {
    display: block;
}

@media (max-width: 1024px) {
    .single-ad-action-bar .desktop-text {
        display: none;
    }

    .mobile-cat-title {
        display: block;
        flex-grow: 1;
        text-align: center;
        font-weight: 600;
        letter-spacing: 1px;
        color: var(--text-main);
        font-size: 0.95rem;
    }

    .mami-mobile-only {
        display: block;
    }
    .mami-desktop-only {
        display: none;
    }

    .back-link {
        font-size: 1.2rem;
    }

    .claim-ad-link {
        display: none;
    }

    .action-divider {
        display: none;
    }

    .single-ad-action-bar {
        justify-content: flex-end;
    }

    /* Let the back button sit on the left of the stretched pill if necessary or push everything right */
    .back-link {
        margin-right: auto;
    }
}

.single-ad-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Profile Action Panel specific rules */
.profile-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.profile-fav-standalone {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.profile-fav-standalone:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-pink);
}

.profile-fav-standalone img {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
    transition: filter 0.3s ease;
}

.profile-fav-standalone.active {
    background: var(--accent-pink);
    border-color: var(--accent-pink);
}

.profile-fav-standalone.active img {
    filter: brightness(0) invert(1);
    transform: scale(1.1);
}

/* Profile Contained Gallery */
.profile-gallery {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

.gallery-main-view {
    width: 100%;
    height: 550px;
    border-radius: 12px;
    background: #0b0f19;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.gallery-main-view img,
.gallery-main-view video {
    height: 100%;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* PERFECT for avoiding cropping vertical/low quality photos */
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3));
}

.gallery-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    margin-top: -10px; /* Compensa esattamente il margin-top delle thumb riportandole all'altezza originale */
    padding-bottom: 8px;
    /* For scrollbar space */
    max-width: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-pink) rgba(255,255,255,0.05); /* Firefox support */
    cursor: grab;
}

.gallery-strip:active {
    cursor: grabbing;
}

/* Custom Scrollbar for strip */
.gallery-strip::-webkit-scrollbar {
    height: 6px;
}

.gallery-strip::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.gallery-strip::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* Gallery Thumb (Re-used architecture) */
.gallery-thumb {
    width: 60px;
    height: 80px;
    margin-top: 10px; /* Spazio fisico riservato per l'hover verso l'alto */
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    background: #0f172a;
    flex-shrink: 0; /* CRITICAL: Prevents them from turning into "sottilette" */
}

.gallery-thumb:hover,
.gallery-thumb.active {
    border-color: var(--accent-pink);
    transform: translateY(-6px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.gallery-thumb img,
.gallery-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-overlay-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 0.70rem;
    pointer-events: none; /* Crucial so clicks pass to the thumb */
    padding-left: 2px; /* Visual center adjustment for play triangle */
}

.gallery-thumb img {
    transition: opacity 0.3s ease;
}

.gallery-thumb:hover img {
    opacity: 0.8;
}

.gallery-thumb.more-photos .more-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    pointer-events: none;
    /* Let clicks pass to the parent */
}

/* Profile Body */
.profile-body {
    max-width: 1100px;
    margin: -100px auto 0;
    /* Overlap the hero securely */
    width: 100%;
    padding: 0 24px 60px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header Card */
.profile-header-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.profile-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap; /* Ensures badge floats alongside text safely */
}

/* Structural Row safely embedding the Title and the Standalone Fav Button */
.profile-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.profile-title-row .profile-name {
    margin: 0;
    padding-bottom: 0;
    border-bottom: none;
    flex: 1; /* Inherit available flow width so wrapping handles safely */
}

.profile-title-row .profile-fav-standalone {
    flex-shrink: 0; /* Anti-crush mechanism: button stays true to its 40x40 circle size */
    position: relative; /* CRITICAL FIX: overrides generic 'absolute' positioning */
    top: auto;
    right: auto;
    margin-top: 4px; /* Aligns correctly with the first line of the title */
}

.verified-badge {
    color: #10b981;
    /* Emerald green */
    font-size: 1.2rem;
}

.profile-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.profile-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.phone-action-wrapper {
    grid-column: 1 / -1; /* Always stretch across all columns if grid fits 2 items */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.phone-action-wrapper .btn-contact {
    width: 100%;
}

.visible-phone-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-pink);
    letter-spacing: 0.5px;
    text-align: center;
}

.btn-contact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    color: white;
    transition: all 0.3s ease;
}

.btn-contact.whatsapp {
    background: #25D366;
    color: #fff;
}

.btn-contact.whatsapp:hover {
    background: #1ebc5a;
    transform: translateY(-2px);
}

.btn-contact.phone {
    background: var(--accent-pink);
    color: white;
}

.btn-contact.phone:hover {
    background: #d81878;
    transform: translateY(-2px);
}

.btn-contact.telegram {
    background: #0088cc;
    color: white;
}

.btn-contact.telegram:hover {
    background: #0077b3;
    transform: translateY(-2px);
}

/* Two Column Layout */
.profile-layout-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
    padding-bottom: 28px;
}

.profile-main-col,
.profile-side-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0; /* CRITICAL FIX: prevents wide flex children from blowing out the grid boundaries */
}

.panel {
    background: #1e293b;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.panel h3 {
    color: white;
    font-size: 1.2rem;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel p {
    color: var(--text-main);
    line-height: 1.7;
    margin-bottom: 16px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.panel p:last-child {
    margin-bottom: 0;
}

.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.cat-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

.stats-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stats-list span {
    color: var(--text-muted);
}

.stats-list strong {
    color: white;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 65%;
}

.services-toggle-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.services-toggle-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--text-main);
}

.services-toggle-list li i {
    color: var(--accent-pink);
    font-size: 0.85rem;
}

.pricing-list strong {
    color: var(--accent-pink);
    font-weight: 600;
}

.small-map {
    width: 100%;
    height: 250px;
    border-radius: 12px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1;
    /* Keep map beneath modals */
}

/* Profile Mobile Adjustments */
@media (max-width: 1024px) {
    .profile-layout-grid {
        grid-template-columns: 1fr;
    }

    /* Flatten columns to allow direct reordering of child panels */
    .profile-main-col,
    .profile-side-col {
        display: contents;
    }

    /* Restore tracking bounds to the newly flattened grid items */
    .profile-layout-grid .panel {
        min-width: 0;
    }

    /* Reorder for mobile UX: Actions -> Claim -> Desc -> Disclaimer -> Stats -> Services -> Pricing -> Map */
    .profile-actions-card { order: 1; }
    .mobile-only-claim { order: 2; }
    .profile-desc { order: 3; }
    .profile-disclaimer { order: 4; }
    .profile-stats { order: 5; }
    .profile-services { order: 6; }
    .profile-pricing { order: 7; }
    .profile-map { order: 8; }

    .profile-actions {
        grid-template-columns: 1fr 1fr;
    }
}

/* Accordion Desktop Behavior (Open, no toggle, no icons) */
.accordion-icon {
    display: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.m-accordion-content {
    display: block;
}

.m-accordion-header {
    cursor: default;
}

/* Fallback Fullscreen per iOS Safari ed Errori API */
.mami-css-fullscreen {
    position: fixed !important;
    top: 66px !important; /* Spazio ESATTO per lasciare fuori l'header principale */
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 66px) !important;
    z-index: 50 !important; /* Deve essere maggiore della barra secondaria (14-20) ma minore del menu laterale (100) */
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    max-width: none !important;
}

/* Base style for Map Controls (Hidden on Desktop) */
.mami-adv-map-actions {
    display: none;
}

@media (max-width: 1024px) {
    .gallery-main-view {
        height: 400px;
    }

    .gallery-strip {
        gap: 8px;
    }

    .gallery-thumb {
        width: 50px;
        height: 65px;
        flex-shrink: 0;
    }

    .profile-name {
        font-size: 1.6rem;
    }

    .profile-actions {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 20px;
    }

    /* MAMI MOBILE LAYOUT: Blocco media tocca i bordi, no arrotondamenti */
    .profile-gallery.panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Annulla i padding sul fondo della pagina per evitare il "piede azzurro" */
    .profile-body {
        padding-bottom: 0 !important;
    }
    
    .profile-layout-grid {
        padding-bottom: 0 !important;
    }

    /* Mappa tocca i bordi laterali, e il suo rosso scuro riempie fino in fondo */
    .profile-map.panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding-left: 0;
        padding-right: 0;
        padding-bottom: 40px; /* Crea lo "zoccoletto" solido finale come a disegno */
        margin-bottom: 0;
    }

    .profile-map.panel h3 {
        padding-left: 20px;
        padding-right: 20px;
    }

    .profile-map .small-map {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
        width: 100%;
        height: 250px; 
    }

    /* Accordion Mobile Behaviors */
    .mobile-accordion .m-accordion-header {
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-accordion .accordion-icon {
        display: block;
        color: var(--accent-pink);
        font-size: 1.1rem;
    }

    .mobile-accordion.closed-on-mobile .m-accordion-header {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
        transition: all 0.2s ease;
    }

    .mobile-accordion.closed-on-mobile .m-accordion-content {
        display: none;
    }

    .mobile-accordion.open-on-mobile .m-accordion-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 12px;
        margin-bottom: 16px;
        transition: all 0.2s ease;
    }

    .mobile-accordion.open-on-mobile .accordion-icon {
        transform: rotate(180deg);
    }

    .mobile-accordion.open-on-mobile .m-accordion-content {
        display: block;
        animation: accordionFadeIn 0.3s ease-out forwards;
    }

    @keyframes accordionFadeIn {
        0% { opacity: 0; transform: translateY(-8px); }
        100% { opacity: 1; transform: translateY(0); }
    }

    /* Stile Controlli Mappa Mobile */
    .mami-adv-map-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        position: absolute !important;
        bottom: 16px !important; /* In modalità ridotta si appoggiano comodamente in basso */
        right: 16px !important;
        top: auto !important;
        z-index: 1000 !important;
    }

    /* Sollevamento estremo *SOLO* in modalità Fullscreen per bypassare la Gesture Bar / Address Bar nativa dei cellulari */
    .mami-css-fullscreen .mami-adv-map-actions,
    :fullscreen .mami-adv-map-actions,
    :-webkit-full-screen .mami-adv-map-actions,
    :-moz-full-screen .mami-adv-map-actions,
    :-ms-fullscreen .mami-adv-map-actions {
        bottom: 85px !important;
    }

    .mami-adv-map-actions button {
        width: 46px;
        height: 46px;
        border-radius: 50%;
        background: rgba(15, 23, 42, 0.85); /* Dark background matching theme */
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: white;
        font-size: 1.2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .mami-adv-map-actions button:active {
        background: var(--accent-pink);
        transform: scale(0.9);
        border-color: var(--accent-pink);
    }

    /* Tutti gli altri riquadri hanno margine laterale per distaccarsi dai bordi dello schermo */
    .profile-layout-grid .panel:not(.profile-gallery):not(.profile-map) {
        margin-left: 16px;
        margin-right: 16px;
    }
}

/* Modale Condivisione */
.mami-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 15, 26, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mami-modal.active {
    display: flex;
    opacity: 1;
}

.mami-modal-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

.mami-modal.active .mami-modal-content {
    transform: scale(1);
}

.mami-modal-close {
    color: #94a3b8;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.mami-modal-close:hover {
    color: white;
}

.mami-modal-content h3 {
    margin-top: 0;
    color: white;
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.mami-modal-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.share-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Mobile Only Claim Link */
.mobile-only-claim {
    display: none;
    text-align: center;
    margin: 10px 0 20px 0;
}
.claim-ad-link-mobile {
    color: var(--text-muted);
    font-size: 1.05rem;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}
.claim-ad-link-mobile strong {
    color: var(--accent-pink);
    font-weight: 600;
}
.claim-ad-link-mobile:hover {
    color: white;
}
.claim-ad-link-mobile:hover strong {
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .mobile-only-claim {
        display: block;
    }
}
