/* ===========================================
   ROBOT STYLES (60% SCALE)
============================================ */

/* --- Robot dengan scale 60% --- */
#robotContainer {
    transform: scale(0.6) !important;
    transform-origin: center center;
    width: 120px;
    height: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.6) !important;
    z-index: 9999;
    transition: top 1.5s ease-out, left 1.5s ease-out;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.3));
}

/* Gambar Robot */
.robot-img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.2));
    animation: floatImage 3s ease-in-out infinite;
}

/* Efek Jet Api */
.jet-flame {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 18px;
    background: linear-gradient(to top, 
        rgba(255, 100, 0, 0.9) 0%,
        rgba(255, 200, 0, 0.8) 30%,
        rgba(255, 255, 100, 0.6) 70%,
        transparent 100%);
    border-radius: 50% 50% 30% 30%;
    opacity: 0;
    z-index: -1;
    filter: blur(2px);
    transition: all 0.3s ease;
}

/* Efek Partikel Api */
.jet-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #FF5500;
    border-radius: 50%;
    bottom: -9px;
    opacity: 0;
    filter: blur(0.6px);
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-12px) scale(0.2);
        opacity: 0;
    }
}

/* Animasi mengambang */
@keyframes floatImage {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg); 
    }
    25% { 
        transform: translateY(-5px) rotate(1deg);
    }
    50% { 
        transform: translateY(-9px) rotate(0deg);
    }
    75% { 
        transform: translateY(-5px) rotate(-1deg);
    }
}

/* Efek saat hover */
#robotContainer:hover .robot-img {
    transform: scale(1.15) rotate(-5deg);
    filter: drop-shadow(0 0 15px var(--primary-color)) brightness(1.2);
}

/* ===========================================
   ROBOT DIALOG - UKURAN TULISAN DIKEMBALIKAN SEMULA
============================================ */

/* Balon Teks Dialog - UKURAN SEMULA (tidak diskalakan) */
.robot-dialog {
    position: absolute;
    /* Jarak dinaikkan karena balon makin besar */
    bottom: 170%; 
    left: 50%;
    transform: translateX(-50%) scale(0);
    
    /* --- UKURAN DIPERBESAR UTK MENGIMBANGI SCALE 0.6 --- */
    /* Target visual lebar: 220px -> CSS: 220 / 0.6 = ~370px */
    width: 370px; 
    
    /* Target visual font: 0.95rem -> CSS: 0.95 / 0.6 = ~1.6rem */
    font-size: 1.6rem !important; 
    
    padding: 15px 25px;
    border-radius: 25px;
    border: 3px solid var(--primary-color); /* Border dipertebal sedikit */
    /* -------------------------------------------------- */

    background: rgba(10, 10, 10, 0.95);
    color: var(--light-color);
    text-align: center;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    opacity: 0;
    z-index: 10001;
    box-shadow: 0 5px 25px rgba(0, 243, 255, 0.4);
    line-height: 1.4;
}

/* Segitiga di bawah balon */
.robot-dialog::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    
    /* Segitiga diperbesar */
    width: 25px;
    height: 25px;
    
    background: rgba(10, 10, 10, 0.95);
    border-bottom: 3px solid var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.robot-dialog.visible {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

/* Efek Kilatan */
.flash-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.flash {
    animation: flashAnimation 0.3s ease-out;
}

@keyframes flashAnimation {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 0.7; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(1.5); }
}

/* Trail effect */
.robot-trail {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0;
    pointer-events: none;
    z-index: 9998;
}

/* ===========================================
   CHAT ICON STYLES (Efek Mengetik Huruf dengan Jeda)
============================================ */

/* Tombol Chat */
#chatToggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: var(--dark-color);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.7);
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    animation: floatChat 4s ease-in-out infinite;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Animasi tombol mengambang */
@keyframes floatChat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ===========================================
   CHAT BUBBLE DENGAN EFEK MENGETIK PER HURUF + JEDA
============================================ */

/* Balon chat */
#chatToggle::before {
    content: '';
    position: absolute;
    top: -90px; /* Naikkan sedikit karena balon lebih besar */
    right: 0;
    width: 220px; /* Lebar ditambah sedikit */
    background-color: var(--medium-dark);
    border: 1px solid var(--primary-color);
    border-radius: 12px 12px 0 12px;
    padding: 12px 15px;
    
    /* PERUBAHAN 1: Ukuran font diperbesar */
    font-size: 0.95rem; 
    font-weight: 500; /* Sedikit lebih tebal agar terbaca */
    
    color: var(--light-color);
    text-align: left; /* Rata kiri lebih enak dibaca untuk chat */
    opacity: 0;
    transform: translateY(10px) scale(0.8);
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0, 243, 255, 0.4);
    white-space: normal;
    line-height: 1.4;
    z-index: 10000;
    
    /* Animasi dijalankan selama 10 detik (lebih santai) */
    animation: 
        chatBubbleAppear 10s ease-in-out infinite,
        typingWithPause 10s linear infinite;
        
    /* Delay dikurangi agar lebih cepat muncul pertama kali */
    animation-delay: 1s, 1s; 
}

