/* =====================
   RESET & BASE
===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(0, 198, 255, 0.18), transparent 45%),
        radial-gradient(circle at bottom right, rgba(0, 114, 255, 0.18), transparent 45%),
        linear-gradient(135deg, #040b13, #0a1a28);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

/* =====================
   AI GLASS PANEL
===================== */
.chat-container {
    width: 1080px;
    max-width: 100%;
    height: 550px;
    max-height: 100%;
    background: rgba(15, 30, 45, 0.6);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: 22px;
    padding: 22px;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(0, 198, 255, 0.25),
        0 25px 60px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
}

/* =====================
   HEADER
===================== */
.header {
    text-align: center;
    margin-bottom: 10px;
    margin-top: -5px;
    position: relative;
}

.back-btn {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0, 198, 255, 0.15);
    border: 1px solid rgba(0, 198, 255, 0.35);
    color: #00c6ff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.back-btn:hover {
    background: rgba(0, 198, 255, 0.3);
    transform: translateX(-2px);
}

.back-btn:active {
    transform: scale(0.92);
}

.header .logo {
    width: 95px;
    margin-bottom: 0px;
    filter: drop-shadow(0 0 14px rgba(0, 198, 255, 0.7));
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.6px;
}

.header p {
    font-size: 12.5px;
    opacity: 0.8;
}

/* =====================
   CHAT BOX
===================== */
.chat-box {
    flex: 1;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    padding: 15px;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 1px solid rgba(0, 198, 255, 0.18);
    scroll-behavior: smooth;
}

/* MESSAGE BUBBLE */
.message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 80%;
}

/* USER */
.message.user {
    margin-left: auto;
    background: linear-gradient(135deg, #0072ff, #00c6ff);
    box-shadow: 0 0 14px rgba(0, 198, 255, 0.5);
}

/* AI */
.message.bot {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(0, 198, 255, 0.3);
    box-shadow: inset 0 0 16px rgba(0, 198, 255, 0.1);
}

/* =====================
   INPUT FIELD
===================== */
.input-container {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.input-container input {
    flex: 1;
    padding: 13px 16px;
    border-radius: 14px;
    border: 1px solid rgba(0, 198, 255, 0.35);
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    outline: none;
}

.input-container input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.input-container button {
    padding: 13px 20px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 0 18px rgba(0, 198, 255, 0.6);
    transition: 0.3s ease;
}

.input-container button:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 26px rgba(0, 198, 255, 0.9);
}

/* =====================
   HAMBURGER MENU (AI HUD)
===================== */
.hamburger-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
}


.hamburger-icon {
    cursor: pointer;
}

.hamburger-icon span {
    display: block;
    width: 26px;
    height: 3px;
    margin: 5px 0;
    border-radius: 3px;
    background: linear-gradient(90deg, #00c6ff, #0072ff);
}

/* DROPDOWN */
.menu-dropdown {
    display: none;
    width: 150px;
    position: absolute;
    right: 0;
    top: 35px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(14px);
    border-radius: 14px;
    border: 1px solid rgba(0, 198, 255, 0.35);
}

.menu-dropdown a {
    display: block;
    padding: 8px 12px;
    font-size: 14px;
    color: #ffffff;
    text-decoration: none;
    border-radius: 10px;
}

.menu-dropdown a:hover {
    background: rgba(0, 198, 255, 0.25);
}

/* =====================
   ANIMATION
===================== */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: fadeSlideUp 0.3s ease forwards;
}

/* =====================
   TYPING INDICATOR AI
===================== */
.typing {
    display: inline-flex;
    gap: 5px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(0, 198, 255, 0.3);
    width: fit-content;
}

