@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap");

:root {
    --primary: #3976ef;
    --primary-light: #5289f8;
    --box-light: #eee;
    --text-color: #333;
    --chatbot-primary-color: #3976ef;
}

/* Main chatbot container */
#glowchatbot {
    position: fixed;
    bottom: 50px;
    right: 30px;
    z-index: 9999999;
}

/* Chatbot toggle button */
#chatbot-toggler {
    border: none;
    display: flex;
    width: 50px;
    height: 50px;
    cursor: pointer;
    border-radius: 50%;
    background-color: var(--chatbot-primary-color);
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    padding: 0;
}

#chatbot-toggler span {
    position: absolute;
    color: #fff;
    display: block;
}

#chatbot-toggler span.close-icon {
    display: none;
}

/* Chatbot popup container */
.chatbot-popup {
    position: fixed;
    opacity: 0;
    pointer-events: none;
    right: 30px;
    bottom: 110px;
    width: 420px;
    color: var(--text-color);
    background: #fff;
    border-radius: 16px;
    font-family: Inter, sans-serif;
    transform: scale(0.2);
    transform-origin: bottom right;
    transition: all 0.2s ease;
    box-shadow: rgba(100, 100, 111, 0.2) 0 7px 29px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
}

.chatbot-popup a {
    color: var(--text-color);
}

.chatbot-popup h2 {
    font-size: 1.4rem;
    margin: 0;
	padding: 0;
}

/* Show chatbot states */
.chatbot-container.show-chatbot .chatbot-popup {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.chatbot-container.show-chatbot #chatbot-toggler span.close-icon {
    display: block;
}

.chatbot-container.show-chatbot #chatbot-toggler span:not(.close-icon) {
    display: none;
}

.chatbot-container.show-chatbot #chatbot-toggler {
    transform: rotate(90deg);
}

/* Chat header */
.chatbot-popup .chat-header {
    display: flex;
    padding: 12px;
    align-items: center;
    justify-content: space-between;
    background-color: var(--chatbot-primary-color);
    border-radius: 15px 15px 0 0;
}

.chat-header .header-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-header button {
    height: 30px;
    width: 30px;
    border: none;
    outline: none;
    color: #fff;
    padding: 0;
    background-color: var(--chatbot-primary-color);
    border-radius: 50%;
}

.chat-header button:hover {
    color: #fff;
    background-color: var(--chatbot-primary-color);
    cursor: pointer;
}

.chatbot-icon svg {
    width: 30px;
    height: 30px;
    fill: #fff;
    border-radius: 50%;
}

.header-info .logo-text {
    color: #fff;
}

/* Chat body */
.chat-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 460px;
    overflow-y: auto;
    padding: 25px 22px;
    scrollbar-width: thin;
    scrollbar-color: var(--box-light) transparent;
}

