:root {
    --aica-primary: #1a2744;
    --aica-primary-light: #2c3e63;
    --aica-bg: #ffffff;
    --aica-bg-msg: #f0f2f5;
    --aica-text: #1a2744;
    --aica-text-light: #6b7280;
    --aica-border: #e5e7eb;
    --aica-radius: 20px;
}

#aica-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aica-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(26, 39, 68, 0.35);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
#aica-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(26, 39, 68, 0.45);
}
#aica-toggle svg { width: 26px; height: 26px; transition: transform 0.3s; }
#aica-toggle.open svg { transform: rotate(90deg); }

#aica-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-height: 540px;
    background: var(--aica-bg);
    border-radius: var(--aica-radius);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid var(--aica-border);
}
#aica-chat.visible {
    display: flex;
    animation: aica-up 0.3s ease;
}
@keyframes aica-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

#aica-inline-chat #aica-chat {
    position: relative;
    bottom: auto; right: auto;
    width: 100%; max-height: 600px;
    display: flex;
}
#aica-inline-chat #aica-toggle { display: none; }

.aica-header {
    background: var(--aica-primary);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.aica-header-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.aica-header-icon svg { width: 20px; height: 20px; }
.aica-header-info { flex: 1; min-width: 0; }
.aica-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aica-header-info span {
    font-size: 12px;
    opacity: 0.7;
    display: block;
    margin-top: 1px;
}
.aica-header-actions { display: flex; gap: 4px; }
.aica-header-actions button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.aica-header-actions button:hover { background: rgba(255,255,255,0.2); }
.aica-header-actions button svg { width: 14px; height: 14px; }

.aica-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 280px;
    max-height: 340px;
    scroll-behavior: smooth;
}
.aica-messages::-webkit-scrollbar { width: 4px; }
.aica-messages::-webkit-scrollbar-thumb { background: var(--aica-border); border-radius: 4px; }

.aica-msg {
    max-width: 84%;
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}
.aica-msg.user {
    align-self: flex-end;
    background: var(--aica-primary);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}
.aica-msg.assistant {
    align-self: flex-start;
    background: var(--aica-bg-msg);
    color: var(--aica-text);
    border-radius: 18px 18px 18px 4px;
}

.aica-quick-replies {
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 90%;
    margin-top: -2px;
}
.aica-quick-btn {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid var(--aica-border);
    font-size: 13px;
    font-family: inherit;
    color: var(--aica-text);
    cursor: pointer;
    background: var(--aica-bg);
    transition: background 0.15s, border-color 0.15s;
}
.aica-quick-btn:hover {
    background: var(--aica-bg-msg);
    border-color: var(--aica-primary);
}

.aica-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 12px 18px;
    background: var(--aica-bg-msg);
    border-radius: 18px 18px 18px 4px;
}
.aica-typing span {
    width: 7px; height: 7px;
    background: var(--aica-text-light);
    border-radius: 50%;
    animation: aica-dot 1.4s infinite both;
}
.aica-typing span:nth-child(2) { animation-delay: 0.16s; }
.aica-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes aica-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.aica-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--aica-border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    background: var(--aica-bg);
}
.aica-input-area textarea {
    flex: 1;
    border: 1px solid var(--aica-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
    background: var(--aica-bg);
    color: var(--aica-text);
    box-sizing: border-box;
}
.aica-input-area textarea:focus { border-color: var(--aica-primary); }
.aica-input-area textarea::placeholder { color: var(--aica-text-light); }

.aica-send-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--aica-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.1s;
}
.aica-send-btn:hover { opacity: 0.9; }
.aica-send-btn:active { transform: scale(0.95); }
.aica-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.aica-send-btn svg { width: 18px; height: 18px; }

.aica-footer {
    text-align: center;
    padding: 7px 12px;
    font-size: 11px;
    color: var(--aica-text-light);
    background: var(--aica-bg);
    border-top: 1px solid var(--aica-border);
}

@media (max-width: 440px) {
    #aica-chat {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 92px;
        max-height: calc(100vh - 120px);
    }
    .aica-messages { max-height: calc(100vh - 280px); }
}
