/* ============================================
   Share Modal
   ============================================ */

/* --- Trigger Button --- */
.share-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 0.5px solid rgba(255, 255, 255, 0.5);
    /* Every property the hover rule can change is listed, so the button eases into its
       hover state instead of snapping colour/shadow/border while the background fades.
       Keep this in step with .pls-btn in pages/user_page.php — the language switcher
       clones this button and the two must feel identical. border-width is deliberately
       left out: animating it would shift layout. */
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease,
                border-color 0.3s ease;
}

.share-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.share-button i {
    font-size: 17px;
}

/* --- Overlay --- */
#sharePopup {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    visibility: hidden;
    pointer-events: none;
    transition: background 0.35s ease, visibility 0s linear 0.4s;
}

#sharePopup.active {
    visibility: visible;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.35s ease, visibility 0s linear 0s;
}

/* --- Content Panel (mobile-first: bottom sheet) --- */
.share-popup-content {
    text-shadow: none;
    background: #fff;
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 18px 18px 0 0;
    padding: 10px 22px 30px;
    text-align: center;
    position: relative;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
}

#sharePopup.active .share-popup-content {
    transform: translateY(0);
}

/* Desktop / Tablet: centered card */
@media (min-width: 768px) {
    #sharePopup {
        align-items: center;
    }

    .share-popup-content {
        max-width: 420px;
        max-height: 88vh;
        border-radius: 18px;
        padding: 24px 28px 28px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
        transform: translateY(30px);
        opacity: 0;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.28s ease;
    }

    #sharePopup.active .share-popup-content {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Drag Handle (mobile only) --- */
.share-drag-handle {
    width: 36px;
    height: 4px;
    background: #ddd;
    border-radius: 100px;
    margin: 2px auto 14px;
}

@media (min-width: 768px) {
    .share-drag-handle {
        display: none;
    }
}

/* --- Close Button --- */
.close-popup {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f2f2f2;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    font-size: 1.4rem;
    font-weight: 300;
    line-height: 1;
    transition: background 0.2s ease;
    z-index: 2;
}

.close-popup:hover {
    background: #e6e6e6;
}

.close-popup:active {
    background: #ddd;
}

/* --- Profile Picture --- */
.share-modal-profile-pic {
    border-radius: 50% !important;
    width: 150px !important;
    height: 150px !important;
    max-width: 150px !important;
    object-fit: cover !important;
    display: block !important;
    margin: 10px auto 12px auto !important;
    border: 3px solid #fff !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

/* --- Page Title --- */
.share-page-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 2px;
    color: #1a1a1a;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    line-height: 1.5;
}

/* --- Divider --- */
.styled-hr {
    border: none;
    height: 1px;
    background: #f0f0f0;
    margin: 14px 0;
    width: 100%;
}

/* ============================================
   Social Icons Carousel
   ============================================ */

.social-slider-container {
    position: relative;
    overflow: hidden;
    margin: 6px 0;
    padding: 0 24px;
}

.social-slider {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 6px 0;
    gap: 0;
}

.social-slider::-webkit-scrollbar {
    display: none;
}

.social-slider .share-icon {
    flex: 0 0 25%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #555;
    padding: 10px 4px 8px;
    border-radius: 12px;
    transition: background 0.18s ease;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    -webkit-tap-highlight-color: transparent;
}

.social-slider .share-icon:hover {
    background: #fafafa;
}

.social-slider .share-icon:active {
    background: #f5f5f5;
}

.social-slider .share-icon i {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #444;
    margin-bottom: 6px;
    transition: background 0.18s ease;
}

.social-slider .share-icon:hover i {
    background: #efefef;
}

.social-slider .share-icon span {
    display: block;
    font-size: 10.5px;
    color: #888;
    line-height: 1.2;
    white-space: nowrap;
}

/* Slider Controls */
.slider-controls {
    display: flex;
    justify-content: space-between;
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    pointer-events: none;
    direction: ltr;
}

.slider-prev,
.slider-next {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #eee;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    pointer-events: auto;
    z-index: 10;
    transition: opacity 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    color: #888;
    font-size: 10px;
    transform: scaleX(-1);
    opacity: 1;
}

.slider-btn-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide slider buttons when modal is not active — prevents flash on close */
#sharePopup:not(.active) .slider-prev,
#sharePopup:not(.active) .slider-next {
    opacity: 0 !important;
    pointer-events: none !important;
}

.slider-prev:hover,
.slider-next:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: #555;
}

.slider-prev {
    left: 2px;
    right: auto;
    margin-right: auto;
    margin-left: 2px;
}

.slider-next {
    right: 2px;
    left: auto;
    margin-left: auto;
    margin-right: 2px;
}

/* RTL arrow corrections */
.slider-prev .fas.fa-chevron-left:before {
    content: "\f054";
}

.slider-next .fas.fa-chevron-right:before {
    content: "\f053";
}

