/**
 * ALLOut Video Manager — inline per-video "tools" bar (front-end).
 *
 * Small, theme-neutral action row shown under every rendered video for users
 * with the allout_vm_share_videos capability. Deliberately understated so it
 * sits comfortably inside archive cards, the single watch page and arbitrary
 * shortcode placements alike.
 *
 * @author    ALLOut Security
 * @copyright 2026 ALLOut Security
 * @license   Proprietary
 */

.allout-vm-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
}

/*
 * Stage: the positioned pairing of a video body and its tools bar, emitted by
 * the Renderer only for users who can share. The bar sits in normal flow BELOW
 * the video, aligned to its bottom-right. It used to overlay the video's
 * top-right corner (position:absolute), which laid the Share control on top of
 * the picture; moving it out from under the overlay keeps the video clean and the
 * control easy to find. Archive cards render the bar in normal flow inside the
 * card body (no stage) and were already outside the video, so they are unchanged.
 */
.allout-vm-stage {
    position: relative;
}

.allout-vm-stage > .allout-vm-tools {
    justify-content: flex-end;
    margin: 10px 0 0;
}

.allout-vm-tool {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: var(--avm-accent, #ef3b44);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    -webkit-appearance: none;
    appearance: none;
}

/* Neutral (never accent-tinted) lift so the control stays legible over any frame. */
.allout-vm-stage > .allout-vm-tools .allout-vm-tool {
    box-shadow: 0 2px 10px -2px rgba(16, 25, 43, .45);
}

.allout-vm-tool:hover,
.allout-vm-tool:focus-visible {
    background: var(--avm-accent-ink, #cf2630);
    border-color: transparent;
    color: #fff;
    outline: none;
}

.allout-vm-tool:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
}

.allout-vm-tool:disabled {
    opacity: .7;
    cursor: default;
}

.allout-vm-tool__icon {
    flex: 0 0 auto;
    display: block;
}

.allout-vm-tool.is-copied {
    color: #1e7e4e;
    border-color: #1e7e4e;
    background: #e7f6ee;
}

.allout-vm-tool.is-failed {
    color: #b32d2e;
    border-color: #d63638;
    background: #fcebec;
}

/* ============================================================
   Share popover toolkit — premium redesign
   ============================================================ */
.allout-vm-share {
    position: relative;
    display: inline-block;
    /* Overridden inline by Admin\Assets from the Settings → Player accent. */
    --avm-accent: #ef3b44;
    --avm-accent-ink: #cf2630;
    --avm-ink: #10192b;
    --avm-muted: #6b7688;
    --avm-line: #e7ebf3;
    --avm-tile: #f4f6fb;
    --avm-surface: #fff;
}

/* Give the trigger presence while its menu is open. */
.allout-vm-tool--share[aria-expanded="true"] {
    background: var(--avm-accent-ink);
    border-color: transparent;
    color: #fff;
}

.allout-vm-share-menu {
    position: absolute;
    z-index: 9999;
    top: calc(100% + 10px);
    left: 0;
    width: 320px;
    max-width: calc(100vw - 24px);
    padding: 6px;
    background: var(--avm-surface);
    border: 1px solid var(--avm-line);
    border-radius: 16px;
    box-shadow:
        0 1px 0 rgba(16, 25, 43, .02),
        0 12px 24px -8px rgba(16, 25, 43, .18),
        0 40px 64px -32px rgba(16, 25, 43, .28);
    transform-origin: top left;
    animation: allout-vm-share-in .16s cubic-bezier(.16, 1, .3, 1);
}

/*
 * Overlaid on the video the trigger hugs the right edge, so the menu opens
 * right-aligned (it would otherwise overflow the frame) with its caret under
 * the trigger.
 */
.allout-vm-stage .allout-vm-share-menu {
    left: auto;
    right: 0;
    transform-origin: top right;
}

/* Caret pointing back at the trigger. */
.allout-vm-share-menu::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 22px;
    width: 11px;
    height: 11px;
    background: var(--avm-surface);
    border-left: 1px solid var(--avm-line);
    border-top: 1px solid var(--avm-line);
    border-top-left-radius: 3px;
    transform: rotate(45deg);
}

