* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: #e9edf1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.chat-container {
    width: 100%;
    max-width: 450px;
    height: 100vh;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    position: relative;
}

@media (min-width: 480px) {
    .chat-container {
        height: 90vh;
        border-radius: 20px;
        overflow: hidden;
    }
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(50, 31, 89, 0.95), rgba(26, 16, 60, 0.95));
    backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #fff;
    cursor: pointer;
    margin-right: 15px;
    padding: 10px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    transition: background-color 0.3s ease;
}

.back-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.header-info {
    flex-grow: 1;
}

.header-info h2 {
    font-size: 16px;
    color: #ffffff;
    font-weight: 600;
}

.header-info .status {
    font-size: 12px;
    color: #00ff88;
    font-weight: 500;
}

.bot-avatar-header {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b2c6e, #2a1f52);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 18px;
    overflow: hidden;
}

.bot-avatar-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: white;
}

/* Chat Area */
.chat-area {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #f5f4f9;
    background-image: url('data:image/svg+xml;utf8,%3Csvg width="120" height="120" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="%233c2a65" opacity="0.04"%3E%3Cpath d="M 20 20 L 30 10 L 40 20 L 38 20 L 38 35 L 22 35 L 22 20 Z" /%3E%3Cpath d="M 70 30 L 70 40 L 90 40 L 90 33 C 90 30 87 30 85 30 L 70 30 Z M 67 25 L 70 25 L 70 42 L 67 42 Z" /%3E%3Ccircle cx="75" cy="27" r="3" /%3E%3Cpath d="M 25 75 A 12 12 0 1 0 40 90 A 15 15 0 1 1 25 75 Z" /%3E%3Cpath d="M 80 75 Q 80 85 90 85 Q 80 85 80 95 Q 80 85 70 85 Q 80 85 80 75 Z" /%3E%3Ccircle cx="55" cy="55" r="2" /%3E%3Ccircle cx="15" cy="50" r="1" /%3E%3Ccircle cx="105" cy="20" r="1.5" /%3E%3Ccircle cx="100" cy="105" r="1" /%3E%3Ccircle cx="50" cy="110" r="2" /%3E%3C/g%3E%3C/svg%3E');
    background-size: 100px 100px;
}

/* Messages */
.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease-in-out;
}

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bot-avatar {
    width: 35px;
    height: 35px;
    background: #3b2c6e;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 14px;
    margin-right: 10px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: white;
}

