/**
 * ==========================================================================
 * FlowPosts Wirtualny Asystent — Style frontendu bota tutorialowego
 * Autor: FlowPosts
 * Wersja: 1.0.0
 * ==========================================================================
 *
 * HIERARCHIA Z-INDEX (ważne — nie zmieniać bez aktualizacji JS):
 * ---------------------------------------------------------------
 *   99970 = Przycisk startowy (launch button)
 *   99980 = Ciemna nakładka (overlay)
 *   99982 = Podświetlony element strony
 *   99983 = Przechwytywacz kliknięć (click catcher)
 *   99985 = Wyniesiony rodzic Elementor (sekcja/kolumna)
 *   99990 = Kontener bota
 *   99995 = Ekran zwycięstwa
 * ---------------------------------------------------------------
 */

/* ==========================================================================
   1. ZMIENNE CSS — domyślne wartości nadpisywane przez inline styles z PHP
   ========================================================================== */
:root {
    --fpa-bubble-bg: #ffffff;
    --fpa-bubble-text: #1e293b;
    --fpa-bubble-radius: 16px;
    --fpa-bubble-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    --fpa-avatar-from: #3b82f6;
    --fpa-avatar-to: #9333ea;
    --fpa-avatar-size: 64px;
    --fpa-avatar-border: #1e293b;
    --fpa-highlight-color: rgba(59, 130, 246, 0.7);
    --fpa-overlay-bg: rgba(15, 23, 42, 0.80);
    --fpa-overlay-blur: 4px;
    --fpa-btn-primary: #3b82f6;
    --fpa-btn-skip-from: #f59e0b;
    --fpa-btn-skip-to: #f97316;
    --fpa-btn-finish-from: #22c55e;
    --fpa-btn-finish-to: #10b981;
    --fpa-karaoke-bg: #3b82f6;
    --fpa-karaoke-color: #ffffff;
    --fpa-bot-max-width: 360px;
}

/* ==========================================================================
   2. RESET — border-box na wszystkich elementach bota
   ========================================================================== */
[id^="fpa-"],
[id^="fpa-"] *,
[class^="fpa-"],
[class^="fpa-"] * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   3. CIEMNA NAKŁADKA (overlay)
   ========================================================================== */
.fpa-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: var(--fpa-overlay-bg) !important;
    -webkit-backdrop-filter: blur(var(--fpa-overlay-blur));
    backdrop-filter: blur(var(--fpa-overlay-blur));
    z-index: 99980 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    will-change: opacity;
}

.fpa-overlay.fpa-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================================
   4. KONTENER BOTA
   ========================================================================== */
.fpa-bot {
    position: fixed !important;
    z-index: 99990 !important;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: var(--fpa-bot-max-width);
    width: var(--fpa-bot-max-width);
    opacity: 0;
    transform: scale(0.7) translateY(30px);
    pointer-events: none;
    filter: drop-shadow(0 8px 32px rgba(0, 0, 0, 0.25));
    /* Sprężysta animacja "lotu" bota */
    transition:
        opacity 0.35s ease,
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        top 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
        left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
        bottom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
        right 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: opacity, transform, top, left;
}

.fpa-bot.fpa-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* ==========================================================================
   5. KOMIKSOWY DYMEK
   ========================================================================== */
.fpa-comic-bubble {
    position: relative;
    background: var(--fpa-bubble-bg);
    color: var(--fpa-bubble-text);
    border-radius: var(--fpa-bubble-radius) var(--fpa-bubble-radius) var(--fpa-bubble-radius) 0;
    box-shadow: var(--fpa-bubble-shadow);
    padding: 0;
    width: 100%;
    overflow: hidden;
}

/* Ogonek dymka — trójkąt skierowany w lewo-dół */
.fpa-comic-bubble::after {
    content: "";
    position: absolute;
    bottom: -12px;
    left: 24px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 12px 0 0;
    border-color: var(--fpa-bubble-bg) transparent transparent transparent;
    filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.1));
}

