/*
 * Share modal styles — extracted from frontend-dashboard.css so the
 * site-wide floating share button (which can open this modal on any
 * frontend page) doesn't depend on the dashboard CSS bundle.
 *
 * Loaded site-wide via class-frontend.php for every visitor. The
 * dashboard's frontend-dashboard.css still ships its own copy of
 * these rules — harmless duplication, overridden by source order.
 */

/* ----------------------------------------------------------------------
 * Generic modal overlay primitive — also used by other dashboard modals
 * (payout, profile, payment) but those are dashboard-only and load
 * the dashboard CSS. Defining the base primitive here means a non-
 * dashboard page can render #share-modal correctly without pulling
 * in the full dashboard bundle.
 * ---------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: dimiShareModalFadeIn 0.2s ease-out;
}

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

.modal-overlay .modal,
.modal-overlay .modal-content {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 550px;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    margin: auto;
}

body.dimi-modal-open,
html.dimi-modal-open {
    overflow: hidden !important;
    touch-action: none;
}

.modal-overlay .modal-header {
    padding: 1rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-overlay .modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* ----------------------------------------------------------------------
 * Share modal specifics (extracted verbatim from frontend-dashboard.css)
 * ---------------------------------------------------------------------- */
#share-modal .modal-content {
    max-width: 480px;
}

#share-modal .modal-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#share-modal .modal-header h4 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--di-text, #0F172A);
}

#share-modal .modal-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--di-text-muted, #475569);
    cursor: pointer;
    transition: background 150ms ease-out, color 150ms ease-out;
}
#share-modal .modal-close:hover {
    background: var(--di-surface-alt, #F1F5F9);
    color: var(--di-text, #0F172A);
}
#share-modal .modal-close svg,
#share-modal .modal-close .di-icon {
    width: 16px;
    height: 16px;
}

#share-modal .share-modal__lede {
    margin: 0 0 14px;
    font-size: 0.875rem;
    color: var(--di-text-muted, #475569);
}

#share-modal .share-modal__url-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 18px;
}
#share-modal .share-modal__url {
    flex: 1;
    min-width: 0;
    padding: 10px 12px !important;
    background: var(--di-surface-alt, #F8FAFC) !important;
    border: 1px solid var(--di-border, #E2E8F0) !important;
    border-radius: 8px !important;
    color: var(--di-text, #0F172A) !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
    font-size: 0.8125rem !important;
    line-height: 1.4;
}
#share-modal .share-modal__url:focus {
    outline: 0 !important;
    border-color: var(--di-primary, #2563EB) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--di-primary, #2563EB) 16%, transparent) !important;
}
#share-modal .share-modal__copy {
    flex-shrink: 0;
    padding: 10px 16px !important;
    background: var(--di-primary, #2563EB) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 8px !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    /* Neutralize the global .copy-btn min-height: 44px so the button
       sits flush with the smaller .share-modal__url input next to it
       — modal compact density. line-height keeps the text vertically
       centered without needing the 44px floor. */
    min-height: 0 !important;
    line-height: 1.2 !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: filter 150ms ease-out;
}
#share-modal .share-modal__copy:hover {
    filter: brightness(0.95);
}
#share-modal .share-modal__copy svg,
#share-modal .share-modal__copy .di-icon {
    width: 13px;
    height: 13px;
}

#share-modal .share-modal__channels-label {
    margin: 0 0 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--di-text-muted, #475569);
}
#share-modal .share-modal__channels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
}
#share-modal .share-channel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--di-surface, #FFFFFF);
    border: 1px solid var(--di-border, #E2E8F0);
    border-radius: 10px;
    color: var(--di-text, #0F172A);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 150ms ease-out, transform 100ms ease-out, box-shadow 150ms ease-out;
}
#share-modal .share-channel:hover {
    border-color: color-mix(in srgb, var(--di-primary, #2563EB) 35%, var(--di-border, #E2E8F0));
    box-shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}
#share-modal .share-channel:active {
    transform: translateY(0);
}
#share-modal .share-channel__icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #fff;
    flex-shrink: 0;
}
#share-modal .share-channel__icon svg,
#share-modal .share-channel__icon .di-icon {
    width: 16px;
    height: 16px;
}

#share-modal .share-channel__icon--facebook { background: #1877F2; }
#share-modal .share-channel__icon--x        { background: #0F172A; }
#share-modal .share-channel__icon--telegram { background: #229ED9; }
#share-modal .share-channel__icon--whatsapp { background: #25D366; }
#share-modal .share-channel__icon--email    { background: var(--di-text-muted, #475569); }

#share-modal .share-channel__name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--di-text, #0F172A);
}

@media (max-width: 480px) {
    #share-modal .share-modal__url-row {
        flex-direction: column;
    }
    #share-modal .share-modal__copy {
        justify-content: center;
    }
    #share-modal .share-modal__channels {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay {
        animation: none;
    }
    #share-modal .share-channel,
    #share-modal .modal-close,
    #share-modal .share-modal__copy {
        transition: none;
    }
    #share-modal .share-channel:hover {
        transform: none;
    }
}
