/* =============================================
   DevBot — Floating Chatbot Widget
   ============================================= */

#devbot-wrap {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

/* ── Bubble button ── */
#devbot-bubble {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}



#devbot-bubble:hover {
    transform: scale(1.08);
    background: none;
    box-shadow: none;
}

#devbot-bubble:focus,
#devbot-bubble:active,
#devbot-bubble:focus-visible {
    outline: none;
    background: none;
    box-shadow: none;
}


#devbot-window {
    width: 340px;
    height: 520px;
    max-height: 520px;
    background: rgba(10, 18, 32, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 194, 178, 0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

#devbot-window.devbot-open {
    display: flex;
}

/* ── Genie group: wraps mascot + chat window, drives the whole animation ── */
#devbot-genie-group {
    transform-origin: bottom right;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    /* hidden by default — JS shows it */
    display: none;
}

#devbot-genie-group.devbot-genie-in {
    display: flex;
    animation: devbot-genie-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#devbot-genie-group.devbot-genie-out {
    display: flex;
    animation: devbot-genie-out 0.42s cubic-bezier(0.6, 0, 0.9, 0.3) both;
}

/*
  Genie-in:
  - Starts as a tiny squished sliver at the bottom-right (the bubble origin)
  - clip-path narrows the bottom neck, widens as it rises
  - Combined with scaleY + skewX for the classic lamp-genie wisp shape
*/
@keyframes devbot-genie-in {
    0% {
        opacity: 0;
        clip-path: polygon(
            40% 100%, 60% 100%,
            70% 100%, 30% 100%
        );
        transform: translateY(80px) scaleY(0.05) scaleX(0.35) skewX(18deg);
        filter: blur(6px) brightness(1.6);
    }
    20% {
        opacity: 0.6;
        clip-path: polygon(
            25% 100%, 75% 100%,
            85% 60%,  15% 60%
        );
        transform: translateY(45px) scaleY(0.35) scaleX(0.6) skewX(10deg);
        filter: blur(3px) brightness(1.3);
    }
    45% {
        opacity: 0.9;
        clip-path: polygon(
            10% 100%, 90% 100%,
            96% 20%,  4%  20%
        );
        transform: translateY(10px) scaleY(0.75) scaleX(0.88) skewX(4deg);
        filter: blur(1px);
    }
    65% {
        clip-path: polygon(
            2% 100%, 98% 100%,
            100% 0%,  0%  0%
        );
        transform: translateY(-8px) scaleY(1.06) scaleX(0.96) skewX(-2deg);
        filter: blur(0);
    }
    82% {
        clip-path: polygon(
            0% 100%, 100% 100%,
            100% 0%, 0% 0%
        );
        transform: translateY(4px) scaleY(0.98) scaleX(1.01) skewX(1deg);
    }
    100% {
        clip-path: polygon(
            0% 100%, 100% 100%,
            100% 0%, 0% 0%
        );
        transform: translateY(0) scaleY(1) scaleX(1) skewX(0deg);
        filter: blur(0);
        opacity: 1;
    }
}

/* Genie-out: reverses — collapses back into the bubble */
@keyframes devbot-genie-out {
    0% {
        opacity: 1;
        clip-path: polygon(
            0% 100%, 100% 100%,
            100% 0%, 0% 0%
        );
        transform: translateY(0) scaleY(1) scaleX(1) skewX(0deg);
        filter: blur(0);
    }
    25% {
        clip-path: polygon(
            2% 100%, 98% 100%,
            100% 0%, 0% 0%
        );
        transform: translateY(6px) scaleY(0.92) scaleX(1.04) skewX(-3deg);
    }
    55% {
        opacity: 0.7;
        clip-path: polygon(
            12% 100%, 88% 100%,
            94% 30%, 6% 30%
        );
        transform: translateY(35px) scaleY(0.5) scaleX(0.7) skewX(8deg);
        filter: blur(2px);
    }
    100% {
        opacity: 0;
        clip-path: polygon(
            42% 100%, 58% 100%,
            65% 100%, 35% 100%
        );
        transform: translateY(80px) scaleY(0.04) scaleX(0.3) skewX(16deg);
        filter: blur(6px) brightness(1.5);
    }
}

/* ── Bubble ring pulse on open ── */
#devbot-bubble.devbot-bubble-pulse::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(0, 194, 178, 0.6);
    animation: devbot-ring-pulse 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes devbot-ring-pulse {
    0%   { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ── Header ── */
#devbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(0, 194, 178, 0.55), rgba(0, 119, 182, 0.55));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

#devbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
}

#devbot-avatar {
    font-size: 1.4rem;
    line-height: 1;
}

#devbot-header-info strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}

#devbot-status {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

#devbot-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
}

#devbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#devbot-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ── Messages ── */
#devbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
    min-height: 0;
}

#devbot-messages::-webkit-scrollbar {
    width: 4px;
}

#devbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#devbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.devbot-msg {
    display: flex;
    max-width: 88%;
    animation: devbot-msg-in 0.2s ease;
}

@keyframes devbot-msg-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.devbot-msg-bot {
    align-self: flex-start;
}

.devbot-msg-user {
    align-self: flex-end;
}

.devbot-msg span {
    padding: 0.55rem 0.85rem;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.55;
}

.devbot-msg-bot span {
    background: rgba(255, 255, 255, 0.09);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.07);
    color: #e8f0fe;
    border-bottom-left-radius: 4px;
}

.devbot-msg-user span {
    background: linear-gradient(135deg, #00c2b2, #0077b6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Choices ── */
#devbot-choices {
    padding: 0.6rem 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(5, 12, 24, 0.97);
    min-height: 80px;
    max-height: 220px;
    overflow-y: auto;
    transition: min-height 0.2s ease;
}

#devbot-choices::-webkit-scrollbar {
    width: 4px;
}

#devbot-choices::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.devbot-choice {
    background: rgba(30, 42, 65, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #e0eaff;
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 0.82rem;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.devbot-choice:hover {
    background: rgba(0, 194, 178, 0.3);
    border-color: rgba(0, 194, 178, 0.6);
    color: #fff;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    #devbot-window {
        width: calc(100vw - 2rem);
        max-height: 70vh;
    }

    #devbot-wrap {
        bottom: 1rem;
        right: 1rem;
    }
}

/* ── Mascot peek ── */
#devbot-mascot-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 3;
    width: 340px;
    height: 340px;
    overflow: hidden;
    margin-bottom: -210px;
    pointer-events: none;
    /* No standalone animation — parent #devbot-genie-group drives it */
}

#devbot-speech-bubble {
    pointer-events: all;
}

/* .devbot-mascot-visible kept for JS compatibility but group controls visibility */
#devbot-mascot-wrap.devbot-mascot-visible {
    display: flex;
}

#devbot-mascot-frame {
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    position: relative;
    z-index: 4;
    overflow: hidden;
}

#devbot-mascot,
#devbot-mascot-back {
    width: 150px;
    height: 150px;
    object-fit: contain;
    object-position: center top;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

#devbot-mascot {
    filter: drop-shadow(0 -4px 10px rgba(0, 0, 0, 0.35));
    z-index: 2;
}

#devbot-mascot-back {
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

#devbot-speech-bubble {
    background: #fff;
    color: #1a1a2e;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    white-space: normal;
    text-align: center;
    max-width: 260px;
    position: relative;
    z-index: 10;
    margin-bottom: 0.5rem;
    align-self: center;
    animation: devbot-bubble-in 0.4s ease 0.25s both;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes devbot-bubble-in {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(6px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#devbot-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fff;
    border-bottom: none;
}