/* --- Nagłówek dymka --- */
.fpa-bubble-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.02);
}

.fpa-bubble-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fpa-btn-primary);
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}

.fpa-bubble-title i {
    font-size: 13px;
}

/* Przyciski ikon w nagłówku (ustawienia, głośnik, zamknij) */
.fpa-bubble-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fpa-icon-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: #94a3b8 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    line-height: 1 !important;
    outline: none !important;
    box-shadow: none !important;
}

.fpa-icon-btn:hover {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--fpa-btn-primary) !important;
}

.fpa-icon-btn:focus {
    outline: 2px solid var(--fpa-btn-primary) !important;
    outline-offset: -2px;
}

.fpa-icon-btn.fpa-active {
    color: var(--fpa-btn-primary) !important;
    background: rgba(59, 130, 246, 0.12) !important;
}

/* --- Panel ustawień (język, głos TTS) --- */
.fpa-settings-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    padding: 0 14px;
}

.fpa-settings-panel.fpa-visible {
    max-height: 200px;
    padding: 10px 14px;
}

.fpa-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.fpa-settings-row:last-child {
    margin-bottom: 0;
}

.fpa-settings-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    min-width: 48px;
}

.fpa-settings-select {
    flex: 1;
    padding: 4px 8px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    background: #ffffff !important;
    color: #334155 !important;
    cursor: pointer !important;
    outline: none !important;
    height: auto !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    -webkit-appearance: auto !important;
    appearance: auto !important;
}

.fpa-settings-select:focus {
    border-color: var(--fpa-btn-primary) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15) !important;
}

/* --- Treść tutorialu --- */
.fpa-bubble-content {
    padding: 14px;
}

.fpa-tutorial-text {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.65;
    color: var(--fpa-bubble-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-height: 180px;
    overflow-y: auto;
}

/* Scrollbar dla tekstu tutorialu */
.fpa-tutorial-text::-webkit-scrollbar {
    width: 4px;
}

.fpa-tutorial-text::-webkit-scrollbar-track {
    background: transparent;
}

.fpa-tutorial-text::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.fpa-tutorial-text::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* --- Pasek postępu --- */
.fpa-progress-bar {
    height: 3px;
    background: rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.fpa-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--fpa-btn-primary), var(--fpa-avatar-to, #9333ea));
    border-radius: 0 3px 3px 0;
    transition: width 0.4s ease;
}

/* ==========================================================================
   6. KARAOKE — podświetlanie słów podczas odczytu TTS
   ========================================================================== */
.fpa-word {
    display: inline;
    padding: 1px 3px;
    margin: 0 0.5px;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
    cursor: default;
}

.fpa-word.fpa-word-active {
    background-color: var(--fpa-karaoke-bg);
    color: var(--fpa-karaoke-color);
    border-radius: 4px;
}

/* Przeczytane słowa — delikatne wygaszenie */
.fpa-word.fpa-word-read {
    opacity: 0.55;
}

/* ==========================================================================
   7. STOPKA BOTA — awatar + nawigacja
   ========================================================================== */
.fpa-bot-footer {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-top: 14px;
    width: 100%;
}

/* --- Awatar --- */
.fpa-avatar {
    position: relative;
    flex-shrink: 0;
    width: var(--fpa-avatar-size);
    height: var(--fpa-avatar-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fpa-avatar-from), var(--fpa-avatar-to));
    border: 3px solid var(--fpa-avatar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 16px rgba(59, 130, 246, 0.3),
        0 0 0 3px rgba(59, 130, 246, 0.1);
    cursor: default;
}

.fpa-avatar i,
.fpa-avatar-icon {
    font-size: calc(var(--fpa-avatar-size) * 0.42);
    color: #ffffff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Pulsujący wskaźnik statusu (zielona kropka) */
.fpa-avatar-pulse {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--fpa-bubble-bg);
}

.fpa-avatar-pulse::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.4);
    animation: fpa-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Animacja pulsowania wskaźnika statusu */
