/* Floating AI Chatbot Mascot — Robot Nón Lá Ngữ Văn phong cách AI hiện đại & Animation mượt */

.ricky-ai-launcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    text-decoration: none !important;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.ricky-ai-mascot-wrap {
    position: relative;
    width: 84px;
    height: 84px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), filter 0.28s ease;
    filter: drop-shadow(0 8px 18px rgba(20, 56, 55, 0.22));
    will-change: transform;
}

/* Sóng năng lượng AI tỏa nhẹ phía sau mascot */
.ricky-ai-aura-pulse {
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(94, 234, 212, 0.26) 0%, rgba(44, 95, 93, 0) 70%);
    border: 1.5px solid rgba(94, 234, 212, 0.48);
    animation: rickyBotAuraPulse 3s cubic-bezier(0.22, 1, 0.36, 1) infinite;
    pointer-events: none;
}

.ricky-bot-svg {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* 1. Vòng hào quang AI xoay chậm sau lưng */
.ricky-bot-ring {
    transform-box: view-box;
    transform-origin: 64px 68px;
    animation: rickyBotRingSpin 14s linear infinite;
}

/* 2. Toàn bộ mascot bay lơ lửng mượt */
.ricky-bot-float {
    animation: rickyBotFloat 3.4s ease-in-out infinite;
    will-change: transform;
}

/* 3. Bóng đổ co giãn đồng bộ nhịp bay */
.ricky-bot-shadow {
    transform-box: fill-box;
    transform-origin: center;
    animation: rickyBotShadow 3.4s ease-in-out infinite;
}

/* 4. Đầu + Nón lá nghiêng nhẹ sinh động */
.ricky-bot-head {
    transform-box: view-box;
    transform-origin: 64px 76px;
    animation: rickyBotHeadTilt 4.8s ease-in-out infinite;
}

/* 5. Đôi mắt LED tự chớp tự nhiên */
.ricky-bot-eye-left,
.ricky-bot-eye-right-open {
    transform-box: fill-box;
    transform-origin: center;
    animation: rickyBotBlink 4.2s ease-in-out infinite;
    transition: opacity 0.16s ease;
}

/* Mắt nháy wink khi hover */
.ricky-bot-eye-right-wink {
    opacity: 0;
    transition: opacity 0.16s ease;
}

/* 6. Tay phải vẫy chào thân thiện */
.ricky-bot-wave-arm {
    transform-box: view-box;
    transform-origin: 84.5px 83.5px;
    animation: rickyBotWave 2.8s ease-in-out infinite;
}

/* 7. Lõi AI trên ngực thở ánh sáng */
.ricky-bot-core {
    transform-box: fill-box;
    transform-origin: center;
    animation: rickyBotCorePulse 2.4s ease-in-out infinite;
}

/* 8. Hạt sáng AI bay lên từ quyển sách mở */
.ricky-book-spark {
    transform-box: fill-box;
    transform-origin: center;
}

.ricky-book-spark.spark-1 {
    animation: rickyBookSparkRise 2.6s ease-in-out infinite;
}

.ricky-book-spark.spark-2 {
    animation: rickyBookSparkRise 2.9s ease-in-out infinite 0.85s;
}

.ricky-book-spark.spark-3 {
    animation: rickyBookSparkRise 2.4s ease-in-out infinite 1.5s;
}

/* 9. Sao AI lấp lánh bên góc nón */
.ricky-bot-spark-top {
    transform-box: fill-box;
    transform-origin: center;
    animation: rickyBotTwinkle 2.6s ease-in-out infinite;
}

.ricky-bot-spark-dot {
    transform-box: fill-box;
    transform-origin: center;
    animation: rickyBotTwinkle 2.6s ease-in-out infinite 1.1s;
}

/* ==================== HOVER / FOCUS / ACTIVE ==================== */

.ricky-ai-launcher:hover .ricky-ai-mascot-wrap,
.ricky-ai-launcher:focus-visible .ricky-ai-mascot-wrap {
    transform: translateY(-5px) scale(1.08);
    filter: drop-shadow(0 14px 24px rgba(24, 68, 67, 0.34));
}

.ricky-ai-launcher:hover .ricky-bot-ring,
.ricky-ai-launcher:focus-visible .ricky-bot-ring {
    animation-duration: 5s;
}

.ricky-ai-launcher:hover .ricky-bot-wave-arm,
.ricky-ai-launcher:focus-visible .ricky-bot-wave-arm {
    animation: rickyBotWaveFast 0.85s ease-in-out infinite;
}

/* Nháy mắt wink vui vẻ khi hover */
.ricky-ai-launcher:hover .ricky-bot-eye-right-open,
.ricky-ai-launcher:focus-visible .ricky-bot-eye-right-open {
    opacity: 0;
}

.ricky-ai-launcher:hover .ricky-bot-eye-right-wink,
.ricky-ai-launcher:focus-visible .ricky-bot-eye-right-wink {
    opacity: 1;
}

.ricky-ai-launcher:active .ricky-ai-mascot-wrap {
    transform: scale(0.95);
}

/* Badge AI hiện đại */
.ricky-ai-launcher-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    z-index: 4;
    padding: 2px 7px;
    border-radius: 99px;
    background: linear-gradient(135deg, #1E4F4D 0%, #2C5F5D 55%, #E07A5F 100%);
    color: #FFFFFF;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.07em;
    line-height: 1.2;
    border: 1.8px solid #FFFFFF;
    box-shadow: 0 3px 10px rgba(24, 58, 57, 0.35);
}

/* Tooltip thanh lịch trên Desktop */
.ricky-ai-launcher-tooltip {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    background: linear-gradient(135deg, #142626 0%, #1E3938 100%);
    color: #F4FAFA;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid rgba(141, 230, 221, 0.24);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 26px rgba(13, 30, 30, 0.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.22s ease;
}

.ricky-ai-tooltip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5EEAD4;
    box-shadow: 0 0 8px #5EEAD4;
    flex-shrink: 0;
}

.ricky-ai-launcher-tooltip::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1E3938;
}

