/* Chat Drawer - Glass Neon Theme */
.chat-drawer {
    position: fixed;
    top: 64px; /* Below header */
    right: -480px; /* Hidden */
    width: 420px;
    height: calc(100vh - 64px);
    background: rgba(8, 13, 24, 0.85); /* Dark Glass */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(34, 211, 238, 0.2); /* Cyan border */
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 900; /* Below topbar (1001) but above content */
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 24px 0 0 24px;
}

.chat-drawer.open {
    right: 0;
}

/* Backdrop - mainly for mobile or focus */
.chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 899;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.chat-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(34, 211, 238, 0.03);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(34, 211, 238, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.chat-title-group h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #f8fafc;
    line-height: 1.2;
}

.chat-subtitle {
    font-size: 11px;
    color: #94a3b8;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar for messages */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 90%;
    font-size: 14px;
    line-height: 1.5;
}

.message-content {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}

/* System/AI Message */
.chat-message.system,
.chat-message.ai {
    align-self: flex-start;
}

.chat-message.system .message-content,
.chat-message.ai .message-content {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border-top-left-radius: 2px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(34, 211, 238, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22d3ee;
    flex-shrink: 0;
    border: 1px solid rgba(34, 211, 238, 0.2);
}

/* User Message */
.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.user .message-content {
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: #ccfbf1;
    border-top-right-radius: 2px;
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.05);
}

.chat-message.user .message-avatar {
    display: none; /* No avatar for user usually, or use profile pic */
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.4);
}

.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 4px 6px 4px 16px;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(34, 211, 238, 0.5);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.1);
}

#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    color: #f8fafc;
    font-size: 14px;
    resize: none;
    outline: none;
    padding: 8px 0;
    max-height: 100px;
}

.chat-send-btn {
    background: #22d3ee;
    color: #0f172a;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-left: 8px;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
}

/* Mobile Styles */
@media (max-width: 768px) {
    .chat-drawer {
        top: auto;
        bottom: -100%;
        right: 0;
        left: 0;
        width: 100%;
        height: 85vh;
        border-left: none;
        border-top: 1px solid rgba(34, 211, 238, 0.3);
        border-radius: 24px 24px 0 0;
        transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 2000; /* Higher than everything */
        max-width: 100%;
    }

    .chat-drawer.open {
        bottom: 0;
        right: 0;
    }
    
    /* Ensure backdrop is visible on mobile */
    .chat-backdrop {
        display: block; /* Base display */
        z-index: 1999;
    }
}