/* ==========================================
   BOT MASCOT 5.0 - Gestionale Smart
   Interactive, multi-page, real mini robot,
   lateral movement, GS logo, explaining state
   ========================================== */

/* ==========================================
   BASE & POSITIONING — moves between sections
   ========================================== */
.bot-mascot {
    position: fixed;
    bottom: 100px;
    right: 40px;
    left: auto;
    z-index: 8900;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                bottom 1.2s cubic-bezier(0.22, 1, 0.36, 1),
                right 1.2s cubic-bezier(0.22, 1, 0.36, 1),
                left 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.bot-mascot.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.bot-mascot.floating {
    animation: botFloating 3s ease-in-out infinite;
}

/* Lateral positions for section movement */
.bot-mascot.bot-pos-right {
    right: 40px;
    left: auto;
}

.bot-mascot.bot-pos-left {
    right: auto;
    left: 40px;
}

body.page-pricing .bot-mascot {
    right: 18px !important;
    left: auto !important;
    bottom: 24px;
}

body.page-pricing .bot-speech {
    display: none !important;
}

/* When on left side, flip speech bubble */
.bot-mascot.bot-pos-left .bot-speech {
    right: auto;
    left: -10px;
}

.bot-mascot.bot-pos-left .speech-arrow {
    right: auto;
    left: 24px;
}

/* Vertical positions */
.bot-mascot.bot-pos-high { bottom: 55vh; }
.bot-mascot.bot-pos-mid { bottom: 35vh; }
.bot-mascot.bot-pos-low { bottom: 100px; }

/* MINIMIZED — small dot, clickable to restore */
.bot-mascot.minimized {
    opacity: 1;
    pointer-events: auto;
    transform: scale(0.45);
    filter: grayscale(0.3);
    animation: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bot-mascot.minimized:hover {
    transform: scale(0.55);
    filter: grayscale(0);
}

.bot-mascot.minimized .bot-speech,
.bot-mascot.minimized .bot-shadow {
    display: none;
}

/* NUDGE — subtle bounce when section changes */
.bot-mascot.bot-nudge {
    animation: botNudge 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* MOVING — disable float while repositioning */
.bot-mascot.bot-moving {
    animation: none !important;
}

/* ==========================================
   SPEECH BUBBLE
   ========================================== */
.bot-speech {
    position: absolute;
    bottom: 100%;
    right: -10px;
    left: auto;
    background: var(--white);
    padding: 14px 16px 10px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12),
                0 0 0 1px rgba(0, 0, 0, 0.04);
    opacity: 0;
    transform: translateY(10px) scale(0.85);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-bottom: 12px;
    max-width: 280px;
    min-width: 180px;
    white-space: normal;
    word-break: break-word;
    text-align: left;
    pointer-events: none;
    z-index: 8901;
}

.bot-speech.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Close button (X) */
.bot-close-btn {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
}

.bot-close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Minimize button (bottom of bubble) */
.bot-minimize-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 4px 0;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    text-align: center;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.bot-minimize-btn:hover {
    opacity: 1;
    color: var(--primary-color);
}

/* Message text */
.bot-msg-text {
    display: block;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 8px;
    padding-right: 18px;
}

/* Quick reply buttons */
.bot-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bot-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--primary-lighter);
    border: 1px solid rgba(46, 9, 156, 0.12);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.3;
}

.bot-reply-btn i {
    font-size: 0.65rem;
}

.bot-reply-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(46, 9, 156, 0.25);
}

/* Typing indicator */
.bot-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.bot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.4;
    animation: botTypingDot 1.2s ease-in-out infinite;
}

.bot-typing span:nth-child(2) { animation-delay: 0.15s; }
.bot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes botTypingDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Legacy text style */
.speech-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    display: block;
    line-height: 1.4;
}

