/* ============================================
   INFO HUD — Contextual Help Tooltip System
   & Vendor Processing Notice Banners
   ============================================
   Provides a toggle-able overlay of tooltip
   balloons next to key UI elements, plus
   always-visible processing notices for
   API vs non-API vendor workflows.
   ============================================ */

/* ============================================
   1. HUD TOGGLE BUTTON
   Fixed circular button above the theme toggle
   ============================================ */

html body .avosec-hud-toggle {
    position: fixed;
    bottom: 84px;
    right: 24px;
    z-index: 9999;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-bg-secondary);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    padding: 0;
    color: var(--color-text-secondary);
}

html body .avosec-hud-toggle:hover {
    transform: scale(1.1);
    border-color: var(--color-accent);
    box-shadow: var(--shadow-glow);
}

html body .avosec-hud-toggle .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    line-height: 1;
}

/* Active state — HUD is on */
html body .avosec-hud-toggle.active {
    border-color: var(--color-info);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(14, 165, 233, 0.3);
    color: #ffffff;
    background-color: var(--color-info);
}

/* ============================================
   2. TOOLTIP BALLOONS
   Fixed-position tips shown when HUD is active
   ============================================ */

.avosec-hud-tip {
    position: fixed;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-top: 2px solid var(--color-info);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.12);
    max-width: 260px;
    padding: var(--space-3);
    z-index: 10000;
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-text-primary);
    transition: opacity 200ms ease-out, transform 200ms ease-out, visibility 200ms ease-out;
    transition-delay: var(--hud-tip-delay, 0ms);
}

/* Shown state — body has active class and tip is marked visible */
body.avosec-hud-active .avosec-hud-tip.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Slide-in animations based on arrow direction */
.avosec-hud-tip[data-hud-position="top"] {
    transform: translateY(6px);
}

.avosec-hud-tip[data-hud-position="bottom"] {
    transform: translateY(-6px);
}

.avosec-hud-tip[data-hud-position="left"] {
    transform: translateX(6px);
}

.avosec-hud-tip[data-hud-position="right"] {
    transform: translateX(-6px);
}

body.avosec-hud-active .avosec-hud-tip.visible[data-hud-position="top"],
body.avosec-hud-active .avosec-hud-tip.visible[data-hud-position="bottom"] {
    transform: translateY(0);
}

body.avosec-hud-active .avosec-hud-tip.visible[data-hud-position="left"],
body.avosec-hud-active .avosec-hud-tip.visible[data-hud-position="right"] {
    transform: translateX(0);
}

/* ============================================
   2a. TOOLTIP ARROWS (CSS triangles via ::after)
   ============================================ */

.avosec-hud-tip::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

/* Arrow points DOWN (tip is above the target) */
.avosec-hud-tip[data-hud-position="top"]::after {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: var(--color-info);
    border-bottom: none;
}

/* Arrow points UP (tip is below the target) */
.avosec-hud-tip[data-hud-position="bottom"]::after {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: var(--color-info);
    border-top: none;
}

/* Arrow points RIGHT (tip is to the left of the target) */
.avosec-hud-tip[data-hud-position="left"]::after {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: var(--color-info);
    border-right: none;
}

/* Arrow points LEFT (tip is to the right of the target) */
.avosec-hud-tip[data-hud-position="right"]::after {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: var(--color-info);
    border-left: none;
}

/* ============================================
   3. TIP CONTENT LAYOUT
   Icon + text flexbox row
   ============================================ */

