/* SGJ Institute Smart Assistant - Chatbot CSS */

:root {
    --chat-primary: #1E5FA8; /* Academic Royal Blue */
    --chat-secondary: #0B3C5D;
    --chat-accent: #D97706; /* Golden Amber */
    --chat-bg: #FFFFFF;
    --chat-text: #1F2937;
    --chat-bot-bubble: #F3F4F6;
    --chat-user-bubble: #1E5FA8;
    --chat-user-text: #FFFFFF;
    --chat-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Hide original FAB if present */
.fab-button {
    display: none !important;
}

/* Floating Bubble */
#sgj-chat-trigger {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
}

#sgj-chat-trigger:hover {
    transform: scale(1.1) rotate(5deg);
    background: var(--chat-secondary);
}

#sgj-chat-trigger .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chat-accent);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    display: block;
}

/* Chat Window */
#sgj-chat-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    max-width: calc(100vw - 4rem);
    height: 600px;
    max-height: calc(100vh - 8rem);
    background: var(--chat-bg);
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0,0,0,0.05);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

#sgj-chat-window.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.chat-header {
    background: var(--chat-primary);
    padding: 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.bot-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-primary);
}

.chat-header-text h3 {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

.chat-header-text span {
    font-size: 0.75rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-text span::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #10B981;
    border-radius: 50%;
    display: inline-block;
}

/* Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #F9FAFB;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.chat-body::-webkit-scrollbar {
    width: 4px;
}

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

/* Messages */
.message {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    animation: messageIn 0.3s ease-out forwards;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: var(--chat-text);
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message.user {
    align-self: flex-end;
    background: var(--chat-primary);
    color: var(--chat-user-text);
    border-bottom-right-radius: 0.25rem;
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.quick-reply-btn {
    background: white;
    border: 1px solid var(--chat-primary);
    color: var(--chat-primary);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-reply-btn:hover {
    background: var(--chat-primary);
    color: white;
}

/* Footer & Input */
.chat-footer {
    padding: 1rem;
    background: white;
    border-top: 1px solid #E5E7EB;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    background: #F3F4F6;
    border-radius: 2rem;
    padding: 0.25rem 0.5rem 0.25rem 1rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.chat-input-wrapper:focus-within {
    background: white;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(30, 95, 168, 0.1);
}

.chat-footer input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.5rem 0;
    font-size: 0.9375rem;
}

.send-btn {
    width: 32px;
    height: 32px;
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: scale(1.1);
    background: var(--chat-secondary);
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 3px;
    padding: 10px 15px;
    background: white;
    border-radius: 15px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.typing span {
    width: 6px;
    height: 6px;
    background: #CBD5E1;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    #sgj-chat-window {
        right: 1rem;
        bottom: 5rem;
        width: calc(100vw - 2rem);
        height: calc(100vh - 7rem);
    }
    #sgj-chat-trigger {
        right: 1.5rem;
        bottom: 1.5rem;
    }
}