/* Speech arrow */
.speech-arrow {
    position: absolute;
    bottom: -8px;
    right: 24px;
    left: auto;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* ==========================================
   BOT BODY
   ========================================== */
.bot-body {
    position: relative;
    filter: drop-shadow(0 10px 20px rgba(46, 9, 156, 0.3));
    cursor: pointer;
    transition: filter 0.3s ease;
}

.bot-body:hover {
    filter: drop-shadow(0 12px 24px rgba(46, 9, 156, 0.4));
}

.bot-antenna {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 15px;
    background: linear-gradient(180deg, var(--primary-color), #7c3aed);
    border-radius: 2px;
    animation: antennaWiggle 2s ease-in-out infinite;
}

.antenna-ball {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
    animation: antennaPulse 1.5s ease-in-out infinite;
}

.bot-head {
    width: 70px;
    height: 55px;
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
    border-radius: 20px 20px 15px 15px;
    border: 3px solid var(--primary-color);
    position: relative;
    box-shadow: inset 0 -5px 15px rgba(0, 0, 0, 0.05);
}

.bot-eyes {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 12px;
}

.bot-eye {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.bot-pupil {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease;
}

.bot-mouth {
    width: 20px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 0 0 10px 10px;
    margin: 8px auto 0;
    transition: all 0.2s ease;
}

.bot-mascot.talking .bot-mouth {
    animation: mouthTalk 0.6s ease-in-out infinite;
}

.bot-torso {
    width: 60px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    border-radius: 10px 10px 15px 15px;
    margin: -3px auto 0;
    position: relative;
    box-shadow: 0 5px 15px rgba(46, 9, 156, 0.3);
}

.bot-screen {
    width: 30px;
    height: 25px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    border-radius: 5px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* GS Logo on chest (replaces heart) */
.bot-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: logoPulse 2s ease-in-out infinite;
}

.bot-logo svg {
    display: block;
}

.bot-arms {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
}

.bot-arm {
    width: 12px;
    height: 30px;
    background: linear-gradient(180deg, var(--primary-color) 0%, #7c3aed 100%);
    border-radius: 6px;
    position: absolute;
    transition: transform 0.3s ease;
}

.bot-arm.left {
    left: -8px;
    transform-origin: top center;
    transform: rotate(15deg);
}

.bot-arm.right {
    right: -8px;
    transform-origin: top center;
    transform: rotate(-15deg);
}

.bot-shadow {
    width: 50px;
    height: 15px;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    margin: 10px auto 0;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.bot-mascot.floating .bot-shadow {
    animation: shadowFloat 3s ease-in-out infinite;
}

/* ==========================================
   STATES (used by JS)
   ========================================== */

/* WAVE */
.bot-mascot.waving .bot-arm.right {
    animation: armWave 0.5s ease-in-out 3;
}

/* POINT */
.bot-mascot.pointing .bot-arm.right {
    transform: rotate(-90deg) translateX(5px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* CELEBRATE */
.bot-mascot.celebrating .bot-arm.left {
    animation: armWaveLeft 0.4s ease-in-out infinite;
}

.bot-mascot.celebrating .bot-arm.right {
    animation: armWaveRight 0.4s ease-in-out infinite;
}

.bot-mascot.celebrating .bot-mouth {
    height: 12px;
    border-radius: 10px;
    width: 16px;
}

.bot-mascot.celebrating .antenna-ball {
    animation: antennaPulse 0.5s ease-in-out infinite;
}

/* EXPLAINING — arms open wide, mouth animating */
.bot-mascot.explaining .bot-arm.left {
    transform: rotate(-45deg);
}

.bot-mascot.explaining .bot-arm.right {
    transform: rotate(45deg);
}

.bot-mascot.explaining .bot-mouth {
    animation: mouthTalk 0.8s ease-in-out infinite;
}

.bot-mascot.explaining .antenna-ball {
    animation: antennaPulse 1s ease-in-out infinite;
}

/* THINK */
.bot-mascot.thinking .bot-mouth {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
}

.bot-mascot.thinking .bot-pupil {
    animation: eyeLook 3s ease-in-out infinite;
}

/* SLEEP */
.bot-mascot.sleeping {
    animation: sleepBob 4s ease-in-out infinite;
}

.bot-mascot.sleeping .bot-eye {
    height: 3px;
    border-radius: 3px;
    overflow: visible;
}

.bot-mascot.sleeping .bot-pupil {
    display: none;
}

.bot-mascot.sleeping .bot-mouth {
    width: 12px;
    height: 4px;
    border-radius: 0 0 6px 6px;
}

.bot-mascot.sleeping::after {
    content: 'z z z';
    position: absolute;
    top: -30px;
    right: -10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-40);
    animation: sleepZzz 2s ease-in-out infinite;
    letter-spacing: 3px;
}

/* ==========================================
   MINI BOT (Mobile) — Real Robot!
   ========================================== */
.bot-mini {
    position: fixed;
    bottom: 90px;
    right: 16px;
    z-index: 8900;
    display: none;
    cursor: pointer;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.bot-mini:active .bot-mini-robot {
    transform: scale(0.92);
}

/* The actual robot structure */
.bot-mini-robot {
    position: relative;
    width: 52px;
    filter: drop-shadow(0 4px 12px rgba(46, 9, 156, 0.35));
    transition: transform 0.2s ease;
}

/* Mini antenna */
.bot-mini-antenna {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: linear-gradient(180deg, var(--primary-color), #7c3aed);
    border-radius: 1px;
    z-index: 1;
}

.bot-mini-antenna-ball {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 7px;
    height: 7px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
    animation: antennaPulse 1.5s ease-in-out infinite;
}

/* Mini head */
.bot-mini-head {
    width: 42px;
    height: 32px;
    background: linear-gradient(135deg, #fff 0%, #f3f4f6 100%);
    border-radius: 12px 12px 8px 8px;
    border: 2px solid var(--primary-color);
    margin: 0 auto;
    position: relative;
    box-shadow: inset 0 -3px 8px rgba(0, 0, 0, 0.04);
}

.bot-mini-eyes {
    display: flex;
    gap: 7px;
    justify-content: center;
    padding-top: 7px;
}

.bot-mini-eye {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    border: 1.5px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.bot-mini-pupil {
    width: 5px;
    height: 5px;
    background: var(--primary-color);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.bot-mini-mouth {
    width: 10px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 0 0 5px 5px;
    margin: 3px auto 0;
}

/* Mini body/torso */
.bot-mini-body {
    width: 36px;
    height: 22px;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    border-radius: 6px 6px 10px 10px;
    margin: -2px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(46, 9, 156, 0.3);
}

.bot-mini-body svg {
    display: block;
    opacity: 0.9;
}

/* Mobile bot bounce on section change */
.bot-mini.bot-mini-bounce .bot-mini-robot {
    animation: miniNudge 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Mobile speech — supports quick replies */
.bot-mini-speech {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--white);
    padding: 12px 14px;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12),
                0 0 0 1px rgba(0, 0, 0, 0.04);
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-800);
    max-width: 260px;
    min-width: 160px;
    white-space: normal;
    opacity: 0;
    transform: translateY(8px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.bot-mini-speech.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.bot-mini-speech::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 16px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--white);
}

.bot-mini-speech .bot-msg-text {
    font-size: 0.78rem;
    padding-right: 0;
    margin-bottom: 6px;
}

.bot-mini-speech .bot-replies {
    gap: 5px;
}

.bot-mini-speech .bot-reply-btn {
    font-size: 0.68rem;
    padding: 5px 10px;
}

/* ==========================================
   KEYFRAMES
   ========================================== */
@keyframes botFloating {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

@keyframes botNudge {
    0% { transform: scale(1); }
    30% { transform: scale(1.12); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes miniNudge {
    0% { transform: scale(1); }
    30% { transform: scale(1.15) translateY(-3px); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes shadowFloat {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(0.7); opacity: 0.15; }
}

@keyframes armWave {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(-60deg); }
}

@keyframes armWaveLeft {
    0%, 100% { transform: rotate(15deg); }
    50% { transform: rotate(-30deg); }
}

@keyframes armWaveRight {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(30deg); }
}

@keyframes antennaWiggle {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    25% { transform: translateX(-50%) rotate(10deg); }
    75% { transform: translateX(-50%) rotate(-10deg); }
}

@keyframes antennaPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(251, 191, 36, 0.6); transform: translateX(-50%) scale(1); }
    50% { box-shadow: 0 0 25px rgba(251, 191, 36, 0.9); transform: translateX(-50%) scale(1.2); }
}

@keyframes eyeLook {
    0%, 100% { transform: translate(-50%, -50%); }
    20% { transform: translate(-80%, -50%); }
    40% { transform: translate(-20%, -80%); }
    60% { transform: translate(-80%, -20%); }
    80% { transform: translate(-20%, -50%); }
}

@keyframes mouthTalk {
    0%, 100% { height: 8px; border-radius: 0 0 10px 10px; }
    10%, 30%, 50%, 70% { height: 12px; border-radius: 10px; }
    20%, 40%, 60%, 80% { height: 6px; border-radius: 0 0 8px 8px; }
}

@keyframes logoPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes sleepBob {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(3px) rotate(1deg); }
}

@keyframes sleepZzz {
    0% { opacity: 0; transform: translateY(0) scale(0.8); }
    50% { opacity: 1; transform: translateY(-10px) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(1.2); }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
    .bot-mascot {
        display: none !important;
    }

    .bot-mini {
        display: block;
    }
}

@media (min-width: 1025px) {
    .bot-mini {
        display: none !important;
    }
}