.allout-vm-stage .allout-vm-share-menu::before {
    left: auto;
    right: 22px;
}

@keyframes allout-vm-share-in {
    from { opacity: 0; transform: translateY(-6px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.allout-vm-share-menu[hidden] { display: none; }

/* Header */
.allout-vm-share-head {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 12px 14px 10px;
    margin: -6px -6px 6px;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid var(--avm-line);
    background: var(--avm-surface);
}
.allout-vm-share-head__title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .01em;
    color: var(--avm-ink);
}
.allout-vm-share-head__hint {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--avm-muted);
}

/* Portal "anyone with the link (no login)" switch */
.allout-vm-share-access {
    padding: 8px 4px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--avm-line);
}
.allout-vm-share-access__switch {
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: start;
    gap: 10px;
    cursor: pointer;
}
.allout-vm-share-access__switch input {
    grid-column: 1;
    grid-row: 1;
    width: 34px;
    height: 20px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.allout-vm-share-access__track {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: var(--avm-line);
    transition: background .16s ease;
    pointer-events: none;
}
.allout-vm-share-access__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(16, 25, 43, .35);
    transition: transform .16s ease;
}
.allout-vm-share-access__switch input:checked ~ .allout-vm-share-access__track {
    background: var(--avm-accent);
}
.allout-vm-share-access__switch input:checked ~ .allout-vm-share-access__track::after {
    transform: translateX(14px);
}
.allout-vm-share-access__switch input:focus-visible ~ .allout-vm-share-access__track {
    outline: 2px solid var(--avm-accent-ink);
    outline-offset: 2px;
}
.allout-vm-share-access__switch input:disabled ~ .allout-vm-share-access__track {
    opacity: .55;
}
.allout-vm-share-access__text {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.allout-vm-share-access__label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--avm-ink);
}
.allout-vm-share-access__hint {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--avm-muted);
}
@media (prefers-reduced-motion: reduce) {
    .allout-vm-share-access__track,
    .allout-vm-share-access__track::after { transition: none; }
}

/* Options */
.allout-vm-share-opt {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 10px;
    font: inherit;
    text-align: left;
    color: var(--avm-ink);
    background: transparent;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    transition: background .14s ease, transform .14s ease;
}
.allout-vm-share-opt + .allout-vm-share-opt { margin-top: 1px; }

.allout-vm-share-opt__icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--avm-accent);
    background: var(--avm-tile);
    border: 1px solid var(--avm-line);
    border-radius: 10px;
    transition: background .14s ease, color .14s ease, border-color .14s ease, transform .14s ease;
}
.allout-vm-share-opt__icon svg { width: 18px; height: 18px; display: block; }

.allout-vm-share-opt__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.allout-vm-share-opt__label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
}
.allout-vm-share-opt__desc {
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--avm-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s ease;
}

/* A copy confirms itself in place: the row's own description turns green and
   says "Copied to clipboard" for a moment (design: --success-500). The reader is
   already looking at the row they clicked — that is where the answer belongs,
   not in a separate box elsewhere in the popover. */
.allout-vm-share-opt__desc.is-copied {
    color: #1e9e63;
    font-weight: 700;
}

.allout-vm-share-opt__chevron {
    flex: 0 0 auto;
    margin-left: auto;
    display: grid;
    place-items: center;
    color: #c2c9d6;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .14s ease, transform .14s ease, color .14s ease;
}
.allout-vm-share-opt__chevron svg { width: 16px; height: 16px; display: block; }

