:root {
    --arytic-chat-primary: #41556F;
    /* Dark Blue */
    --arytic-chat-primary-hover: #5E7191;
    /* Light Blue-Grey */
    --arytic-chat-secondary: #66DAB5;
    /* Cyan */
    --arytic-chat-bg: rgba(255, 255, 255, 0.95);
    --arytic-chat-text: #1f2937;
    --arytic-chat-text-light: #5E7191;
    --arytic-chat-border: rgba(229, 231, 235, 0.8);
    --arytic-chat-user-msg: var(--arytic-chat-primary);
    --arytic-chat-bot-msg: #f3f4f6;
    --arytic-chat-bot-text: #1f2937;
    --arytic-chat-radius: 16px;
    --arytic-chat-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Chat Container */
#arytic-ai-chat-bot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Chat Window */
#arytic-chat-window {
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 100px);
    background: var(--arytic-chat-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--arytic-chat-border);
    border-radius: var(--arytic-chat-radius);
    box-shadow: var(--arytic-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    /* Above launcher */
    right: 0;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

/* Hide State */
#arytic-ai-chat-bot.arytic-chat-closed #arytic-chat-window {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
}

/* Header */
.arytic-chat-header {
    background: var(--arytic-chat-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.arytic-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.arytic-header-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.arytic-avatar {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#arytic-chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
    display: flex;
}

#arytic-chat-close-btn:hover {
    opacity: 1;
}

/* Messages Area */
#arytic-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

#arytic-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#arytic-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#arytic-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.arytic-message {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease forwards;
    word-wrap: break-word;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.arytic-bot-message {
    background: var(--arytic-chat-bot-msg);
    color: var(--arytic-chat-bot-text);
    align-self: flex-start;
    border-radius: 16px 16px 16px 4px;
}

.arytic-user-message {
    background: var(--arytic-chat-user-msg);
    color: white;
    align-self: flex-end;
    border-radius: 16px 16px 4px 16px;
}

/* Typing Indicator */
.arytic-typing {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    align-self: flex-start;
    background: var(--arytic-chat-bot-msg);
    border-radius: 16px 16px 16px 4px;
    animation: fadeIn 0.3s ease;
}

.arytic-typing span {
    width: 6px;
    height: 6px;
    background: var(--arytic-chat-text-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.arytic-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.arytic-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.arytic-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--arytic-chat-border);
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

#arytic-chat-input {
    flex: 1;
    border: 1px solid var(--arytic-chat-border);
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    background: #f9fafb;
    transition: border-color 0.2s;
    font-family: inherit;
    line-height: 1.4;
}

#arytic-chat-input:focus {
    border-color: var(--arytic-chat-primary);
    background: white;
}

#arytic-chat-send-btn {
    background: var(--arytic-chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0;
}

#arytic-chat-send-btn:hover {
    background: var(--arytic-chat-primary-hover);
}

#arytic-chat-send-btn:active {
    transform: scale(0.95);
}

#arytic-chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

/* Launcher Button */
#arytic-chat-launcher {
    width: 60px;
    height: 60px;
    background: var(--arytic-chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: absolute;
    bottom: 0;
    right: 0;
}

#arytic-chat-launcher:hover {
    transform: scale(1.1);
}

#arytic-ai-chat-bot:not(.arytic-chat-closed) #arytic-chat-launcher {
    transform: scale(0);
    opacity: 0;
}

.arytic-launcher-svg {
    animation: launcherFloat 3s ease-in-out infinite;
}

@keyframes launcherFloat {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

/* Interactive Robot SVG */
.arytic-robot-icon {
    display: block;
}

.arytic-robot-hand {
    transform-origin: 90px 90px;
    transform: rotate(45deg) translateY(20px) scale(0.9);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

#arytic-chat-launcher:hover .arytic-robot-hand {
    opacity: 1;
    transform: rotate(0deg) translateY(0px) scale(1.1);
    animation: aryticWaveHand 1.5s ease-in-out infinite;
    animation-delay: 0.2s;
}

@keyframes aryticWaveHand {
    0% { transform: rotate(0deg) scale(1.1); }
    20% { transform: rotate(15deg) scale(1.1); }
    40% { transform: rotate(-5deg) scale(1.1); }
    60% { transform: rotate(15deg) scale(1.1); }
    80% { transform: rotate(-5deg) scale(1.1); }
    100% { transform: rotate(0deg) scale(1.1); }
}

#arytic-chat-launcher:hover .arytic-robot-eye {
    animation: aryticBlink 2s infinite;
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes aryticBlink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #arytic-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 74px;
        right: -8px;
        /* Adjust for parent padding */
    }
}