/* ========================================================
   GIAO DIỆN HỘI THOẠI NPC QUY LÃO KAME (PHONG CÁCH NGỌC RỒNG)
   Thiết kế chuẩn phong cách game TeaMobi - Không dùng kiểu AI hiện đại
   ======================================================== */

#quylao-chat-root {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #2e1503;
}

/* --- NPC LAUNCHER STAND (THẺ NHÂN VẬT GÓC MÀN HÌNH) --- */
.quylao-launcher {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
}
.quylao-launcher:hover {
    transform: translateY(-4px) scale(1.04);
}
.quylao-launcher:active {
    transform: scale(0.96);
}

/* Khung ảnh NPC tròn chuẩn game */
.quylao-launcher-frame {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid #5a1d00;
    outline: 2px solid #ffb300;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.quylao-launcher-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}

/* Thẻ tên [NPC QUY LÃO] bên dưới */
.quylao-nametag-badge {
    background: linear-gradient(180deg, #d84315 0%, #7c2d12 100%);
    border: 1.5px solid #ffcc80;
    border-radius: 4px;
    color: #fff9c4;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 7px;
    margin-top: -8px;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 2px #000;
    white-space: nowrap;
}

/* Bong bóng lời thoại NPC Game phía trên */
.quylao-speech-bubble {
    position: absolute;
    bottom: 84px;
    right: 0;
    background: #2a1505;
    border: 2px solid #ff9800;
    border-radius: 6px;
    color: #fff3c4;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    text-shadow: 0 1px 2px #000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.quylao-speech-bubble::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 28px;
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #ff9800 transparent transparent;
}
.quylao-launcher:hover .quylao-speech-bubble,
.quylao-speech-bubble.show-hint {
    opacity: 1;
    transform: translateY(0);
}

/* --- KHUNG HỘI THOẠI NPC (NRO DIALOGUE WINDOW) --- */
.quylao-chatbox {
    position: fixed;
    bottom: 96px;
    right: 18px;
    width: 385px;
    max-width: calc(100vw - 32px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: #fffdf7;
    border: 3px solid #6b2600;
    outline: 2px solid #ffb300;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(16px);
}
.quylao-chatbox.open {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* Tiêu đề thanh Bar cửa sổ */
.quylao-header {
    background: linear-gradient(180deg, #c2410c 0%, #7c2d12 100%);
    border-bottom: 2px solid #f59e0b;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 2px 4px rgba(0,0,0,0.2);
}
.quylao-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.quylao-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid #fde047;
    background: transparent;
    object-fit: cover;
}
.quylao-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: #fffbeb;
    text-shadow: 0 1px 2px #000;
    letter-spacing: 0.3px;
}
.quylao-header-info small {
    display: block;
    font-size: 11px;
    color: #fef08a;
    font-weight: 600;
    text-shadow: 0 1px 1px #000;
}
.quylao-header-actions {
    display: flex;
    gap: 4px;
}
.quylao-btn-retro {
    background: linear-gradient(180deg, #991b1b 0%, #581010 100%);
    border: 1px solid #f87171;
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 #fca5a5, 0 1px 2px rgba(0,0,0,0.4);
    transition: filter 0.15s, transform 0.1s;
}
.quylao-btn-retro:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}
.quylao-btn-retro:active {
    transform: translateY(1px);
}

/* Nội dung hội thoại */
.quylao-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: #fffdf5 url('/event/assets/images/pattern.png') repeat;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.quylao-messages::-webkit-scrollbar {
    width: 6px;
}
.quylao-messages::-webkit-scrollbar-thumb {
    background: #d97706;
    border-radius: 3px;
}

/* Lời thoại NPC vs Người chơi */
.quylao-dialogue-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 94%;
}
.quylao-row-bot {
    align-self: flex-start;
}
.quylao-row-user {
    align-self: flex-end;
}

.quylao-speaker-label {
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.quylao-row-bot .quylao-speaker-label {
    color: #b45309;
}
.quylao-row-user .quylao-speaker-label {
    color: #7c2d12;
    justify-content: flex-end;
}

.quylao-dialogue-content {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.quylao-msg-portrait {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid #b45309;
    background: transparent;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.quylao-dialogue-box {
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.quylao-row-bot .quylao-dialogue-box {
    background: #fffbeb;
    border: 1.5px solid #fed7aa;
    color: #451a03;
}
.quylao-row-user .quylao-dialogue-box {
    background: #ffedd5;
    border: 1.5px solid #fdba74;
    color: #431407;
}

.quylao-dialogue-box a {
    color: #c2410c;
    font-weight: 700;
    text-decoration: underline;
}
.quylao-dialogue-box code {
    background: #ffeedd;
    color: #b91c1c;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px dashed #ea580c;
    font-weight: 700;
    font-size: 12px;
}
.quylao-dialogue-time {
    font-size: 10px;
    opacity: 0.65;
    margin-top: 3px;
    text-align: right;
}

/* Đang chuẩn bị bí kíp (Thay thế cho 3 chấm AI) */
.quylao-typing {
    display: none;
    align-self: flex-start;
    gap: 6px;
    align-items: center;
    padding: 6px 12px;
    background: #fffbeb;
    border: 1.5px solid #fed7aa;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #b45309;
}
.quylao-typing.active {
    display: flex;
    animation: nroFade 0.2s ease-in;
}
@keyframes nroFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- MENU TÙY CHỌN CHỨC NĂNG NPC (DẠNG MENU GAME NRO) --- */
.quylao-menu-panel {
    background: #fef3c7;
    border-top: 2px solid #fde68a;
    border-bottom: 2px solid #fde68a;
    padding: 8px 10px;
}
.quylao-menu-title {
    font-size: 11px;
    font-weight: 800;
    color: #92400e;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.quylao-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.quylao-menu-btn {
    background: linear-gradient(180deg, #ea580c 0%, #9a3412 100%);
    border: 1.5px solid #7c2d12;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 #fdba74, 0 2px 3px rgba(0,0,0,0.2);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 6px 8px;
    cursor: pointer;
    text-shadow: 0 1px 1px #000;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s ease;
}
.quylao-menu-btn:hover {
    background: linear-gradient(180deg, #f97316 0%, #c2410c 100%);
    border-color: #9a3412;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 #ffedd5, 0 3px 5px rgba(0,0,0,0.3);
}
.quylao-menu-btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

/* Khung nhập thoại */
.quylao-footer {
    padding: 8px 10px;
    background: #fffbeb;
    display: flex;
    align-items: center;
    gap: 6px;
}
.quylao-input {
    flex: 1;
    border: 1.5px solid #d97706;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    background: #ffffff;
    color: #291202;
    font-family: inherit;
}
.quylao-input:focus {
    border-color: #ea580c;
    box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.2);
}
.quylao-send-btn {
    background: linear-gradient(180deg, #ea580c 0%, #9a3412 100%);
    border: 1.5px solid #7c2d12;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 #fdba74, 0 2px 3px rgba(0,0,0,0.2);
    color: #ffffff;
    font-weight: 800;
    font-size: 12.5px;
    padding: 0 14px;
    height: 35px;
    cursor: pointer;
    text-shadow: 0 1px 1px #000;
    transition: filter 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.quylao-send-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}
.quylao-send-btn:active {
    transform: translateY(1px);
}

/* Mobile */
@media (max-width: 480px) {
    #quylao-chat-root {
        bottom: 12px;
        right: 12px;
    }
    .quylao-chatbox {
        bottom: 82px;
        right: 10px;
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
    }
    .quylao-menu-grid {
        grid-template-columns: 1fr;
    }
}