.avosec-hud-tip-content {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.avosec-hud-tip-content .avosec-hud-tip-icon {
    flex-shrink: 0;
    color: var(--color-info);
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

.avosec-hud-tip-content span:last-child {
    line-height: 1.5;
}

/* ============================================
   4. PROCESSING NOTICE BANNERS
   Always-visible vendor status indicators
   ============================================ */

.avosec-processing-notice {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm, 0.875rem);
    margin: var(--space-3) 0;
    border-left: 3px solid;
}

.avosec-processing-notice .dashicons {
    flex-shrink: 0;
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
}

/* Instant / API vendor — green */
.avosec-processing-notice--instant {
    background: rgba(16, 185, 129, 0.06);
    border-left-color: var(--color-accent);
}

.avosec-processing-notice--instant .dashicons {
    color: var(--color-accent);
}

/* Manual / Non-API vendor — amber */
.avosec-processing-notice--manual {
    background: rgba(245, 158, 11, 0.06);
    border-left-color: var(--color-warning);
}

.avosec-processing-notice--manual .dashicons {
    color: var(--color-warning);
}

/* ============================================
   4a. VENDOR POPUP — compact notice inside cards
   ============================================ */

.cat-box .avosec-processing-notice {
    margin: 4px 0 0;
    padding: var(--space-1) var(--space-2);
    font-size: 0.7rem;
    border-left: none;
    border-radius: var(--radius-sm);
    justify-content: center;
}

.cat-box .avosec-processing-notice .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* ============================================
   4b. HIDE TIPS BEHIND MODAL OVERLAYS
   Body class set by vendor popup jQuery
   ============================================ */

body.avosec-modal-open .avosec-hud-tip {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.avosec-modal-open .avosec-hud-toggle {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ============================================
   5. LIGHT THEME OVERRIDES
   ============================================ */

html[data-theme="light"] .avosec-hud-tip {
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
}

html[data-theme="light"] .avosec-processing-notice--instant {
    background: rgba(16, 185, 129, 0.08);
}

html[data-theme="light"] .avosec-processing-notice--manual {
    background: rgba(245, 158, 11, 0.08);
}

/* ============================================
   6. RESPONSIVE — Mobile (<768px)
   ============================================ */

@media (max-width: 767px) {
    .avosec-hud-toggle {
        right: 12px;
        bottom: 72px;
        width: 44px;
        height: 44px;
    }

    .avosec-hud-tip {
        max-width: 220px;
    }
}

/* ============================================
   7. STAGGERED ANIMATION
   JS sets --hud-tip-delay per tip for
   sequential fade-in effect
   ============================================ */

/* Already handled via the transition-delay
   property on .avosec-hud-tip using
   var(--hud-tip-delay, 0ms).
   Each tip receives a custom property value
   from JS (e.g., 0ms, 50ms, 100ms...). */

/* ============================================
   8. NO-JS FALLBACK
   Hide toggle when JavaScript is unavailable
   ============================================ */

.no-js .avosec-hud-toggle {
    display: none;
}

/* ============================================
   9. VIDEO TUTORIAL — PLAY BUTTON
   Inline trigger next to page H1, visible
   only when HUD is active.
   ============================================ */

html body .avosec-hud-video-trigger {
    display: none;
    align-items: center;
    gap: 6px;
    height: 30px;
    border-radius: 15px;
    border: none;
    background: #3498db;
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 12px;
    padding: 0 12px 0 10px;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.35);
    transition: transform 200ms ease, box-shadow 200ms ease, opacity 200ms ease, background 200ms ease;
    opacity: 0;
    transform: scale(0.8);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
}

body.avosec-hud-active .avosec-hud-video-trigger {
    display: inline-flex;
    opacity: 1;
    transform: scale(1);
    animation: avosec-video-btn-pulse 1.2s ease-in-out 3;
}

html body .avosec-hud-video-trigger:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.5);
    background: #2980b9;
    color: #fff;
}

html body .avosec-hud-video-trigger:active {
    transform: scale(0.97);
}

html body .avosec-hud-video-trigger svg {
    flex-shrink: 0;
}

.avosec-hud-video-label {
    pointer-events: none;
}

/* Attention pulse — plays 3 times then stops */
@keyframes avosec-video-btn-pulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(52, 152, 219, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(52, 152, 219, 0.25), 0 2px 12px rgba(52, 152, 219, 0.5); }
}

/* Hide play button behind modal overlays */
body.avosec-modal-open .avosec-hud-video-trigger {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ============================================
   10. VIDEO TUTORIAL — LIGHTBOX
   Full-screen overlay with centered video.
   Dark/light theme aware.
   ============================================ */

.avosec-video-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

.avosec-video-lightbox[aria-hidden="false"] {
    display: flex;
}

.avosec-video-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    animation: avosec-video-fade-in 200ms ease-out;
}

.avosec-video-lightbox__container {
    position: relative;
    width: min(90vw, 1100px);
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: avosec-video-scale-in 200ms ease-out;
}

.avosec-video-lightbox__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.avosec-video-lightbox__title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a2e;
    letter-spacing: 0.01em;
}

.avosec-video-lightbox__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    padding: 0;
}

.avosec-video-lightbox__close:hover {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

.avosec-video-lightbox__player {
    display: block;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

/* Prevent background scroll while lightbox is open */
body.avosec-video-open {
    overflow: hidden;
}

/* Lightbox entrance animations */
@keyframes avosec-video-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes avosec-video-scale-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   10a. LIGHTBOX — DARK THEME
   ============================================ */

html[data-theme="dark"] .avosec-video-lightbox__backdrop {
    background: rgba(0, 0, 0, 0.85);
}

html[data-theme="dark"] .avosec-video-lightbox__container {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

html[data-theme="dark"] .avosec-video-lightbox__header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .avosec-video-lightbox__title {
    color: #e0e0e0;
}

html[data-theme="dark"] .avosec-video-lightbox__close {
    color: #94a3b8;
}

html[data-theme="dark"] .avosec-video-lightbox__close:hover {
    background: rgba(52, 152, 219, 0.15);
    color: #5dade2;
}