/* Segitiga balon chat */
#chatToggle::after {
    content: '';
    position: absolute;
    top: -15px;
    right: 10px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--medium-dark);
    opacity: 0;
    pointer-events: none;
}

/* ===========================================
   ANIMASI EFEK MENGETIK YANG DIPERBAIKI
============================================ */

/* Animasi muncul-hilang balon chat */
@keyframes chatBubbleAppear {
    0% { 
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
    5% { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    /* PERUBAHAN 2: Balon tetap terlihat (opacity 1) sampai 90% durasi */
    90% { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% { 
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
}

/* Animasi teks mengetik dengan jeda setelah selesai */
@keyframes typingWithPause {
    0% { content: ''; }
    1% { content: 'H'; }
    2% { content: 'He'; }
    3% { content: 'Hel'; }
    4% { content: 'Hell'; }
    5% { content: 'Hello'; }
    6% { content: 'Hello,'; }
    7% { content: 'Hello, '; }
    8% { content: 'Hello, m'; }
    9% { content: 'Hello, ma'; }
    10% { content: 'Hello, may'; }
    11% { content: 'Hello, may '; }
    12% { content: 'Hello, may I'; }
    13% { content: 'Hello, may I '; }
    14% { content: 'Hello, may I h'; }
    15% { content: 'Hello, may I he'; }
    16% { content: 'Hello, may I hel'; }
    17% { content: 'Hello, may I help'; }
    18% { content: 'Hello, may I help '; }
    19% { content: 'Hello, may I help y'; }
    20% { content: 'Hello, may I help yo'; }
    21% { content: 'Hello, may I help you'; }
    22% { content: 'Hello, may I help you '; }
    23% { content: 'Hello, may I help you t'; }
    24% { content: 'Hello, may I help you to'; }
    25% { content: 'Hello, may I help you tod'; }
    26% { content: 'Hello, may I help you toda'; }
    27% { content: 'Hello, may I help you today'; }
    28% { content: 'Hello, may I help you today?'; }
    
    /* PERUBAHAN 3: Fase DIAM (Pause) */
    /* Dari 29% sampai 90%, teks tidak berubah (diam) agar bisa dibaca */
    90% { content: 'Hello, may I help you today?'; }
    
    /* Reset di akhir */
    100% { content: ''; }
}

/* Atur durasi animasi untuk efek mengetik dan jeda */
#chatToggle::before {
    animation: 
        chatBubbleAppear 8s ease-in-out infinite,
        typingWithPause 8s steps(30, end) infinite;
    animation-delay: 2s, 2s;
}

#chatToggle::after {
    animation: chatBubbleAppear 8s ease-in-out infinite;
    animation-delay: 2s;
}

/* Efek hover pada tombol chat */
#chatToggle:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(0, 243, 255, 1);
    animation-play-state: paused;
}

#chatToggle:hover::before {
    animation-play-state: paused;
    content: 'Hello, may I help you today?';
    opacity: 1;
    transform: translateY(0) scale(1);
}

#chatToggle:hover::after {
    animation-play-state: paused;
    opacity: 1;
}

/* ===========================================
   RESPONSIVE DESIGN
============================================ */

@media (max-width: 768px) {
    #chatToggle {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        bottom: 20px;
        right: 20px;
    }
    
    #chatToggle::before {
        width: 160px;
        font-size: 0.7rem;
        top: -70px;
        right: -10px;
    }
    
    #robotContainer {
        transform: scale(0.5) !important;
    }
    
    .robot-dialog {
        width: 350px;
        font-size: 1.8rem !important; 
        bottom: 160%;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    #robotContainer {
        transform: scale(0.4) !important;
    }
    
    .robot-dialog {
        width: 400px; /* Lebar CSS besar karena di-shrink 0.4x */
        font-size: 2.2rem !important;
        padding: 15px;
        bottom: 150%;
        border-width: 4px; /* Pertebal border di scale kecil */
    }
    
    /* Pertebal segitiga di HP */
    .robot-dialog::after {
        width: 30px;
        height: 30px;
        border-width: 4px;
        bottom: -15px;
    }
}