@keyframes fpa-ping {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    75%, 100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* --- Przyciski nawigacyjne --- */
.fpa-nav-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    align-items: center;
}

/* ==========================================================================
   8. PRZYCISKI — z !important dla nadpisania Elementor/Astra
   ========================================================================== */
.fpa-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 8px 16px !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: none !important;
    text-decoration: none !important;
    letter-spacing: 0.02em !important;
    cursor: pointer !important;
    transition: all 0.25s ease !important;
    outline: none !important;
    box-shadow: none !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
    user-select: none !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    text-shadow: none !important;
    min-height: auto !important;
    min-width: auto !important;
    margin: 0 !important;
    float: none !important;
    position: relative !important;
    z-index: auto !important;
    vertical-align: middle !important;
}

.fpa-btn i {
    font-size: 12px !important;
    line-height: 1 !important;
}

/* Przycisk "Wstecz" — szary, drugorzędny */
.fpa-btn.fpa-btn-secondary {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

.fpa-btn.fpa-btn-secondary:hover {
    background: #cbd5e1 !important;
    color: #1e293b !important;
}

/* Przycisk "Dalej" — główny, niebieski */
.fpa-btn.fpa-btn-primary {
    background: var(--fpa-btn-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35) !important;
}

.fpa-btn.fpa-btn-primary:hover {
    filter: brightness(1.1) !important;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5) !important;
    transform: translateY(-1px) !important;
}

/* Przycisk "Pomiń" — gradient amber/orange */
.fpa-btn.fpa-btn-skip {
    background: linear-gradient(135deg, var(--fpa-btn-skip-from), var(--fpa-btn-skip-to)) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3) !important;
}

.fpa-btn.fpa-btn-skip:hover {
    filter: brightness(1.1) !important;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45) !important;
    transform: translateY(-1px) !important;
}

/* Przycisk "Zakończ" — gradient zielony */
.fpa-btn.fpa-btn-finish {
    background: linear-gradient(135deg, var(--fpa-btn-finish-from), var(--fpa-btn-finish-to)) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3) !important;
}

.fpa-btn.fpa-btn-finish:hover {
    filter: brightness(1.1) !important;
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.45) !important;
    transform: translateY(-1px) !important;
}

/* Stan wyłączony */
.fpa-btn:disabled,
.fpa-btn[disabled] {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    filter: none !important;
}

/* ==========================================================================
   9. PODŚWIETLENIE ELEMENTÓW STRONY
   ========================================================================== */

/* Wyniesiony rodzic Elementor — sekcja/kolumna nad overlay */
.fpa-elevated-parent {
    position: relative !important;
    z-index: 99985 !important;
}

/* Podświetlony element — pulsujący niebieska poświata */
.fpa-highlight {
    position: relative !important;
    z-index: 99982 !important;
    animation: fpa-pulse 2s ease-in-out infinite !important;
    outline: 3px solid var(--fpa-highlight-color) !important;
    outline-offset: 4px !important;
    border-radius: 4px;
    transition: outline-color 0.3s ease;
}