.allout-vm-share-opt:hover,
.allout-vm-share-opt:focus-visible {
    /* Neutral fallback first; UAs with color-mix tint it from the live accent. */
    background: #f6f7fa;
    background: color-mix(in srgb, var(--avm-accent) 7%, #fff);
    outline: none;
    transform: translateX(1px);
}
.allout-vm-share-opt:hover .allout-vm-share-opt__icon,
.allout-vm-share-opt:focus-visible .allout-vm-share-opt__icon {
    color: #fff;
    background: var(--avm-accent);
    border-color: var(--avm-accent);
    transform: scale(1.04);
}
.allout-vm-share-opt:hover .allout-vm-share-opt__label,
.allout-vm-share-opt:focus-visible .allout-vm-share-opt__label {
    color: var(--avm-accent-ink);
}
.allout-vm-share-opt:hover .allout-vm-share-opt__chevron,
.allout-vm-share-opt:focus-visible .allout-vm-share-opt__chevron {
    opacity: 1;
    transform: translateX(0);
    color: var(--avm-accent);
}
.allout-vm-share-opt:active { transform: translateX(1px) scale(.995); }

/* "Start at" control: arm checkbox on the first row, slider + exact time below. */
.allout-vm-share-ts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px;
    margin: 2px 2px 6px;
    font-size: 12px;
    font-weight: 500;
    color: #455066;
    background: var(--avm-tile);
    border: 1px solid var(--avm-line);
    border-radius: 10px;
}
.allout-vm-share-ts[hidden] { display: none; }
.allout-vm-share-ts__arm {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.allout-vm-share-ts__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.allout-vm-share-ts__range {
    flex: 1 1 auto;
    min-width: 0;
    height: 4px;
    margin: 0;
    accent-color: var(--avm-accent);
    cursor: pointer;
}
.allout-vm-share-ts__time {
    flex: 0 0 auto;
    width: 62px;
    padding: 3px 6px;
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: #455066;
    background: #fff;
    border: 1px solid var(--avm-line);
    border-radius: 6px;
}
.allout-vm-share-ts__time:focus {
    outline: 2px solid var(--avm-accent);
    outline-offset: 1px;
}
.allout-vm-share-ts__duration {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    color: #7b8598;
    white-space: nowrap;
}
.allout-vm-share-ts__arm input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--avm-accent);
}

/*
 * Theme-proofing for the two form controls.
 *
 * On the front end these render inside the active theme, which styles bare form
 * controls for its own forms — BeTheme sizes them from customizer-generated CSS
 * that is not part of this plugin and cannot be predicted here. A theme rule like
 * `input[type="text"] { width: 230px; display: block; margin-bottom: 20px }` has
 * specificity (0,1,1) and beats a lone `.allout-vm-share-ts__time` (0,1,0), which
 * collapsed the range to just its thumb and stretched the time field into a wide
 * block — the row stopped looking like a scrubber at all.
 *
 * Re-declaring under the parent class plus the type attribute gives (0,3,0), so
 * these win without `!important`, and every property a theme is likely to touch is
 * stated explicitly rather than left to be inherited.
 */
