.cria-chat-root {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cria-chat-root.cria-mode-float.cria-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.cria-chat-root.cria-mode-float.cria-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.cria-chat-root.cria-mode-inline {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 20px auto;
}

/* Toggle Button */
.cria-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    color: #fff;
}

.cria-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.cria-mode-inline .cria-toggle {
    display: none;
}

/* Chat Box */
.cria-box {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 520px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.cria-box.cria-open {
    display: flex;
}

.cria-mode-float.cria-position-bottom-left .cria-box {
    right: auto;
    left: 0;
}

.cria-mode-inline .cria-box {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 480px;
    border-radius: 16px;
    display: flex;
}

/* Header */
.cria-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.cria-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    flex-shrink: 0;
}

.cria-header-info {
    flex: 1;
    min-width: 0;
}

.cria-header-info h4 {
    margin: 0;
    font-size: 0.95em;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cria-header-info span {
    font-size: 0.78em;
    opacity: 0.85;
    color: #fff;
}

.cria-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2em;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.cria-close:hover {
    opacity: 1;
}

/* Messages */
.cria-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cria-msg {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 0.9em;
    line-height: 1.45;
    word-wrap: break-word;
    animation: cria-fadein 0.2s ease;
}

@keyframes cria-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cria-msg-user {
    align-self: flex-end;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cria-msg-bot {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.cria-msg p {
    margin: 0 0 6px 0;
}

.cria-msg p:last-child {
    margin-bottom: 0;
}

/* Typing */
.cria-typing {
    align-self: flex-start;
    padding: 12px 16px;
    border-radius: 14px;
    display: none;
    gap: 4px;
    align-items: center;
}

.cria-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    animation: cria-bounce 1.4s infinite ease-in-out both;
}

.cria-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cria-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes cria-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.cria-input-area {
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.cria-input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 24px;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    color: #212121;
}

.cria-input:focus {
    border-color: var(--cria-primary, #2e7d32);
}

.cria-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    color: #fff;
    font-size: 1.1em;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cria-send:hover {
    transform: scale(1.05);
}

.cria-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Powered By */
.cria-powered {
    text-align: center;
    padding: 6px;
    font-size: 0.65em;
    opacity: 0.6;
    flex-shrink: 0;
}

/* Dark Theme */
.cria-theme-dark .cria-box {
    background: #1e1e1e;
    border-color: #333;
}

.cria-theme-dark .cria-header {
    color: #fff;
}

.cria-theme-dark .cria-messages {
    background: #1e1e1e;
}

.cria-theme-dark .cria-msg-bot {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #3a3a3a;
}

.cria-theme-dark .cria-input {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
}

.cria-theme-dark .cria-input-area {
    background: #1e1e1e;
    border-color: #333;
}

.cria-theme-dark .cria-typing {
    background: #2d2d2d;
    border-color: #3a3a3a;
}

.cria-theme-dark .cria-typing-dot {
    background: #888;
}

/* Light Theme (default) */
.cria-theme-light .cria-box,
.cria-theme-light .cria-mode-inline .cria-box {
    background: #fff;
}

.cria-theme-light .cria-messages {
    background: #f8f9fa;
}

.cria-theme-light .cria-msg-bot {
    background: #fff;
    color: #212121;
    border: 1px solid #e8e8e8;
}

.cria-theme-light .cria-input-area {
    background: #fff;
}

.cria-theme-light .cria-typing {
    background: #fff;
    border: 1px solid #e8e8e8;
}

.cria-theme-light .cria-typing-dot {
    background: #999;
}

/* Auto Theme — inherits from Temas plugin CSS variables */
.cria-theme-auto .cria-box {
    background: var(--cr-surface, #fff);
}

.cria-theme-auto .cria-header {
    background: var(--cr-primary, #2e7d32);
}

.cria-theme-auto .cria-messages {
    background: var(--cr-surface-alt, #f8f9fa);
}

.cria-theme-auto .cria-msg-bot {
    background: var(--cr-surface, #fff);
    color: var(--cr-text, #212121);
    border: 1px solid var(--cr-border, #e0e0e0);
}

.cria-theme-auto .cria-msg-user {
    background: var(--cr-primary, #2e7d32);
}

.cria-theme-auto .cria-input {
    background: var(--cr-input-bg, #fff);
    color: var(--cr-text, #212121);
    border-color: var(--cr-input-border, #e0e0e0);
}

.cria-theme-auto .cria-input:focus {
    border-color: var(--cr-primary, #2e7d32);
}

.cria-theme-auto .cria-send {
    background: var(--cr-primary, #2e7d32);
}

.cria-theme-auto .cria-input-area {
    background: var(--cr-surface, #fff);
    border-color: var(--cr-border, #e0e0e0);
}

.cria-theme-auto .cria-toggle {
    background: var(--cr-primary, #2e7d32);
}

.cria-theme-auto .cria-typing {
    background: var(--cr-surface, #fff);
    border: 1px solid var(--cr-border, #e0e0e0);
}

.cria-theme-auto .cria-typing-dot {
    background: var(--cr-muted, #999);
}

.cria-theme-auto .cria-powered {
    color: var(--cr-muted, #999);
}