/* Animacja pulsowania — rozszerzający się cień */
@keyframes fpa-pulse {
    0% {
        box-shadow: 0 0 0 0 var(--fpa-highlight-color);
    }
    50% {
        box-shadow: 0 0 0 16px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Przechwytywacz kliknięć — blokuje interakcję z podświetlonym elementem */
.fpa-click-catcher {
    position: absolute !important;
    inset: -4px !important;
    z-index: 99983 !important;
    background: transparent !important;
    cursor: default !important;
    border: none !important;
    outline: none !important;
    pointer-events: auto;
}

/* ==========================================================================
   10. EKRAN ZWYCIĘSTWA
   ========================================================================== */
.fpa-victory-screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(15, 23, 42, 0.92) !important;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 99995 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    overflow: hidden;
}

.fpa-victory-screen.fpa-visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Deszcz konfetti --- */
.fpa-confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.fpa-confetti {
    position: absolute;
    top: -40px;
    font-size: 24px;
    animation: fpa-fall linear infinite;
    will-change: transform;
    user-select: none;
    pointer-events: none;
}

/* Losowe opóźnienia i pozycje dla elementów konfetti (ustawiane inline w HTML) */
.fpa-confetti:nth-child(1)  { left: 3%;  animation-duration: 3.2s; animation-delay: 0.0s; font-size: 20px; }
.fpa-confetti:nth-child(2)  { left: 8%;  animation-duration: 3.8s; animation-delay: 0.3s; font-size: 26px; }
.fpa-confetti:nth-child(3)  { left: 13%; animation-duration: 2.9s; animation-delay: 0.7s; font-size: 18px; }
.fpa-confetti:nth-child(4)  { left: 18%; animation-duration: 4.1s; animation-delay: 0.1s; font-size: 22px; }
.fpa-confetti:nth-child(5)  { left: 23%; animation-duration: 3.5s; animation-delay: 0.5s; font-size: 28px; }
.fpa-confetti:nth-child(6)  { left: 28%; animation-duration: 3.0s; animation-delay: 0.9s; font-size: 16px; }
.fpa-confetti:nth-child(7)  { left: 33%; animation-duration: 3.7s; animation-delay: 0.2s; font-size: 24px; }
.fpa-confetti:nth-child(8)  { left: 38%; animation-duration: 4.3s; animation-delay: 0.6s; font-size: 20px; }
.fpa-confetti:nth-child(9)  { left: 43%; animation-duration: 2.8s; animation-delay: 1.0s; font-size: 26px; }
.fpa-confetti:nth-child(10) { left: 48%; animation-duration: 3.4s; animation-delay: 0.4s; font-size: 22px; }
.fpa-confetti:nth-child(11) { left: 53%; animation-duration: 3.9s; animation-delay: 0.8s; font-size: 18px; }
.fpa-confetti:nth-child(12) { left: 58%; animation-duration: 3.1s; animation-delay: 0.15s; font-size: 28px; }
.fpa-confetti:nth-child(13) { left: 63%; animation-duration: 4.0s; animation-delay: 0.55s; font-size: 20px; }
.fpa-confetti:nth-child(14) { left: 68%; animation-duration: 3.3s; animation-delay: 0.85s; font-size: 24px; }
.fpa-confetti:nth-child(15) { left: 73%; animation-duration: 2.7s; animation-delay: 0.25s; font-size: 16px; }
.fpa-confetti:nth-child(16) { left: 78%; animation-duration: 3.6s; animation-delay: 0.65s; font-size: 26px; }
.fpa-confetti:nth-child(17) { left: 83%; animation-duration: 4.2s; animation-delay: 0.05s; font-size: 22px; }
.fpa-confetti:nth-child(18) { left: 88%; animation-duration: 3.0s; animation-delay: 0.45s; font-size: 20px; }
.fpa-confetti:nth-child(19) { left: 93%; animation-duration: 3.8s; animation-delay: 0.75s; font-size: 28px; }
.fpa-confetti:nth-child(20) { left: 97%; animation-duration: 3.2s; animation-delay: 0.35s; font-size: 18px; }
.fpa-confetti:nth-child(21) { left: 5%;  animation-duration: 3.5s; animation-delay: 1.1s; font-size: 24px; }
.fpa-confetti:nth-child(22) { left: 15%; animation-duration: 4.0s; animation-delay: 1.3s; font-size: 20px; }
.fpa-confetti:nth-child(23) { left: 25%; animation-duration: 2.9s; animation-delay: 1.5s; font-size: 26px; }
.fpa-confetti:nth-child(24) { left: 35%; animation-duration: 3.4s; animation-delay: 1.2s; font-size: 18px; }
.fpa-confetti:nth-child(25) { left: 45%; animation-duration: 3.7s; animation-delay: 1.4s; font-size: 22px; }
.fpa-confetti:nth-child(26) { left: 55%; animation-duration: 3.1s; animation-delay: 1.6s; font-size: 28px; }
.fpa-confetti:nth-child(27) { left: 65%; animation-duration: 4.1s; animation-delay: 1.0s; font-size: 16px; }
.fpa-confetti:nth-child(28) { left: 75%; animation-duration: 3.3s; animation-delay: 1.7s; font-size: 24px; }
.fpa-confetti:nth-child(29) { left: 85%; animation-duration: 2.8s; animation-delay: 1.8s; font-size: 20px; }
.fpa-confetti:nth-child(30) { left: 95%; animation-duration: 3.6s; animation-delay: 1.9s; font-size: 26px; }

/* Animacja spadania konfetti z obrotami 3D */
@keyframes fpa-fall {
    0% {
        transform: translateY(-40px) rotateZ(0deg) rotateX(0deg) scale(1);
        opacity: 1;
    }
    25% {
        transform: translateY(25vh) rotateZ(90deg) rotateX(180deg) scale(0.95);
        opacity: 1;
    }
    50% {
        transform: translateY(50vh) rotateZ(180deg) rotateX(360deg) scale(0.9);
        opacity: 0.9;
    }
    75% {
        transform: translateY(75vh) rotateZ(270deg) rotateX(540deg) scale(0.85);
        opacity: 0.7;
    }
    100% {
        transform: translateY(105vh) rotateZ(360deg) rotateX(720deg) scale(0.8);
        opacity: 0;
    }
}

/* --- Kontener trofeum --- */
.fpa-trophy-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    padding: 24px;
}

