/* ==========================================================================
   Social Share & Action Toolbar Component
   ========================================================================== */

.share-toolbar-wrapper {
    margin: 2.25rem 0 1.25rem 0;
}

.share-toolbar-heading {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
    padding-left: 0.35rem;
}

.share-toolbar-title {
    font-size: 0.785rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bs-secondary-color, #6c757d);
    user-select: none;
    display: inline-flex;
    align-items: center;
}

.share-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.08));
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.share-toolbar-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
}

/* Social Media Buttons (Circular, Brand Colors on Light/White Base) */
.social-share-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--bs-border-color, #dee2e6);
    background-color: var(--bs-body-bg, #ffffff);
    text-decoration: none;
    cursor: pointer;
    font-size: 0.98rem;
    padding: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.2s ease,
                color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

.social-share-btn:hover {
    transform: translateY(-2px);
    color: #ffffff !important;
    border-color: transparent !important;
}

.social-share-btn:active {
    transform: translateY(0);
}

.social-share-btn:focus-visible,
.tool-action-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Native Share */
.btn-native-share { display: none; color: #0d6efd; border-color: rgba(13, 110, 253, 0.2); }
.btn-native-share.is-visible { display: inline-flex; }
.btn-native-share:hover { background-color: #0d6efd; color: #ffffff !important; }

/* Social Icons Base Colors & Hover Fills */
.btn-facebook { color: #1877f2; border-color: rgba(24, 119, 242, 0.25); }
.btn-facebook:hover { background-color: #1877f2; box-shadow: 0 4px 12px rgba(24, 119, 242, 0.35); }

.btn-twitter { color: #000000; border-color: rgba(0, 0, 0, 0.2); }
.btn-twitter:hover { background-color: #000000; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }

.btn-instagram { color: #e4405f; border-color: rgba(228, 64, 95, 0.28); }
.btn-instagram:hover {
    background-color: #d6249f;
    background-image: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
    box-shadow: 0 4px 12px rgba(214, 36, 159, 0.35);
}

.btn-whatsapp { color: #25d366; border-color: rgba(37, 211, 102, 0.3); }
.btn-whatsapp:hover { background-color: #25d366; box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35); }

.btn-tiktok { color: #000000; border-color: rgba(0, 0, 0, 0.2); }
.btn-tiktok:hover { background-color: #000000; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }

.btn-linkedin { color: #0a66c2; border-color: rgba(10, 102, 194, 0.25); }
.btn-linkedin:hover { background-color: #0a66c2; box-shadow: 0 4px 12px rgba(10, 102, 194, 0.35); }

.btn-email { color: #ea4335; border-color: rgba(234, 67, 53, 0.3); }
.btn-email:hover { background-color: #ea4335; box-shadow: 0 4px 12px rgba(234, 67, 53, 0.35); }

.btn-copy { color: #495057; border-color: rgba(73, 80, 87, 0.25); }
.btn-copy:hover { background-color: #495057; box-shadow: 0 4px 12px rgba(73, 80, 87, 0.3); }

.social-share-btn.is-copied {
    background-color: #198754 !important;
    background-image: none !important;
    border-color: #198754 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.35);
}

/* Right Action Tools (Rounded Square, Distinct Shape and Role) */
.tool-action-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    background-color: var(--bs-body-bg, #ffffff);
    text-decoration: none;
    cursor: pointer;
    font-size: 0.98rem;
    padding: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.2s ease,
                color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

.tool-action-btn:hover {
    transform: translateY(-2px);
    color: #ffffff !important;
    border-color: transparent !important;
}

.tool-action-btn:active {
    transform: translateY(0);
}

.btn-tool-html { color: #0d6efd; border-color: rgba(13, 110, 253, 0.25); }
.btn-tool-html:hover { background-color: #0d6efd; box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35); }

.btn-tool-text { color: #198754; border-color: rgba(25, 135, 84, 0.25); }
.btn-tool-text:hover { background-color: #198754; box-shadow: 0 4px 12px rgba(25, 135, 84, 0.35); }

.btn-tool-zip { color: #fd7e14; border-color: rgba(253, 126, 20, 0.25); }
.btn-tool-zip:hover { background-color: #fd7e14; box-shadow: 0 4px 12px rgba(253, 126, 20, 0.35); }

.btn-tool-print { color: #495057; border-color: rgba(73, 80, 87, 0.25); }
.btn-tool-print:hover { background-color: #495057; box-shadow: 0 4px 12px rgba(73, 80, 87, 0.35); }

/* Dark Theme Support */
[data-bs-theme="dark"] .share-toolbar {
    background-color: var(--bs-dark-bg-subtle, #1a1e24);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .social-share-btn,
[data-bs-theme="dark"] .tool-action-btn {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .btn-twitter { color: #e9ecef; border-color: rgba(255, 255, 255, 0.2); }
[data-bs-theme="dark"] .btn-instagram,
.theme-dark .btn-instagram { color: #f05275; border-color: rgba(240, 82, 117, 0.3); }
[data-bs-theme="dark"] .btn-tiktok { color: #e9ecef; border-color: rgba(255, 255, 255, 0.2); }
[data-bs-theme="dark"] .btn-copy { color: #ced4da; }
[data-bs-theme="dark"] .btn-tool-print { color: #ced4da; }

/* RTL Support */
[dir="rtl"] .share-toolbar-heading {
    padding-left: 0;
    padding-right: 0.35rem;
}

/* Mobile Responsiveness */
@media (max-width: 767.98px) {
    .share-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        padding: 1rem 0.85rem;
    }

    .share-toolbar-section {
        justify-content: center;
    }

    .social-share-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1.05rem;
    }

    .tool-action-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1.05rem;
        border-radius: 10px;
    }
}

/* ==========================================================================
   Share Popover Floating Icon Tray
   ========================================================================== */

.social-share {
    position: relative;
    z-index: 30;
}

.detail-share-inline {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.share-popover-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.share-trigger-btn {
    color: var(--bs-body-color, #212529);
}

.news-byline-tools .share-trigger-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 50%;
    font-size: 0.9rem;
    color: #0f172a;
    background-color: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.news-byline-tools .share-trigger-btn:hover,
.news-byline-tools .share-trigger-btn[aria-expanded="true"] {
    transform: none;
    background-color: #0f172a;
    border-color: #0f172a !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}

.share-trigger-btn:hover,
.share-trigger-btn[aria-expanded="true"] {
    background-color: var(--detail-accent, #0f766e);
    color: var(--detail-on-accent, #ffffff) !important;
    border-color: var(--detail-accent, #0f766e) !important;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.share-popover-menu {
    position: absolute;
    top: calc(100% + 0.65rem);
    left: 0;
    right: auto;
    z-index: 1060;
    padding: 0.4rem;
    background-color: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(15, 23, 42, 0.09);
    border-radius: 0.875rem;
    box-shadow: 0 18px 38px -8px rgba(15, 23, 42, 0.16),
                0 4px 12px -2px rgba(15, 23, 42, 0.06);
    width: max-content;
    max-width: calc(100vw - 2.5rem);
}

.share-popover-menu[hidden] {
    display: none !important;
}

.share-popover-icons {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    animation: sharePopoverIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.share-popover-icons .social-share-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 0.625rem;
    background-color: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.06);
    font-size: 0.95rem;
}

.share-popover-icons .btn-facebook:hover { background-color: #1877f2; }
.share-popover-icons .btn-twitter:hover { background-color: #000000; }
.share-popover-icons .btn-instagram:hover {
    background-color: #d6249f;
    background-image: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
}
.share-popover-icons .btn-whatsapp:hover { background-color: #25d366; }
.share-popover-icons .btn-tiktok:hover { background-color: #000000; }
.share-popover-icons .btn-linkedin:hover { background-color: #0a66c2; }
.share-popover-icons .btn-email:hover { background-color: #ea4335; }
.share-popover-icons .btn-copy:hover { background-color: #334155; }

@keyframes sharePopoverIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.share-container.justify-content-start,
.share-container.justify-content-center {
    display: flex;
    width: 100%;
}

.share-container.justify-content-center .share-popover-menu {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

@media (min-width: 768px) {
    .detail-tools .share-popover-menu {
        left: auto;
        right: -0.25rem;
    }

    .detail-tools .share-popover-menu::before {
        content: "";
        position: absolute;
        top: -5px;
        right: 15px;
        width: 9px;
        height: 9px;
        background-color: #ffffff;
        border-top: 1px solid rgba(15, 23, 42, 0.09);
        border-left: 1px solid rgba(15, 23, 42, 0.09);
        transform: rotate(45deg);
    }
}

@media (max-width: 767.98px) {
    .share-popover-icons {
        flex-wrap: wrap;
        justify-content: center;
    }

    .share-container.justify-content-start .share-popover-menu,
    .share-container.justify-content-center .share-popover-menu {
        max-width: min(calc(100vw - 2.5rem), 100%);
    }

    .detail-tools {
        position: relative;
        z-index: 30;
    }

    .news-byline-tools .share-trigger-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }

    .share-popover-icons .social-share-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }

    .detail-tools .share-popover-wrapper {
        position: static;
    }

    .detail-tools .share-popover-menu {
        left: 0;
        right: auto;
        max-width: min(calc(100vw - 3rem), 100%);
        border-radius: 0.875rem;
    }
}

@media (max-width: 420px) {
    .share-popover-icons .social-share-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }
}

[data-bs-theme="dark"] .share-popover-menu,
.theme-dark .share-popover-menu {
    background-color: rgba(26, 30, 36, 0.96);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 18px 38px -8px rgba(0, 0, 0, 0.55);
}

@media (min-width: 768px) {
    [data-bs-theme="dark"] .detail-tools .share-popover-menu::before,
    .theme-dark .detail-tools .share-popover-menu::before {
        background-color: #1a1e24;
        border-top-color: rgba(255, 255, 255, 0.14);
        border-left-color: rgba(255, 255, 255, 0.14);
    }
}

[data-bs-theme="dark"] .share-popover-icons .social-share-btn,
.theme-dark .share-popover-icons .social-share-btn {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.09);
}

[data-bs-theme="dark"] .news-byline-tools .share-trigger-btn,
.theme-dark .news-byline-tools .share-trigger-btn {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: #f8fafc;
}

[data-bs-theme="dark"] .news-byline-tools .share-trigger-btn:hover,
[data-bs-theme="dark"] .news-byline-tools .share-trigger-btn[aria-expanded="true"],
.theme-dark .news-byline-tools .share-trigger-btn:hover,
.theme-dark .news-byline-tools .share-trigger-btn[aria-expanded="true"] {
    background-color: #38bdf8;
    border-color: #38bdf8 !important;
    color: #0f172a !important;
}

[dir="rtl"] .share-popover-menu {
    left: auto;
    right: 0;
}

@media (min-width: 768px) {
    [dir="rtl"] .detail-tools .share-popover-menu {
        left: -0.25rem;
        right: auto;
    }

    [dir="rtl"] .detail-tools .share-popover-menu::before {
        left: 15px;
        right: auto;
    }
}
