/* ========================================
   SocialHub - UI Models & Modals
   Centralized styling for all system modals
   ======================================== */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    overflow-y: auto;
}

.modal.show {
    display: flex !important;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--glass-shadow);
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Global UI Modal Transitions & Specifics */
#global-ui-modal {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#global-ui-modal.show {
    opacity: 1;
}

#global-ui-modal .modal-content {
    max-width: 450px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

#global-ui-modal.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.modal-close {
    cursor: pointer;
    font-size: 24px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--white);
}

/* Ad Controls Mobile Popup (Full Page Style) */
.ad-options-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ad-options-content {
    background: var(--bg-card);
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 32px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: none;
}

@media (max-width: 768px) {
    .ad-options-overlay {
        /* Center-ish (not bottom-sheet) so it won't clip under top/bottom menus */
        align-items: center;
        padding: 10px;
    }
    .ad-options-content {
        max-width: 100%;
        border-radius: 22px;
        padding: 18px;
        /* Ensure the popup fits between header/footer on mobile */
        max-height: calc(100vh - 72px);
        overflow-y: auto;
        margin-top: 8px;
        margin-bottom: 8px;
        animation: adPopupSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@keyframes adPopupSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.ad-opt-btn {
    width: 100%;
    padding: 18px 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
}

.ad-opt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-cyan);
    transform: translateX(5px);
}

/* --------------------------------------------
   One-off “New Ad Campaign” modal UX fixes
   (from tradespeople/management/ads.php)
--------------------------------------------- */
#createAdModal {
    z-index: 99999;
}

#createAdModal .modal-content,
#editAdModal .modal-content,
#transferCreditsModal .modal-content,
#withdrawCreditsModal .modal-content,
#insightsModal .modal-content {
    max-width: 720px;
}

/* Add a consistent close button slot if the HTML provides .modal-close */
#createAdModal .modal-close,
#editAdModal .modal-close {
    position: absolute;
    right: 14px;
    top: 10px;
    font-size: 26px;
}

@media (max-width: 768px) {
    /* Keep this centered between mobile header + bottom nav */
    #createAdModal.modal,
    #editAdModal.modal,
    #transferCreditsModal.modal,
    #withdrawCreditsModal.modal,
    #insightsModal.modal {
        align-items: center;
        padding: 10px;
    }

    #createAdModal .modal-content,
    #editAdModal .modal-content,
    #transferCreditsModal .modal-content,
    #withdrawCreditsModal .modal-content,
    #insightsModal .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 72px);
        overflow-y: auto;
        margin-top: 6px;
        margin-bottom: 6px;
        padding: 18px;
        border-radius: 22px;
    }
}

/* Ensure emoji picker appears above all modals and is centered */
#global-emoji-picker {
    z-index: 7500 !important;
    max-height: 80vh;
    max-width: 95vw;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8);
}