.typing span {
    width: 6px;
    height: 6px;
    background: #00c6ff;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}

.typing span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* =====================
   LOGO AI PULSE
===================== */
.header .logo {
    animation: aiPulse 3s infinite;
}

@keyframes aiPulse {
    0% {
        filter: drop-shadow(0 0 10px rgba(0, 198, 255, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 22px rgba(0, 198, 255, 1));
    }
    100% {
        filter: drop-shadow(0 0 10px rgba(0, 198, 255, 0.6));
    }
}

/* =====================
   AI LOADER
===================== */
.ai-loader {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle, rgba(0,198,255,0.15), transparent 60%),
        linear-gradient(135deg, #040b13, #0a1a28);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: #fff;
}

.ai-core {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 2px solid rgba(0,198,255,0.25);
    position: relative;
    animation: rotateCore 3s linear infinite;
}

.ai-core::before,
.ai-core::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: #00c6ff;
    animation: rotateCoreReverse 1.5s linear infinite;
}

.ai-core::after {
    inset: 18px;
    border-top-color: #0072ff;
    animation-duration: 1s;
}

@keyframes rotateCore {
    to { transform: rotate(360deg); }
}

@keyframes rotateCoreReverse {
    to { transform: rotate(-360deg); }
}

.ai-loader p {
    margin-top: 18px;
    font-size: 14px;
    letter-spacing: 1px;
    opacity: 0.85;
    animation: pulseText 1.8s infinite;
}

@keyframes pulseText {
    0%,100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* HIDE LOADER */
.ai-loader.hide {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.menu-dropdown.show {
    display: block;
    animation: fadeSlideUp 0.25s ease;
}

.hamburger-icon.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-icon.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-icon.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.hamburger-icon span {
    transition: 0.3s ease;
}

/* INPUT LOCKED STATE */
.input-container input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-btn:disabled {
    opacity: 0.5;
    box-shadow: none;
    cursor: not-allowed;
}


/* =====================
   CUSTOM SCROLLBAR (AI STYLE)
===================== */

/* Chrome, Edge, Safari */
.chat-box::-webkit-scrollbar {
    width: 20px;
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: linear-gradient(
        180deg,
        rgba(0, 198, 255, 0.9),
        rgba(0, 114, 255, 0.9)
    );
    border-radius: 10px;
    box-shadow:
        0 0 10px rgba(0, 198, 255, 0.6),
        inset 0 0 4px rgba(255, 255, 255, 0.4);
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
        180deg,
        #00e0ff,
        #005bff
    );
}

/* Firefox */
.chat-box {
    scrollbar-width: thin;
    scrollbar-color: #00c6ff rgba(255, 255, 255, 0.05);
}

/* ===============================
   CHAT BOX SPACING FIX
================================= */

.chat-box {
    display: flex;
    flex-direction: column;
    gap: 8px;              /* lebih rapat */
    padding: 16px 18px;    /* tidak terlalu luas */
}

/* ===============================
   BASE MESSAGE
================================= */

.message {
    display: inline-block;
    max-width: 68%;
    padding: 10px 14px;     /* lebih compact */
    border-radius: 14px;
    font-family: "Inter", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
    animation: fadeIn 0.2s ease;
    margin-bottom: 2px;     /* kecil saja */
}

/* ===============================
   USER
================================= */

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #ffffff;
    border-bottom-right-radius: 6px;
}

/* ===============================
   BOT
================================= */

.message.bot {
    align-self: flex-start;
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(56, 189, 248, 0.15);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(6px);
    padding-top: 22px; /* beri ruang untuk copy button */
    padding-bottom: -22px !important;
}

/* ===============================
   COPY BUTTON FIX POSISI
================================= */

.copy-btn {
    position: absolute;
    top: 6px;
    right: 10px; /* tidak terlalu mepet */
    font-size: 10px;
    background: rgba(255,255,255,0.08);
    color: #cbd5e1;
    border: none;
    padding: 3px 7px;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.2s ease;
}

.copy-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

/* ===============================
   WHATSAPP REDIRECT BUTTON
================================= */

.message.redirect {
    align-self: center;
    text-align: center;
    width: fit-content;
    max-width: 92%;
    padding: 12px 18px;
}

/* override ruang copy-btn & margin markdown di bubble redirect */
.message.redirect.bot {
    padding-top: 12px;
    padding-bottom: 12px;
}

.message.redirect p {
    margin: 0;
}

.wa-redirect-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 12px;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: #ffffff;
    font-weight: 500;
    font-size: 11.5px;
    text-decoration: none;
    border-radius: 7px;
    box-shadow: 0 0 8px rgba(37, 211, 102, 0.35);
    transition: 0.25s ease;
}

.wa-redirect-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 16px rgba(37, 211, 102, 0.7);
}

/* ===============================
   MARKDOWN SPACING RAPAT
================================= */

.message.bot p {
    margin: 4px 0;
    margin-bottom: -10px;
}

.message.bot ul {
    margin: 4px 0;
    padding-left: 18px;
}

.message.bot li {
    margin-bottom: 3px;
}

/* ===============================
   TYPING BUBBLE
================================= */

/* === TYPING MESSAGE (IKUT STYLE BUBBLE BOT) === */
.message.typing {
    align-self: flex-start;

    display: inline-flex;         /* penting */
    width: fit-content;           /* jangan full width */
    max-width: 70%;

    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(56, 189, 248, 0.15);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(6px);
    font-size: 13px;
    animation: fadeIn 0.2s ease-in-out;
}

