/* Chat Drawer (Slide-Over) and Chat Bubbles */

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 3rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.chat-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--text-primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.chat-avatar.plubot-avatar {
    background: linear-gradient(135deg, var(--text-primary), #a0a0a0);
}

.chat-info {
    display: flex;
    flex-direction: column;
}

.chat-info strong {
    font-size: 0.85rem;
    font-weight: 600;
}

.chat-info span {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.chat-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scroll-hide::-webkit-scrollbar {
    display: none;
}

.chat-input-area {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.chat-bubble-input {
    flex: 1;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-base);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--text-primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

/* Typing Indicator Native */
.typing-indicator {
    display: flex;
    gap: 3px;
    padding: 0.5rem;
    background: transparent;
    width: fit-content;
    align-self: flex-start;
    animation: popIn 0.3s forwards;
    padding-left: 1rem;
}

.typing-indicator span {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Slide Over Drawer Base */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.chat-drawer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    width: 92%;
    max-width: 900px;
    height: 85vh;
    max-height: 850px;
    background: rgba(15, 15, 15, 0.75);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-drawer.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(10, 10, 10, 0.6);
    z-index: 2;
}

.drawer-profile {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.drawer-profile .chat-info strong {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.drawer-profile .chat-info span {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.drawer-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    scroll-behavior: smooth;
}

.drawer-body::-webkit-scrollbar {
    width: 6px;
}

.drawer-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Premium Chat Bubbles */
.msg {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.85rem;
    line-height: 1.4;
    animation: messagePop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: bottom center;
}

@keyframes messagePop {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.msg.human,
.msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent-primary, #2ecca6), #0fa473);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 15px rgba(46, 204, 166, 0.25);
    font-weight: 500;
    border: none;
}

/* Floating Input Area */
.drawer-footer {
    padding: 1rem 1.5rem 1.5rem;
    background: transparent;
    position: relative;
}

.drawer-footer::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to top, rgba(15, 15, 15, 0.9), transparent);
    pointer-events: none;
}

#drawer-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 1rem 3.5rem 1rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) inset;
}

#drawer-input:focus {
    border-color: rgba(46, 204, 166, 0.5);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 2px rgba(46, 204, 166, 0.1), 0 4px 20px rgba(0, 0, 0, 0.3) inset;
    outline: none;
}

#drawer-send-btn {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%) translateY(-0.25rem);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
}

#drawer-input:valid+#drawer-send-btn,
#drawer-send-btn:not([disabled]) {
    background: var(--accent-primary, #2ecca6);
    color: #000;
    box-shadow: 0 2px 10px rgba(46, 204, 166, 0.4);
    transform: translateY(-50%) translateY(-0.25rem) scale(1.05);
    cursor: pointer;
}

@media (max-width: 768px) {
    .chat-drawer {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: translate(0, 100%) !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 85vh !important;
        border-radius: 32px 32px 0 0 !important;
        border: none !important;
        border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .chat-drawer.open {
        transform: translate(0, 0) !important;
    }

    .drawer-header {
        position: relative;
        padding-top: 1.5rem !important;
    }

    .drawer-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        z-index: 10;
    }
}