/* ================= ROOT ================= */
#chat360 {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ================= TOGGLE BUTTON ================= */
#chat360-toggle {
    padding: 12px 16px;
    border-radius: 999px;
    border: none;
    background: #0f172a;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0,0,0,.35);
}

/* ================= CHAT WINDOW ================= */
#chat360-window {
    display: none;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    background: #ffffff;
    border-radius: 16px;
    position: absolute;
    bottom: 60px;
    right: 0;
    box-shadow: 0 25px 60px rgba(0,0,0,.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ================= HEADER ================= */
#chat360-header {
    flex-shrink: 0;
    padding: 14px 16px;
    background: #0f172a;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#chat360-close {
    cursor: pointer;
    font-size: 20px;
}

/* ================= BODY ================= */
#chat360-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
}

/* ================= FOOTER ================= */
#chat360-footer {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

#chat360-footer input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    outline: none;
}

#chat360-footer button {
    padding: 10px 14px;
    border-radius: 10px;
    border: none;
    background: #0f172a;
    color: #fff;
    cursor: pointer;
}

/* ================= MESSAGES ================= */
.bot,
.user {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.bot {
    background: #e5e7eb;
    color: #111827;
    border-top-left-radius: 4px;
}

.user {
    background: #0f172a;
    color: #fff;
    margin-left: auto;
    border-top-right-radius: 4px;
}

/* ================= QUICK REPLIES ================= */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.qr-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
}

/* ================= TYPING ================= */
.typing {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 8px;
}

.typing span {
    animation: blink 1.4s infinite both;
}

@keyframes blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

/* ================= SKELETON ================= */
.skeleton {
    background: #f3f4f6;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.skeleton div {
    height: 10px;
    background: linear-gradient(90deg,#e5e7eb,#f3f4f6,#e5e7eb);
    margin-bottom: 8px;
    border-radius: 6px;
    animation: loading 1.2s infinite;
}

@keyframes loading {
    0% { background-position: -200px; }
    100% { background-position: 200px; }
}

/* ================= MOBILE (REAL FIX) ================= */
@media (max-width: 768px) {

    #chat360 {
        bottom: 16px;
        right: 16px;
    }

    #chat360-toggle {
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 50%;
        font-size: 20px;
    }

    #chat360-window {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh; /* IMPORTANT: dynamic viewport */
        max-width: 100vw;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }

    #chat360-body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    #chat360-footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}
