:root {
    --edel-chat-base-color: #0073aa;
    /* Default Fallback */
}

/* Wrapper ID for Specificity */
#edel-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Floating Button */
#edel-chat-widget #edel-chat-button {
    position: fixed;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 2147483647 !important;
    /* Max Z-Index just to be sure */
    background-color: var(--edel-chat-base-color);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    transition: transform 0.2s, background 0.3s;
    border: none;
    font-size: 14px;
}

#edel-chat-widget #edel-chat-button:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

/* Chat Window */
#edel-chat-widget #edel-chat-window {
    position: fixed;
    /* Changed from absolute to fixed for better mobile handling/expand */
    bottom: 80px !important;
    right: 20px !important;
    z-index: 2147483647 !important;
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #ddd;
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Header */
#edel-chat-widget .edel-chat-header {
    background: var(--edel-chat-base-color);
    color: white;
    padding: 8px 12px;
    /* Reduced padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
    /* Slightly smaller font */
}

#edel-chat-widget .edel-chat-actions {
    display: flex;
    gap: 8px;
}

#edel-chat-widget .edel-chat-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    width: 24px;
    /* Reduced size */
    height: 24px;
    /* Reduced size */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

#edel-chat-widget .edel-chat-actions button:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Messages Area */
#edel-chat-widget #edel-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
#edel-chat-widget .edel-chat-message {
    display: flex;
    width: 100%;
}

#edel-chat-widget .edel-chat-message.user {
    justify-content: flex-end;
}

#edel-chat-widget .edel-chat-message.ai,
#edel-chat-widget .edel-chat-message.admin {
    justify-content: flex-start;
}

#edel-chat-widget .edel-chat-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-wrap: break-word;
}

#edel-chat-widget .edel-chat-bubble strong {
    font-weight: bold;
}

#edel-chat-widget .edel-chat-bubble em {
    font-style: italic;
}

#edel-chat-widget .edel-chat-bubble ul,
#edel-chat-widget .edel-chat-bubble ol {
    margin: 5px 0 5px 20px;
    padding: 0;
    list-style-type: disc;
}

#edel-chat-widget .edel-chat-bubble li {
    margin-bottom: 2px;
}

#edel-chat-widget .edel-chat-bubble p {
    margin: 0 0 5px 0;
}

#edel-chat-widget .edel-chat-message.user .edel-chat-bubble {
    background: var(--edel-chat-base-color);
    color: white;
    border-bottom-right-radius: 4px;
}

#edel-chat-widget .edel-chat-message.ai .edel-chat-bubble {
    background: #e5e5ea;
    color: #333;
    border-bottom-left-radius: 4px;
}

#edel-chat-widget .edel-chat-message.admin .edel-chat-bubble {
    background: #e1f5fe;
    color: #0277bd;
    border-bottom-left-radius: 4px;
    border: 1px solid #b3e5fc;
}

/* Input Area */
#edel-chat-widget .edel-chat-input-area {
    padding: 12px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    /* Center items vertically */
    gap: 8px;
    background: white;
}

#edel-chat-widget #edel-chat-input {
    flex: 1;
    padding: 10px 15px;
    /* Vertical padding to center text visually */
    height: 40px;
    line-height: normal;
    /* Or specific value like 1.4 */
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
    font-family: inherit;
    /* Ensure font matches */
    resize: none;
    /* Disable manual resize */
    overflow-y: auto;
    /* Allow scroll for multiple lines */
}

#edel-chat-widget #edel-chat-input:focus {
    border-color: var(--edel-chat-base-color);
}

#edel-chat-widget #edel-chat-send {
    background: var(--edel-chat-base-color);
    color: white;
    border: none;
    padding: 0 20px;
    height: 40px;
    /* Explicit height */
    line-height: normal;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: opacity 0.2s;
}

#edel-chat-widget #edel-chat-send:hover {
    opacity: 0.9;
}

/* Footer */
#edel-chat-widget .edel-chat-footer {
    padding: 8px 15px;
    background: #f5f5f5;
    text-align: right;
    font-size: 11px;
    border-top: 1px solid #eaeaea;
}

#edel-chat-widget #edel-chat-call-human,
#edel-chat-widget #edel-chat-end-human {
    background: none;
    border: none;
    color: #888;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: 11px;
}

#edel-chat-widget #edel-chat-end-human {
    color: #d63638;
}

/* Expanded Mode */
#edel-chat-widget.edel-chat-expanded #edel-chat-window {
    width: 600px;
    max-width: 90vw;
    height: 80vh;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
}

#edel-chat-widget #edel-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

/* Typing Indicator */
#edel-chat-widget .edel-chat-typing {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    align-items: center;
    background: #e5e5ea;
    /* AI/Admin color matches */
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 2px;
}

#edel-chat-widget .edel-chat-typing span {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: edelChatBounce 1.4s infinite ease-in-out both;
}

#edel-chat-widget .edel-chat-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

#edel-chat-widget .edel-chat-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes edelChatBounce {

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

    40% {
        transform: scale(1);
    }

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

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    #edel-chat-widget #edel-chat-button {
        width: 45px;
        height: 45px;
        border-radius: 50%;
        padding: 0;
        gap: 0;
        /* Remove gap to ensure centering */
        justify-content: center;
        font-size: 0;
        /* Hide "Chat" text */
        bottom: 20px;
        right: 20px;
    }

    #edel-chat-widget #edel-chat-button .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
        margin: 0;
    }

    /* Window adjustments for mobile */
    #edel-chat-widget #edel-chat-window {
        width: 90vw;
        height: 70vh;
        bottom: 90px;
        right: 5vw;
    }
}