/* Poświata za trofeum */
.fpa-trophy-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(250, 204, 21, 0.25) 0%, transparent 70%);
    filter: blur(20px);
    pointer-events: none;
    animation: fpa-glow-pulse 2s ease-in-out infinite;
}

@keyframes fpa-glow-pulse {
    0%, 100% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.15);
    }
}

/* Ikona trofeum */
.fpa-trophy-icon {
    position: relative;
    z-index: 3;
    font-size: 80px;
    color: #facc15;
    filter: drop-shadow(0 4px 16px rgba(250, 204, 21, 0.5));
    animation: fpa-trophy-bounce 1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Sprężysty bounce trofeum */
@keyframes fpa-trophy-bounce {
    0% {
        transform: scale(0) rotate(-15deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(5deg);
    }
    70% {
        transform: scale(0.95) rotate(-2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Tytuł zwycięstwa — gradientowy tekst */
.fpa-victory-title {
    position: relative;
    z-index: 3;
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #facc15, #f59e0b, #f97316);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fpa-shimmer 3s ease-in-out infinite;
    line-height: 1.2;
    text-align: center;
    user-select: none;
}

/* Animacja migotania gradientu */
@keyframes fpa-shimmer {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Podtytuł zwycięstwa */
.fpa-victory-subtitle {
    position: relative;
    z-index: 3;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    text-align: center;
    max-width: 320px;
    line-height: 1.5;
}

/* Przycisk zamknięcia ekranu zwycięstwa */
.fpa-victory-close {
    position: relative;
    z-index: 3;
    margin-top: 16px;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 12px 28px !important;
    border: 2px solid rgba(250, 204, 21, 0.5) !important;
    border-radius: 50px !important;
    background: rgba(250, 204, 21, 0.1) !important;
    color: #facc15 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.fpa-victory-close:hover {
    background: rgba(250, 204, 21, 0.2) !important;
    border-color: rgba(250, 204, 21, 0.8) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 20px rgba(250, 204, 21, 0.25) !important;
}

/* ==========================================================================
   11. PRZYCISK STARTOWY (launch button)
   ========================================================================== */
.fpa-launch-btn {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 99970 !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    border: none !important;
    background: linear-gradient(135deg, var(--fpa-avatar-from), var(--fpa-avatar-to)) !important;
    color: #ffffff !important;
    font-size: 22px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow:
        0 4px 16px rgba(59, 130, 246, 0.4),
        0 0 0 0 rgba(59, 130, 246, 0.3) !important;
    transition: all 0.3s ease !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    animation: fpa-launch-pulse 2.5s ease-in-out infinite;
}

.fpa-launch-btn:hover {
    transform: scale(1.12) !important;
    box-shadow:
        0 8px 28px rgba(59, 130, 246, 0.55),
        0 0 0 6px rgba(59, 130, 246, 0.15) !important;
}

.fpa-launch-btn:active {
    transform: scale(0.95) !important;
}

/* Ukrywanie przycisku gdy bot jest aktywny */
.fpa-launch-btn.fpa-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.5) !important;
}

/* Delikatna pulsacja przycisku startowego */
@keyframes fpa-launch-pulse {
    0%, 100% {
        box-shadow:
            0 4px 16px rgba(59, 130, 246, 0.4),
            0 0 0 0 rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow:
            0 4px 16px rgba(59, 130, 246, 0.4),
            0 0 0 8px rgba(59, 130, 246, 0);
    }
}

/* Tooltip przycisku */
.fpa-launch-btn[title] {
    position: relative !important;
}

/* ==========================================================================
   12. RESPONSYWNOŚĆ — urządzenia mobilne
   ========================================================================== */
@media (max-width: 768px) {
    /* Bot zajmuje 90% szerokości ekranu */
    .fpa-bot {
        width: 90vw !important;
        max-width: none !important;
        left: 5vw !important;
        right: 5vw !important;
    }

    /* Mniejszy awatar */
    .fpa-avatar {
        width: 48px !important;
        height: 48px !important;
    }

    .fpa-avatar i,
    .fpa-avatar-icon {
        font-size: 20px !important;
    }

    /* Mniejszy tekst */
    .fpa-tutorial-text {
        font-size: 13px;
        max-height: 140px;
    }

    /* Mniejsze przyciski */
    .fpa-btn {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }

    /* Mniejsze trofeum */
    .fpa-trophy-icon {
        font-size: 56px;
    }

    .fpa-victory-title {
        font-size: 24px;
    }

    .fpa-victory-subtitle {
        font-size: 14px;
    }

    /* Mniejszy przycisk startowy */
    .fpa-launch-btn {
        width: 48px !important;
        height: 48px !important;
        bottom: 16px !important;
        right: 16px !important;
        font-size: 18px !important;
    }

    /* Mniejsze konfetti */
    .fpa-confetti {
        font-size: 16px !important;
    }

    /* Nawigacja w kolumnie na małych ekranach */
    .fpa-nav-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .fpa-btn {
        justify-content: center !important;
        width: 100% !important;
    }

    /* Stopka bota w kolumnie */
    .fpa-bot-footer {
        flex-direction: column;
        align-items: center;
    }
}

/* Bardzo małe ekrany */
@media (max-width: 480px) {
    .fpa-bot {
        width: 95vw !important;
        left: 2.5vw !important;
        right: 2.5vw !important;
    }

    .fpa-bubble-header {
        padding: 8px 10px;
    }

    .fpa-bubble-title {
        font-size: 10px;
    }

    .fpa-bubble-content {
        padding: 10px;
    }

    .fpa-tutorial-text {
        font-size: 12px;
        max-height: 120px;
    }

    .fpa-trophy-icon {
        font-size: 44px;
    }

    .fpa-victory-title {
        font-size: 20px;
    }

    .fpa-victory-subtitle {
        font-size: 12px;
        max-width: 260px;
    }

    .fpa-trophy-glow {
        width: 140px;
        height: 140px;
    }
}

/* ==========================================================================
   13. WP ADMIN BAR — przesunięcie o 32px (desktop) / 46px (mobilne WP)
   ========================================================================== */

/* Desktop admin bar: 32px wysokości */
.admin-bar .fpa-overlay {
    top: 32px !important;
}

.admin-bar .fpa-bot {
    /* Nie zmniejszaj top — JS dynamicznie ustawia pozycję */
}

.admin-bar .fpa-launch-btn {
    /* Bez zmian — jest na dole strony */
}

.admin-bar .fpa-victory-screen {
    top: 32px !important;
}

/* Mobilny admin bar: 46px wysokości (poniżej 783px) */
@media screen and (max-width: 782px) {
    .admin-bar .fpa-overlay {
        top: 46px !important;
    }

    .admin-bar .fpa-victory-screen {
        top: 46px !important;
    }
}

/* Ukryty admin bar — bez przesunięć (fallback) */
html:not(.admin-bar) .fpa-overlay {
    top: 0 !important;
}

/* ==========================================================================
   14. NADPISANIA DLA MOTYWU ASTRA
   ========================================================================== */

/* Nagłówek sticky Astra — musi być pod overlay */
.ast-sticky-active,
.ast-header-sticked,
#ast-fixed-header,
.ast-sticky-main-header-active .site-header,
.ast-above-header-wrap,
.ast-below-header-wrap,
.ast-primary-header-bar,
.site-header-primary-section-left,
.site-header-primary-section-right {
    z-index: 99 !important;
}

/* Upewnij się, że sticky header nie blokuje overlay */
body.ast-header-break-point .ast-mobile-header-wrap,
body.ast-header-break-point .ast-mobile-popup-drawer {
    z-index: 99 !important;
}

/* Gdy bot jest aktywny, wymuś niski z-index na nawigacji Astra */
body.fpa-bot-active .ast-sticky-active,
body.fpa-bot-active .ast-header-sticked,
body.fpa-bot-active #ast-fixed-header,
body.fpa-bot-active .site-header {
    z-index: 99 !important;
    position: relative !important;
}

/* Menu mobilne Astra — pod overlay */
body.fpa-bot-active .ast-mobile-popup-drawer,
body.fpa-bot-active .ast-mobile-header-wrap {
    z-index: 99 !important;
}

/* Astra sidebar i content — reset z-index */
body.fpa-bot-active .site-content,
body.fpa-bot-active #content,
body.fpa-bot-active .ast-container {
    z-index: auto !important;
}

/* ==========================================================================
   15. ANIMACJE WEJŚCIA BOTA
   ========================================================================== */

/* Bounce — sprężyste wejście */
.fpa-entrance-bounce {
    animation: fpa-entrance-bounce-kf 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes fpa-entrance-bounce-kf {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(40px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) translateY(-8px);
    }
    70% {
        transform: scale(0.97) translateY(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Slide — wjazd z boku */
.fpa-entrance-slide {
    animation: fpa-entrance-slide-kf 0.5s ease-out both;
}

@keyframes fpa-entrance-slide-kf {
    0% {
        opacity: 0;
        transform: translateX(-60px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* ==========================================================================
   16. UKRYWANIE ELEMENTÓW — klasy pomocnicze
   ========================================================================== */
.fpa-hidden {
    display: none !important;
}

.fpa-invisible {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Wyłączenie scroll na body gdy bot jest aktywny (opcjonalne) */
body.fpa-no-scroll {
    overflow: hidden !important;
}

/* ==========================================================================
   17. DRUKOWANIE — ukryj wszystko co dotyczy bota
   ========================================================================== */
@media print {
    .fpa-overlay,
    .fpa-bot,
    .fpa-victory-screen,
    .fpa-launch-btn,
    .fpa-click-catcher,
    .fpa-confetti-container {
        display: none !important;
    }

    .fpa-highlight {
        animation: none !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .fpa-elevated-parent {
        z-index: auto !important;
    }
}
