/* ============ Automind Popup — clean ============ */

/* Root: nic nie łapie klików (łapią pod‑elementy) */
#automind-pop {
    position: fixed;
    bottom: 18px;
    right: 18px;
    /* domyślnie prawa strona */
    z-index: 2147483600 !important;
    /* wysoki, ale zostawiamy miejsce dla CookieYes */
    transition: opacity .2s ease;
    opacity: 0;
    pointer-events: none !important;
}

#automind-pop.left {
    left: 18px;
    right: auto;
}

#automind-pop.am-ready {
    opacity: 1;
}

/* Bubble (ikona) — usuń wszystkie style przycisku z motywu */
#automind-pop .am-pop-bubble {
    width: var(--am-icon-size, 48px);
    height: var(--am-icon-size, 48px);
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    /* dla pierścienia */
    transform: translateZ(0);
    will-change: auto;
    z-index: 2147483600 !important;
    pointer-events: auto !important;
}

/* Nie pozwól motywowi nadpisywać tła/cieni przy interakcjach */
#automind-pop .am-pop-bubble:hover,
#automind-pop .am-pop-bubble:active,
#automind-pop .am-pop-bubble:focus,
#automind-pop .am-pop-bubble:focus-visible,
#automind-pop .am-pop-bubble::-moz-focus-inner {
    background: transparent !important;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Ikona jako tło (SVG/PNG) */
#automind-pop .am-pop-ico {
    display: block;
    width: 100% !important;
    height: 100% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    pointer-events: none;
}

/* Pulse ring — działa także na mobile */
#automind-pop .am-pop-bubble.am-attn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 999px;
    box-shadow: 0 0 0 0 rgba(11, 92, 171, .45);
    animation: amPulseRing 1.1s ease-out 7;
    pointer-events: none;
}

@keyframes amPulseRing {
    0% {
        box-shadow: 0 0 0 0 rgba(11, 92, 171, .45);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(11, 92, 171, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(11, 92, 171, 0);
    }
}

/* Tip (welcome) — sterowany aria-hidden */
#automind-pop .am-pop-tip {
    display: none;
    position: absolute;
    bottom: calc(var(--am-icon-size, 48px) + 36px);
    right: 0;
    width: 320px;
    max-width: min(360px, calc(100vw - 48px));
    background: #fff;
    color: #111;
    font-size: 13px;
    line-height: 1.45;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .10);
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    z-index: 2147483599 !important;
    /* pod bubble/panelem */
    white-space: normal;
    word-break: normal;
    hyphens: auto;
}

#automind-pop.left .am-pop-tip {
    right: auto;
    left: 0;
}

#automind-pop .am-pop-tip[aria-hidden="false"] {
    display: block;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#automind-pop .am-tip-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: 0;
    background: transparent;
    color: #6b7280;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}

/* Panel (desktop baseline) */
#automind-pop .am-pop-panel {
    position: absolute;
    bottom: calc(var(--am-icon-size, 48px) + 24px);
    width: 360px;
    max-height: 70vh;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
    overflow: hidden;
    display: none;
    /* ukryty domyślnie */
    pointer-events: none;
    z-index: 2147483598 !important;
}

#automind-pop.right .am-pop-panel {
    right: 0;
}

#automind-pop.left .am-pop-panel {
    left: 0;
}

#automind-pop .am-pop-panel.am-open,
#automind-pop.am-open .am-pop-panel {
    display: block !important;
}

#automind-pop .am-pop-panel[aria-hidden="true"] {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

#automind-pop .am-pop-panel[aria-hidden="false"] {
    pointer-events: auto !important;
    visibility: visible !important;
}

/* Panel header/body */
#automind-pop .am-pop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    background: #f8fafc;
}

#automind-pop .am-pop-title {
    font-weight: 600;
}

#automind-pop .am-pop-close {
    background: transparent;
    border: 0;
    font-size: 18px;
    cursor: pointer;
    color: #444;
}

#automind-pop .am-pop-body {
    padding: 10px;
}

#automind-pop .automind-widget {
    max-width: none;
    border: 0;
    padding: 0;
}

#automind-pop .automind-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#automind-pop .automind-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 2px;
}

#automind-pop .automind-actions .button {
    flex: 1;
}

/* Ikona bliżej dolnej krawędzi na mobile */
@media (max-width: 782px) {
    #automind-pop {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    }

    body.admin-bar #automind-pop {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    }
}

/* ============ Mobile: fullscreen panel ============ */
@media (max-width: 782px) {
    #automind-pop .am-pop-panel {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw !important;
        height: 100vh;
        height: 100svh;
        height: 100dvh;
        max-height: none !important;
        border-radius: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
        display: none !important;
        /* ukryty domyślnie */
        flex-direction: column;
        background: #fff;
        z-index: 2147483598 !important;
        /* pod bubble */
    }

    #automind-pop .am-pop-panel.am-open,
    #automind-pop.am-open .am-pop-panel {
        display: flex !important;
    }

    #automind-pop .am-pop-header {
        flex: 0 0 auto;
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top, 0));
        border-bottom: 1px solid #eee;
        background: #f8fafc;
    }

    #automind-pop .am-pop-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0));
    }

    #automind-pop .automind-widget {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    #automind-pop .automind-widget .automind-messages {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
    }

    #automind-pop .automind-form {
        flex: 0 0 auto;
        margin-top: 8px;
    }
}

/* ============ CookieYes fallback (widoczny, nad czatem) ============ */
.cky-consent-container {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    background-color: #ffffff !important;
    /* upewnij się, że NIE jest transparentny */
    color: #111 !important;
    border: 1px solid #e5e7eb !important;
    z-index: 2147483647 !important;
    /* ponad ikoną czatu */
    position: fixed !important;
    /* jeśli motyw nie nadaje pozycjonowania */
}

.cky-overlay {
    opacity: 1 !important;
    visibility: visible !important;
    background: rgba(0, 0, 0, .35) !important;
    /* przyciemnij tło */
    z-index: 2147483646 !important;
    /* pod banerem, nad treścią */
}

.cky-overlay.cky-hide,
.cky-consent-container.cky-hide,
.cky-consent-container[style*="display: none"],
.cky-overlay[style*="display: none"] {
    pointer-events: none !important;
    visibility: hidden !important;
}