/* AioChat Widget Styles */

#aiochat-widget {
    position: fixed !important;
    bottom: 30px !important;
    z-index: 2147483647 !important;
    display: flex !important;
    flex-direction: column-reverse !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
}

#aiochat-widget > * {
    pointer-events: auto;
}

/* Posición configurable desde el admin */
#aiochat-widget.aiochat-right {
    right: 30px !important;
    left: auto !important;
    align-items: flex-end !important;
}

#aiochat-widget.aiochat-left {
    left: 30px !important;
    right: auto !important;
    align-items: flex-start !important;
}


/* Botón burbuja flotante */
#aiochat-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    margin-top: 12px;
}

#aiochat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.6);
}

#aiochat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    align-items: center;
    justify-content: center;
}

/* Caja del chat */
#aiochat-box {
    display: none;
    width: 360px;
    height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    flex-direction: column;
    overflow: hidden;
    animation: aiochat-appear 0.25s ease;
}

@keyframes aiochat-appear {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
#aiochat-header {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

#aiochat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#aiochat-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

#aiochat-title {
    font-weight: 700;
    font-size: 15px;
}

#aiochat-status-text {
    font-size: 11px;
    opacity: 0.85;
}

#aiochat-header-actions {
    display: flex;
    gap: 6px;
}

#aiochat-header-actions button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#aiochat-header-actions button:hover {
    background: rgba(255,255,255,0.3);
}

/* Área de mensajes */
#aiochat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.aiochat-msg {
    display: flex;
    max-width: 80%;
}

.aiochat-msg.aiochat-customer {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aiochat-msg.aiochat-bot,
.aiochat-msg.aiochat-agent {
    align-self: flex-start;
}

.aiochat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.aiochat-customer .aiochat-bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-bottom-right-radius: 4px;
}

.aiochat-bot .aiochat-bubble,
.aiochat-agent .aiochat-bubble {
    background: white;
    color: #1e293b;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.aiochat-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 2px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiochat-bounce 1.2s infinite;
}

.aiochat-typing span:nth-child(2) { animation-delay: 0.2s; }
.aiochat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiochat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Panel humano */
#aiochat-human-panel {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8fafc;
    gap: 12px;
}

#aiochat-human-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    text-align: center;
    margin-bottom: 8px;
}

#aiochat-human-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.aiochat-contact-btn {
    display: block;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    width: 100%;
}

.aiochat-contact-btn:hover {
    transform: scale(1.02);
    opacity: 0.92;
}

.aiochat-wa    { background: #25D366; color: white; }
.aiochat-phone { background: #0ea5e9; color: white; }
.aiochat-live  { background: #8b5cf6; color: white; }
.aiochat-email { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.aiochat-back-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: underline;
}

/* Panel email */
#aiochat-email-panel {
    flex: 1;
    flex-direction: column;
    padding: 16px;
    background: #f8fafc;
    gap: 10px;
    overflow-y: auto;
}

#aiochat-email-panel input,
#aiochat-email-panel textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    box-sizing: border-box;
    font-family: inherit;
}

#aiochat-email-panel textarea {
    resize: none;
}

.aiochat-send-email-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* Panel live */
#aiochat-live-panel {
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    gap: 10px;
}

#aiochat-live-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Input area */
#aiochat-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#aiochat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 14px;
    resize: none;
    max-height: 80px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

#aiochat-input:focus {
    border-color: #2563eb;
}

#aiochat-send-btn {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    flex-shrink: 0;
}

#aiochat-send-btn:hover {
    transform: scale(1.05);
}

/* Footer */
#aiochat-footer {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    padding: 6px 0 8px;
    background: white;
    border-top: 1px solid #f1f5f9;
}

#aiochat-footer a {
    color: #2563eb;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 480px) {
    #aiochat-box {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 0;
        left: 12px;
        position: fixed;
    }

    #aiochat-widget {
        bottom: 12px;
    }
    #aiochat-widget.aiochat-right {
        right: 12px !important;
        left: auto !important;
    }
    #aiochat-widget.aiochat-left {
        left: 12px !important;
        right: auto !important;
    }
}