@media (min-width: 768px) {
    .social-slider .share-icon i {
        width: 48px;
        height: 48px;
        font-size: 21px;
    }

    .social-slider .share-icon span {
        font-size: 11px;
    }
}

/* ============================================
   Invite Section
   ============================================ */

.share-invite-text {
    padding: 8px 0 2px;
    color: #444;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    font-size: 13.5px;
    line-height: 1.7;
    margin: 0;
    text-align: center;
}

.shortcut-form {
    display: block;
    width: 100%;
    text-align: center;
    margin: 8px auto 4px;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.btn-submit {
    background: #f5f5f5;
    color: #1a1a1a;
    border: none;
    padding: 9px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 700;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    transition: background 0.2s ease, color 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-submit:hover {
    background: #e8e8e8;
    color: #1a1a1a;
}

.button-container .btn-submit {
    flex: 1;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .button-container .btn-submit {
        padding: 9px 20px;
        font-size: 12.5px;
    }
}

/* ============================================
   Report & Privacy
   ============================================ */

.report-privacy-links {
    margin: 10px 0 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11.5px;
    color: #bbb;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
}

.report-link,
.privacy-link {
    text-decoration: none;
    color: #bbb;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.2s ease;
}

.report-link i,
.privacy-link i {
    margin-left: 4px;
    font-size: 11px;
}

.report-link:hover,
.privacy-link:hover {
    text-decoration: none !important;
    color: #666 !important;
}

.divider-pipe {
    margin: 0 6px;
    color: #bbb;
}

@media (min-width: 768px) {
    .divider-pipe {
        margin: 0 20px;
    }
}

/* ============================================
   Skeleton loader (shown briefly on modal open)
   ============================================ */

.share-skeleton { display: none; padding: 6px 0 4px; }

/* While loading: show the skeleton, hide the real content (keep the handle +
   close button so the sheet still looks/feels right and is dismissable). */
.share-popup-content.is-loading .share-skeleton { display: block; }
.share-popup-content.is-loading > *:not(.share-skeleton):not(.close-popup):not(.share-drag-handle) {
    display: none !important;
}

.share-skeleton .sk {
    background: #ececec;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}
.share-skeleton .sk::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
    animation: shareSkelShimmer 1.2s infinite;
}
@keyframes shareSkelShimmer { 100% { transform: translateX(100%); } }

.share-skeleton .sk-avatar { width: 150px; height: 150px; border-radius: 50%; margin: 10px auto 16px; }
.share-skeleton .sk-title  { width: 58%; height: 16px; margin: 0 auto 20px; border-radius: 6px; }
.share-skeleton .sk-row    { display: flex; justify-content: center; gap: 18px; margin-bottom: 20px; }
.share-skeleton .sk-icon   { width: 46px; height: 46px; border-radius: 50%; }
.share-skeleton .sk-line   { height: 1px; background: #ececec; margin: 4px 0 18px; }
.share-skeleton .sk-block  { width: 100%; height: 54px; border-radius: 14px; margin-bottom: 18px; }
.share-skeleton .sk-btns   { display: flex; gap: 10px; }
.share-skeleton .sk-btn    { flex: 1; height: 38px; border-radius: 50px; }

/* Save as contact (vCard) section: glyph + two text lines + a pill button. */
.share-skeleton .sk-contact      { align-items: center; gap: 12px; margin-bottom: 18px; }
.share-skeleton .sk-contact-glyph{ width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.share-skeleton .sk-contact-text { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.share-skeleton .sk-contact-line-1 { width: 45%; height: 12px; border-radius: 6px; }
.share-skeleton .sk-contact-line-2 { width: 72%; height: 10px; border-radius: 6px; }
.share-skeleton .sk-contact-btn  { width: 64px; height: 34px; border-radius: 50px; flex-shrink: 0; }

/* The contact (vCard) shape + its divider mirror the real .share-contact-section:
   phone only. Hidden on desktop, revealed on coarse-pointer / no-hover devices. */
.share-skeleton .sk-contact,
.share-skeleton .sk-line-contact { display: none; }
@media (hover: none) and (pointer: coarse) {
    .share-skeleton .sk-contact      { display: flex; }
    .share-skeleton .sk-line-contact { display: block; }
}

/* Report & privacy: two short centered pills. */
.share-skeleton .sk-report       { display: flex; justify-content: center; gap: 16px; margin: 16px 0 18px; }
.share-skeleton .sk-report-item  { width: 96px; height: 12px; border-radius: 6px; }

/* Powered-by logo + caption. */
.share-skeleton .sk-logo         { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 4px; }
.share-skeleton .sk-logo-img     { width: 120px; height: 28px; border-radius: 6px; }
.share-skeleton .sk-logo-text    { width: 88px; height: 10px; border-radius: 6px; }

/* ============================================
   PWA Install Section ("تثبيت التطبيق")
   ============================================ */

.pwa-install-section {
    /* display toggled to flex by JS once the page is installable */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 10px 12px;
    margin: 6px 0 2px;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
}

.pwa-install-text {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pwa-install-glyph {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #f0f0f0;
    color: #444;
    /* line-height = box height + vertical-align:middle on the glyph is the most
       reliable way to centre an icon-font character (flex centring leaves the
       FontAwesome glyph riding high because of its font metrics). */
    display: inline-block;
    text-align: center;
    line-height: 38px;
    font-size: 17px;
}

.pwa-install-glyph::before {
    vertical-align: middle;
    position: relative;
    top: 9px; /* optical nudge — the phone glyph reads slightly high otherwise */
}

.pwa-install-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: right;
    min-width: 0;
}

.pwa-install-copy strong {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.pwa-install-copy span {
    font-size: 11px;
    color: #888;
    line-height: 1.3;
}

.pwa-install-btn {
    flex: 0 0 auto;
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 700;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.1s ease;
}

.pwa-install-btn i {
    margin-left: 5px;
    font-size: 11px;
}

.pwa-install-btn:hover {
    background: #000;
}

.pwa-install-btn:active {
    transform: scale(0.97);
}

/* "Save as contact" is a phone action — show only on touch devices. Hidden by
   default (desktop); revealed on coarse-pointer / no-hover devices. The compound
   selector beats .pwa-install-section's display:flex on specificity. */
.pwa-install-section.share-contact-section { display: none; }
.styled-hr.share-mobile-only-hr { display: none; }

@media (hover: none) and (pointer: coarse) {
    .pwa-install-section.share-contact-section { display: flex; }
    .styled-hr.share-mobile-only-hr { display: block; }
}

/* ============================================
   Powered by Footer
   ============================================ */

.powered-by-linkin1 {
    margin-top: 12px;
    text-align: center;
    padding-bottom: 4px;
}

.linkin1-logo {
    max-width: 90px;
    height: auto;
    display: block;
    margin: 0 auto 2px auto;
    opacity: 0.45;
    transition: opacity 0.2s ease;
}

.linkin1-logo:hover {
    opacity: 1;
}

.powered-by-text {
    font-size: 10.5px;
    color: #ccc;
    margin: 0;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
}

/* ============================================
   Utilities
   ============================================ */

/* Lock body scroll when modal is open */
body.share-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Copy toast */
.share-copy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 13px;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
}

.share-copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- QR block inside the share popup (collapsed by default) ----------------
   Native <details>, deliberately: the public page has no Bootstrap, so a JS
   accordion would mean shipping one just for this. Shows the owner's saved QR
   Studio design when they picked one (a <canvas> filled by qr-render.js),
   otherwise the plain tracker QR (inline <svg>). */
.share-qr-details {
    width: 100%;
    text-align: center;
}

.share-qr-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    font-size: 14px;
    font-weight: 600;
    color: #333;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    cursor: pointer;
    list-style: none;
    transition: background 0.2s ease;
}

/* Hide the default disclosure triangle in both engines. */
.share-qr-summary::-webkit-details-marker { display: none; }
.share-qr-summary::marker { content: ''; }

.share-qr-summary:hover { background: #f7f7f8; }

/* Chevron drawn from the Font Awesome glyph the page already loads. */
.share-qr-summary::after {
    content: '\f078';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 11px;
    color: #888;
    transition: transform 0.2s ease;
}

.share-qr-details[open] .share-qr-summary::after { transform: rotate(180deg); }

.share-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-top: 14px;
}

.share-qr-frame {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    line-height: 0;
}

.share-qr-frame svg {
    width: 218px;
    height: 218px;
    display: block;
}

/* Plain (unstyled) QR gets the owner's profile picture in the centre, matching
   the desktop corner QR (.qr-profile-overlay in styles/qr-code.css). A styled
   design does NOT get this — it already carries its own logo. 28% is the same
   ratio the corner uses: small enough that ECC-H error correction can still
   recover the modules it covers, so the code stays scannable. */
.share-qr-plain {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.share-qr-profile {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28%;
    height: 28%;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #fff;
    object-fit: cover;
    pointer-events: none;
}

/* drawToCanvas() sets an INLINE width and height:auto, which beats these rules;
   height stays auto here too so the code keeps its ratio and stays scannable. */
.share-qr-frame canvas {
    width: 218px;
    height: auto;
    display: block;
}

/* PNG + SVG side by side; wraps to one per line on very narrow phones. */
.share-qr-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.share-qr-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-family: var(--app-font, 'Cairo', 'Segoe UI', system-ui, sans-serif);
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: #222;
    border: 1px solid #222;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.share-qr-download i {
    font-size: 11px;
}

.share-qr-download:hover {
    background: #000;
    border-color: #000;
}

/* SVG is the secondary choice — same shape, outlined so PNG stays the default. */
.share-qr-download-svg {
    color: #222;
    background: transparent;
    border-color: rgba(0, 0, 0, 0.18);
}

.share-qr-download-svg:hover {
    color: #222;
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
}
