:root {
    --aap-zindex: 9999;
}

.aap-wrapper {
    position: fixed;
    z-index: var(--aap-zindex);
    font-family: var(--aap-font-family);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.aap-wrapper * {
    box-sizing: border-box;
}

/* Positioning */
.aap-pos-bottom-right { bottom: 20px; right: 20px; align-items: flex-end; }
.aap-pos-bottom-left { bottom: 20px; left: 20px; align-items: flex-start; }

/* Toggle Button */
.aap-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--aap-primary-color);
    color: var(--aap-text-color);
    border: none;
    cursor: pointer;
    box-shadow: var(--aap-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.aap-toggle-btn:hover {
    transform: scale(1.05);
}

.aap-toggle-btn i {
    width: 28px;
    height: 28px;
}

/* Icon Animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.aap-icon-animated {
    animation: pulse 2s infinite;
}

/* Chat Window */
.aap-window {
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background: #fff;
    border-radius: var(--aap-border-radius);
    box-shadow: var(--aap-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
}

.aap-window.hidden {
    display: none;
}

/* Header */
.aap-header {
    padding: 15px;
    background-color: var(--aap-primary-color);
    color: var(--aap-text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aap-agent-name {
    font-weight: 600;
    font-size: 16px;
}

.aap-close-btn, .aap-restart-btn {
    background: none;
    border: none;
    color: var(--aap-text-color);
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

.aap-close-btn i, .aap-restart-btn i {
    width: 20px;
    height: 20px;
}

/* Messages Area */
.aap-messages-area {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bubbles */
.aap-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--aap-border-radius);
    font-size: var(--aap-font-size);
    line-height: 1.4;
    word-wrap: break-word;
}

.aap-msg-user {
    align-self: flex-end;
    background-color: var(--aap-user-bg-color);
    color: var(--aap-user-font-color);
}

.aap-msg-bot {
    align-self: flex-start;
    background-color: var(--aap-bot-bg-color);
    color: var(--aap-bot-font-color);
}

/* Input Area */
.aap-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: #fff;
}

.aap-input-field {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: var(--aap-border-radius);
    outline: none;
    font-size: var(--aap-font-size);
}

.aap-send-btn {
    background: var(--aap-primary-color);
    color: var(--aap-text-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aap-send-btn i {
    width: 24px;
    height: 24px;
}

.aap-branding {
    font-size: 10px;
    text-align: center;
    color: #aaa;
    padding: 5px;
    background: #f9f9f9;
}

/* Responsiveness */
@media (max-width: 600px) {
    .aap-window {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
    }

    .aap-wrapper {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
    }
}