.ricky-ai-launcher:hover .ricky-ai-launcher-tooltip,
.ricky-ai-launcher:focus-visible .ricky-ai-launcher-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* ==================== KEYFRAMES ==================== */

@keyframes rickyBotFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4.5px);
    }
}

@keyframes rickyBotShadow {
    0%, 100% {
        transform: scaleX(1);
        opacity: 0.9;
    }
    50% {
        transform: scaleX(0.84);
        opacity: 0.55;
    }
}

@keyframes rickyBotRingSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes rickyBotAuraPulse {
    0% {
        transform: scale(0.88);
        opacity: 0.65;
    }
    70% {
        transform: scale(1.24);
        opacity: 0;
    }
    100% {
        transform: scale(1.24);
        opacity: 0;
    }
}

@keyframes rickyBotHeadTilt {
    0%, 100% {
        transform: rotate(0deg);
    }
    30% {
        transform: rotate(-2.5deg);
    }
    70% {
        transform: rotate(2.2deg);
    }
}

@keyframes rickyBotBlink {
    0%, 44%, 49%, 92%, 100% {
        transform: scaleY(1);
    }
    46.5% {
        transform: scaleY(0.12);
    }
}

@keyframes rickyBotWave {
    0%, 60%, 100% {
        transform: rotate(0deg);
    }
    68% {
        transform: rotate(-14deg);
    }
    76% {
        transform: rotate(8deg);
    }
    84% {
        transform: rotate(-12deg);
    }
    92% {
        transform: rotate(4deg);
    }
}

@keyframes rickyBotWaveFast {
    0%, 100% {
        transform: rotate(0deg);
    }
    35% {
        transform: rotate(-16deg);
    }
    70% {
        transform: rotate(10deg);
    }
}

@keyframes rickyBotCorePulse {
    0%, 100% {
        transform: scale(0.95);
        opacity: 0.92;
    }
    50% {
        transform: scale(1.08);
        opacity: 1;
    }
}

@keyframes rickyBookSparkRise {
    0% {
        transform: translateY(4px) scale(0.55);
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    75% {
        opacity: 0.85;
    }
    100% {
        transform: translateY(-9px) scale(1.05);
        opacity: 0;
    }
}

@keyframes rickyBotTwinkle {
    0%, 100% {
        transform: scale(0.75) rotate(0deg);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.16) rotate(14deg);
        opacity: 1;
    }
}

/* ==================== MOBILE & ACCESSIBILITY ==================== */

@media (max-width: 767px) {
    .ricky-ai-launcher {
        right: 10px;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .ricky-ai-mascot-wrap {
        width: 68px;
        height: 68px;
    }

    .ricky-ai-launcher-badge {
        font-size: 8.5px;
        padding: 1.5px 5.5px;
        bottom: 1px;
        right: 1px;
    }

    .ricky-ai-launcher-tooltip {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ricky-ai-aura-pulse,
    .ricky-bot-ring,
    .ricky-bot-float,
    .ricky-bot-shadow,
    .ricky-bot-head,
    .ricky-bot-eye-left,
    .ricky-bot-eye-right-open,
    .ricky-bot-wave-arm,
    .ricky-bot-core,
    .ricky-book-spark,
    .ricky-bot-spark-top,
    .ricky-bot-spark-dot {
        animation: none !important;
    }
}