.chat-body .message {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-body .message .chatbot-icon {
    flex: 1;
}

.chat-body .message .message-text {
    padding: 12px 16px;
    max-width: 75%;
    word-wrap: break-word;
    font-size: 0.95rem;
    flex: 10;
}

.chat-body .message .message-text p {
    margin-bottom: 0;
    margin-top: 0;
	line-height: 1.4rem;
}

.chat-body .message .message-text ul {
    margin-block-start: 0;
    padding-bottom: 1rem;
    margin-bottom: 0;
    line-height: 0;
}

.chat-body .message .message-text li {
    list-style-type: none;
    line-height: 1.4;
}

.chat-body .bot-message svg {
    fill: #fff;
    width: 20px;
}

.chat-body .bot-message .message-text {
    padding: 12px;
    max-width: 100%;
    background: var(--box-light);
    border-radius: 15px 15px 15px 2px;
}

.chat-body .user-message {
    flex-direction: column;
    align-items: flex-end;
}

.chat-body .user-message .message-text {
    padding: 12px;
    max-width: 75%;
    background-color: var(--chatbot-primary-color);
    color: #fff;
    border-radius: 15px 15px 3px 15px;
}

/* Chat footer */
.chat-footer {
    position: relative;
    bottom: 0;
    width: 100%;
    background: #fff;
    padding: 15px 22px 20px;
    border-radius: 0 0 15px 15px;
}

.chat-footer .chat-form {
    display: flex;
    align-items: center;
    background: #fff;
    outline: 1px solid #ccc;
    border-radius: 25px;
    justify-content: space-between;
}

.chat-footer .chat-form:focus-within {
    outline: 1px solid var(--chatbot-primary-color);
}

.chat-form .message-input {
    border: none;
    outline: none;
    background: none;
    height: 47px;
    padding: 0 17px;
    font-size: 0.95rem;
    width: 100%;
}

.chat-form .message-input:focus {
    border: none;
}

.chat-form button {
    height: 35px;
    width: 35px;
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 1.15rem;
    margin-right: 6px;
    border-radius: 50%;
    background-color: var(--chatbot-primary-color);
    border: none;
    display: none;
    padding: 0;
}

.chat-form button:hover {
    background-color: var(--chatbot-primary-color);
}

.chat-form .message-input:valid ~ button {
    display: block;
}

/* Consent popup */
.chatbot-consent-popup {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 300px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    z-index: 999999;
    font-family: Inter, sans-serif;
}

.chatbot-consent-popup p {
    font-size: 0.9rem;
    margin-bottom: 0;
    color: var(--text-color);
    text-transform: none;
    text-align: left;
}

.chatbot-consent-popup p:last-of-type {
    margin-bottom: 15px;
}

.chatbot-consent-popup button {
    margin-right: 10px;
}

.consent-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.consent-buttons button {
    flex: 1 1 auto;
    width: calc(50% - 10px);
    text-transform: none;
}

/* Mobile responsive */
@media (max-width: 520px) {
    #chatbot-toggler {
        right: 20px;
        bottom: 20px;
    }

    .chatbot-popup {
        position: fixed;
        padding-top: env(safe-area-inset-top);
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        border-radius: 0;
        background: #fff;
    }

    .chatbot-popup .chat-header {
        border-radius: 0;
    }

    .chat-body {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }

    .chat-footer {
        width: auto;
        flex-shrink: 0;
    }
}

/* Enhanced scrollbar styling */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
    background-color: var(--box-light);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background-color: #ddd;
}

/* Message animations */
.chat-body .message {
    animation: fadeInUp 0.3s ease;
}

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

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 16px 0;
}

.typing-indicator .chatbot-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--chatbot-primary-color);
    border-radius: 50%;
}

.typing-indicator .typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--box-light);
    border-radius: 16px 16px 16px 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Error states */
.chatbot-error {
    padding: 16px 20px;
    background: #ffe0e0;
    border: 1px solid #ff5a5a;
    color: #900;
    font-weight: 500;
    border-radius: 8px;
    margin: 10px;
    text-align: center;
}

.chatbot-error strong {
    display: block;
    margin-bottom: 8px;
}

/* Loading states */
.chatbot-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chatbot-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--chatbot-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { 
        transform: rotate(0deg); 
    }
    100% { 
        transform: rotate(360deg); 
    }
}

/* Button enhancements */
#chatbot-toggler:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(57, 118, 239, 0.3);
}

.chat-form button:hover {
    transform: scale(1.05);
}

.consent-buttons button {
    padding: 10px 16px;
    border: 2px solid var(--chatbot-primary-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.consent-buttons button.accept {
    background-color: var(--chatbot-primary-color);
    color: #fff;
}

.consent-buttons button.accept:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

.consent-buttons button.decline {
    background-color: transparent;
    color: var(--chatbot-primary-color);
}

.consent-buttons button.decline:hover {
    background-color: var(--chatbot-primary-color);
    color: #fff;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --chatbot-primary-color: #0066cc;
        --text-color: #000;
        --box-light: #f0f0f0;
    }
    
    .chat-footer .chat-form {
        outline-color: #666;
    }
}

/* Focus states for accessibility */
#chatbot-toggler:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.chat-form .message-input:focus {
    outline: none;
}

.chat-form button:focus {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 2px;
}

.consent-buttons button:focus {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 2px;
}