.allout-vm-share-ts .allout-vm-share-ts__range[type="range"] {
    flex: 1 1 auto;
    display: inline-block;
    width: auto;
    min-width: 0;
    max-width: none;
    height: 4px;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    accent-color: var(--avm-accent);
    cursor: pointer;
}
.allout-vm-share-ts .allout-vm-share-ts__time[type="text"] {
    flex: 0 0 auto;
    display: inline-block;
    box-sizing: border-box;
    width: 62px;
    min-width: 0;
    max-width: none;
    height: auto;
    min-height: 0;
    padding: 3px 6px;
    margin: 0;
    font: inherit;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    text-align: center;
    color: #455066;
    background: #fff;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Status line */
.allout-vm-share-status {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 11px;
    margin: 6px 2px 2px;
    font-size: 12px;
    font-weight: 600;
    color: #12704a;
    background: #e9f7ef;
    border: 1px solid #cdeede;
    border-radius: 10px;
}
.allout-vm-share-status[hidden] { display: none; }
.allout-vm-share-status.is-error {
    color: #a5262b;
    background: #fdecec;
    border-color: #f6cfd1;
}

/* QR code panel (drawn in-browser by video-tools.js). */
.allout-vm-share-qr {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 12px 12px;
    margin: 6px 2px 2px;
    border: 1px solid var(--avm-line);
    border-radius: 12px;
    background: var(--avm-surface);
}
.allout-vm-share-qr[hidden] { display: none; }

/* Dismiss the QR on its own, without closing the whole share menu. */
.allout-vm-share-qr__close {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--avm-muted);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.allout-vm-share-qr__close:hover {
    background: #f0f2f6;
    color: var(--avm-ink);
}
.allout-vm-share-qr__close:focus-visible {
    outline: 2px solid var(--avm-accent);
    outline-offset: 1px;
}
.allout-vm-share-qr__img {
    width: 176px;
    height: 176px;
    padding: 10px;
    image-rendering: pixelated;
    background: #fff;
    border: 1px solid var(--avm-line);
    border-radius: 12px;
    box-shadow: 0 8px 20px -12px rgba(16, 25, 43, .4);
}
.allout-vm-share-qr__download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    color: var(--avm-accent);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--avm-line);
    border-radius: 999px;
    transition: background .14s ease, border-color .14s ease;
}
.allout-vm-share-qr__download:hover {
    background: #f6f7fa;
    background: color-mix(in srgb, var(--avm-accent) 7%, #fff);
    border-color: var(--avm-accent);
    text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
    .allout-vm-share-menu { animation: none; }
    .allout-vm-share-opt,
    .allout-vm-share-opt__icon,
    .allout-vm-share-opt__chevron { transition: none; }
}

/*
 * No prefers-color-scheme override: the share menu is a deliberately fixed
 * white surface on every UA. A dark variant existed and was dropped — the
 * white treatment is the finalised design, and the popover already carries its
 * own border and shadow, so it reads correctly against a dark page.
 */

/* ---------------------------------------------------------------------------
 * Admin context (Frontend\VideoToolsBar::forVideo($id, true)) — the bar now also
 * renders in the allout_video list table and on Marketing Library cards.
 * ------------------------------------------------------------------------- */

.allout-vm-tools--admin {
    margin-top: 8px;
}

/* Both hosts are narrow and sit toward the right of their container, so a 320px
   menu anchored left would run off-screen. Anchor it to the right edge instead,
   and move the caret with it (mirrors the .allout-vm-stage overlay rules). */
.allout-vm-tools--admin .allout-vm-share-menu {
    left: auto;
    right: 0;
    transform-origin: top right;
}
.allout-vm-tools--admin .allout-vm-share-menu::before {
    left: auto;
    right: 22px;
}

/* The list table's Share cell is short; keep the trigger compact so the row
   height does not jump. */
.allout-vm-list-share .allout-vm-tool--share {
    padding: 4px 10px;
    font-size: 12px;
}

/* Marketing Library card: the Share trigger reads as a sibling of the card's
   other full-width copy buttons. */
.allout-vm-portal .ml-vid-foot .allout-vm-tools--admin .allout-vm-tool--share {
    width: 100%;
    justify-content: center;
}

/* Floating menu (video-tools.js placeMenu): the menu is anchored to the trigger
   with position:fixed so a clipping container — a Spotlight panel, the theme's
   section wrapper — can no longer swallow its lower options. The caret is dropped
   because a fixed, viewport-clamped (and possibly flipped) menu no longer sits
   directly under the trigger. Two classes so this wins over the .allout-vm-stage
   and .allout-vm-tools--admin caret rules regardless of source order. */
.allout-vm-share-menu.allout-vm-share-menu--floating::before {
    display: none;
}

/* Give the internally-scrolling menu a little end padding and a contained scroll
   so a capped, scrollable menu still reads as one rounded card. */
.allout-vm-share-menu.allout-vm-share-menu--floating {
    overscroll-behavior: contain;
}