.user-message .bot-avatar {
    display: none;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.message-content p {
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 18px;
}

.bot-message .message-content p {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #eef2f6;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.user-message .message-content p {
    background-color: #eef5b3; /* Light yellow from reference */
    color: #333;
    border-top-right-radius: 4px;
}

/* Inline Keyboard (Buttons) */
.inline-keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

.inline-btn {
    background-color: #3b2c6e;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
    text-decoration: none;
}

.inline-btn:hover {
    background-color: #2a1f52;
}

/* Image Grids */
.image-gallery {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    max-width: 100%;
    overflow: hidden;
    border-radius: 12px;
}

.image-item {
    flex: 1;
    height: 120px;
    background-color: #eee;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-image {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    background: #fafafa;
}

.typing-indicator.hidden {
    display: none;
}

.bot-avatar.small {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.dots {
    display: flex;
    gap: 4px;
    background: white;
    padding: 8px 12px;
    border-radius: 15px;
    border: 1px solid #eef2f6;
}

.dots span {
    width: 6px;
    height: 6px;
    background-color: #a0a0a0;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.dots span:nth-child(1) { animation-delay: 0s; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

/* Input Area */
.chat-input-area {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #f0f0f0;
    gap: 10px;
    flex-shrink: 0;
}

.attach-btn {
    background: #f5f5f5;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #666;
    cursor: pointer;
    font-size: 16px;
}

.cmd-btn {
    background: #f5f5f5;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #00b35f;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}
.cmd-btn:hover {
    background: #e0e0e0;
}

.cmd-popup {
    position: absolute;
    bottom: 75px; 
    left: 20px;
    background: white;
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    box-sizing: border-box;
    width: 270px;
    z-index: 1000;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom left;
    transform: scale(1);
    opacity: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cmd-popup.hidden {
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
}
.cmd-item {
    background: #3b2c6e;
    color: white;
    padding: 12px 15px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background 0.2s, transform 0.1s;
}
.cmd-item:hover {
    background: #4a388c;
    transform: scale(1.02);
}

#messageInput {
    flex-grow: 1;
    border: 1px solid #eef2f6;
    background: #f9f9f9;
    padding: 12px 15px;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 100px;
}

.send-btn {
    background: none;
    border: none;
    color: #3b2c6e;
    font-size: 20px;
    cursor: pointer;
    padding: 10px;
}

/* Media Gallery Styles */
.media-gallery {
    display: grid;
    gap: 4px;
    border-radius: 12px;
    overflow: hidden;
    margin: 5px 0 10px 0;
    width: 100%;
    max-width: 280px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.media-gallery.layout-1 {
    grid-template-columns: 1fr;
}
.media-gallery.layout-1 .gallery-item {
    height: 180px;
}

.media-gallery.layout-2 {
    grid-template-columns: 1fr 1fr;
}
.media-gallery.layout-2 .gallery-item {
    height: 140px;
}

.media-gallery.layout-3 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 180px;
}
.media-gallery.layout-3 .gallery-item {
    height: 100%;
}
.media-gallery.layout-3 .gallery-item:nth-child(1) {
    grid-row: span 2;
}

.gallery-item {
    position: relative;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
    background: #e0e0e0;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.more-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}
.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80%;
    border-radius: 8px;
    object-fit: contain;
}
.lightbox-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}
.lightbox-prev, .lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: none;
}
.lightbox-prev { left: 15px; }
.lightbox-next { right: 15px; }
.lightbox-prev:hover, .lightbox-next:hover { background-color: rgba(0,0,0,0.8); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* =========================================
   Serbuk Glitter Mengkilat (Shiny Glitter) 
   ========================================= */
.chat-header::before, 
.bot-avatar-header::before, 
.bot-avatar::before, 
.inline-btn::before, 
.send-btn::before,
.user-message .message-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    background-image: 
        url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Ccircle cx="20" cy="30" r="1.5" fill="white" opacity="0.8"/%3E%3Ccircle cx="150" cy="40" r="1" fill="white" opacity="0.6"/%3E%3Ccircle cx="80" cy="120" r="2" fill="white" opacity="0.9"/%3E%3Ccircle cx="40" cy="160" r="1.5" fill="white" opacity="0.7"/%3E%3Ccircle cx="180" cy="170" r="1" fill="white" opacity="0.5"/%3E%3Ccircle cx="110" cy="190" r="1.5" fill="white" opacity="0.8"/%3E%3Ccircle cx="90" cy="50" r="1" fill="white" opacity="0.6"/%3E%3Ccircle cx="160" cy="100" r="1.5" fill="white" opacity="0.9"/%3E%3Ccircle cx="120" cy="70" r="1" fill="white" opacity="0.8"/%3E%3Ccircle cx="30" cy="100" r="2" fill="white" opacity="0.7"/%3E%3Cpath d="M 140 20 Q 140 40 160 40 Q 140 40 140 60 Q 140 40 120 40 Q 140 40 140 20 Z" fill="white" opacity="0.9"/%3E%3Cpath d="M 60 130 Q 60 145 75 145 Q 60 145 60 160 Q 60 145 45 145 Q 60 145 60 130 Z" fill="white" opacity="0.8"/%3E%3C/svg%3E'),
        url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Ccircle cx="40" cy="10" r="1" fill="white" opacity="0.8"/%3E%3Ccircle cx="110" cy="20" r="1.5" fill="white" opacity="0.6"/%3E%3Ccircle cx="190" cy="60" r="1" fill="white" opacity="0.9"/%3E%3Ccircle cx="50" cy="80" r="1.5" fill="white" opacity="0.7"/%3E%3Ccircle cx="15" cy="140" r="1" fill="white" opacity="0.5"/%3E%3Ccircle cx="170" cy="150" r="1.5" fill="white" opacity="0.8"/%3E%3Ccircle cx="130" cy="180" r="1" fill="white" opacity="0.6"/%3E%3Ccircle cx="90" cy="110" r="1.5" fill="white" opacity="0.9"/%3E%3Ccircle cx="80" cy="40" r="1" fill="white" opacity="0.8"/%3E%3Ccircle cx="160" cy="130" r="1.5" fill="white" opacity="0.7"/%3E%3Cpath d="M 100 80 Q 100 90 110 90 Q 100 90 100 100 Q 100 90 90 90 Q 100 90 100 80 Z" fill="white" opacity="0.9"/%3E%3C/svg%3E');
    background-size: 100px 100px, 80px 80px;
    z-index: 1;
    opacity: 0.8;
    mix-blend-mode: overlay;
    animation: twinkleStars 3s infinite alternate ease-in-out;
}

@keyframes twinkleStars {
    0% { opacity: 0.3; transform: scale(1); }
    100% { opacity: 0.9; transform: scale(1.05); }
}

/* Acak posisi bintang agar tidak sejajar tiap tombol */
.inline-btn:nth-child(1)::before { background-position: 10px 20px, 30px 40px; }
.inline-btn:nth-child(2)::before { background-position: 50px 70px, 10px 90px; }
.inline-btn:nth-child(3)::before { background-position: 80px 10px, 60px 30px; }
.inline-btn:nth-child(4)::before { background-position: 20px 60px, 90px 80px; }
.inline-btn:nth-child(5)::before { background-position: 40px 90px, 20px 10px; }
.inline-btn:nth-child(6)::before { background-position: 70px 50px, 80px 20px; }
.inline-btn:nth-child(7)::before { background-position: 30px 80px, 40px 60px; }

.chat-header, 
.bot-avatar-header, 
.bot-avatar, 
.inline-btn, 
.send-btn,
.user-message .message-content {
    position: relative;
    overflow: hidden;
}

.chat-header > *, 
.bot-avatar-header > *, 
.bot-avatar > *, 
.inline-btn > *, 
.send-btn > *,
.user-message .message-content > * {
    position: relative;
    z-index: 2;
}

/* =========================================
   Loading Screen Animation
   ========================================= */
#loading-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #2a1f52, #1a103c);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}
#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}
.loader-scene {
    width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}
.loader-scene h2 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 60px;
    background: linear-gradient(135deg, #00FF88, #00b35f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.loader-track {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-bottom: 25px;
}
.loader-progress {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    background-color: #00FF88;
    background-image: repeating-linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.4),
        rgba(255, 255, 255, 0.4) 6px,
        transparent 6px,
        transparent 12px
    );
    background-size: 17px 100%;
    border-radius: 3px;
    width: 0%;
    animation: fillBar 2s ease-in-out forwards, moveStripes 0.5s linear infinite;
    box-shadow: 0 0 10px rgba(0,255,136,0.5);
}
.loader-character {
    position: absolute;
    bottom: 12px;
    left: 0%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    animation: flyKey 2s ease-in-out forwards;
}
.key-avatar {
    font-size: 35px;
    color: #FFD700; /* Gold */
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}
.loader-destination {
    position: absolute;
    bottom: -3px; /* sits on the track */
    right: -30px;
    display: flex;
    justify-content: center;
}
.css-house {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.roof {
    width: 0; height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 20px solid rgba(255,255,255,0.4);
}
.house-body {
    width: 32px;
    height: 30px;
    background: rgba(255,255,255,0.4);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
}
.door-closed, .door-open {
    font-size: 26px;
    position: absolute;
    bottom: -1px;
}
.door-closed {
    color: #1a103c; /* Match dark theme */
    animation: hideDoor 2s forwards;
}
.door-open {
    color: #00FF88; /* Bright glow */
    opacity: 0;
    animation: showDoor 2s forwards;
    filter: drop-shadow(0 0 10px rgba(0,255,136,0.8));
}
@keyframes fillBar {
    0% { width: 0%; }
    85%, 100% { width: 100%; }
}
@keyframes moveStripes {
    0% { background-position: 0 0; }
    100% { background-position: 17px 0; }
}
@keyframes flyKey {
    0% { left: 0%; transform: translateX(-50%) rotate(-20deg) translateY(0); }
    25% { left: 25%; transform: translateX(-50%) rotate(20deg) translateY(-5px); }
    50% { left: 50%; transform: translateX(-50%) rotate(-20deg) translateY(0); }
    75% { left: 75%; transform: translateX(-50%) rotate(20deg) translateY(-5px); }
    85%, 100% { left: 100%; transform: translateX(-50%) rotate(0deg) translateY(0); }
}
@keyframes hideDoor {
    0%, 84% { opacity: 1; }
    85%, 100% { opacity: 0; }
}
@keyframes showDoor {
    0%, 84% { opacity: 0; }
    85%, 100% { opacity: 1; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseLogo {
    0% { transform: scale(0.95); opacity: 0.8; }
    100% { transform: scale(1.05); opacity: 1; }
}