/* text + dots sejajar */
.typing-text {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* dots */
.typing-text span {
    width: 5px;
    height: 5px;
    background: #38bdf8;
    border-radius: 50%;
    animation: blinkSlow 1.8s infinite both;
}

/* delay animasi */
.typing-text span:nth-child(2) {
    animation-delay: 0.3s;
}

.typing-text span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes blinkSlow {
    0% { opacity: .2; }
    40% { opacity: 1; }
    100% { opacity: .2; }
}


@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* FIXED FOOTER MINI */
.vira-footer-mini {
    position: static;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 15px;
    margin-top: 10px;
    flex-shrink: 0;
    pointer-events: none;
}

.vira-footer-box {
    background: rgba(10, 25, 40, 0.85);
    backdrop-filter: blur(8px);
    padding: 10px 22px;
    border-radius: 14px;
    text-align: center;
    width: 720px;
    max-width: 100%;
    border: 1px solid rgba(0, 200, 255, 0.18);
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.08);

    pointer-events: auto;
}

/* TEXT */
.vira-footer-box p {
    margin: 0;
    font-size: 12.5px;
    color: #bfeaff;
    letter-spacing: 0.4px;
}

.vira-footer-box span {
    color: #00d4ff;
    font-weight: 600;
}

.vira-footer-box .sub {
    font-size: 11px;
    color: #7fb7cf;
    margin-top: 2px;
}


/* =====================
   RESPONSIVE MOBILE
===================== */

/* =====================
   TABLET LAYOUT (769px - 1024px)
   ===================== */
@media (min-width: 769px) and (max-width: 1024px) {

    body {
        padding: 16px;
    }

    .chat-container {
        width: 100%;
        height: calc(100dvh - 80px);
        max-height: 820px;
        padding: 18px;
    }

    .message {
        max-width: 78%;
    }

    .vira-footer-box {
        width: 100%;
        max-width: 640px;
    }
}

/* =====================
   MOBILE CHAT LAYOUT FIX
   ===================== */
@media (max-width: 768px) {

    body {
        padding: 0;
        margin: 0;
        height: 100dvh;
        overflow: hidden;
    }

    .chat-container {
        height: 100dvh;
        width: 100%;
        border-radius: 0;
        padding: 14px;
    }

    /* HEADER */
    .header {
        position: relative;
        z-index: 10;
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    /* HAMBURGER ALWAYS VISIBLE */
    .hamburger-menu {
        position: fixed;
        top: 14px;
        right: 14px;
        z-index: 20;
    }

    /* CHAT BOX FLEXIBLE (base sudah flex:1, cukup margin) */
    .chat-box {
        margin-bottom: 10px;
    }

    /* INPUT BOTTOM */
    .input-container {
        gap: 8px;
    }

    /* FOOTER ikut dalam container */
    .vira-footer-mini {
        padding: 4px 0 0;
    }

    .vira-footer-box {
        width: 100%;
        max-width: 100%;
        padding: 6px 12px;
    }

    .input-container input {
        flex: 1;
        padding: 12px 14px;
        font-size: 14px;
    }

    /* ICON BUTTON */
    .send-btn {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        box-shadow: 0 0 14px rgba(0, 198, 255, 0.8);
    }
}

/* =====================
   MOBILE KEYBOARD FIX
===================== */
input, button {
    font-size: 16px; /* cegah zoom iOS */
}

/* =====================
   EXTRA SMALL PHONE
===================== */
@media (max-width: 480px) {

    body {
        padding-bottom: 0;
        background:
            radial-gradient(circle at top, rgba(0, 198, 255, 0.22), transparent 55%),
            linear-gradient(180deg, #040b13, #0a1a28);
    }

    .header .logo {
        width: 65px;
        margin-bottom: -10px !important;
        filter: drop-shadow(0 0 14px rgba(0, 198, 255, 0.7));
    }

    .chat-container {
        border-radius: 0;
        padding: 14px;
        height: 100dvh;
    }

    .header h1 {
        margin-top: 20px;
        font-size: 16px;
    }

    .chat-box {
        padding: 10px;
    }

    .message {
        font-size: 12.5px;
        max-width: 88%;
    }

    .send-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .input-container input {
        flex: 1;
        padding: 12px 14px;
        font-size: 14px;
        min-width: 0;
    }

    .input-container button {
        padding: 12px;
    }

    .vira-footer-mini {
        padding: 4px 0 0;
    }

    .vira-footer-box {
        padding: 6px 10px;
        border-radius: 10px;
    }

    /* TEXT */
    .vira-footer-box p {
        font-size: 9px;
    }

    .vira-footer-box .sub {
        font-size: 8px;
        margin-top: 1px;
    }

}
