/* Widget de Chat - Diseño Profesional e Institucional */
.aiwp-chat-widget-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.aiwp-chat-widget {
    width: 380px;
    max-width: calc(100vw - 40px);
    background-color: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: aiwp-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
}

/* Header mejorado con logo prominente */
.aiwp-chat-widget__header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #004aad 0%, #0066cc 50%, #0077ff 100%);
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

.aiwp-chat-widget__header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
    pointer-events: none;
}

.aiwp-chat-widget__logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.aiwp-chat-widget__logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.aiwp-chat-widget__title {
    flex: 1 1 auto;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.3;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Body con mejor espaciado */
.aiwp-chat-widget__body {
    display: flex;
    flex-direction: column;
    height: 500px;
    max-height: calc(85vh - 100px);
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
}

.aiwp-chat-widget__messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.aiwp-chat-widget__messages::-webkit-scrollbar {
    width: 6px;
}

.aiwp-chat-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.aiwp-chat-widget__messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.aiwp-chat-widget__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Mensajes con burbujas modernas */
.aiwp-chat-widget__message {
    max-width: 75%;
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: aiwp-message-fade-in 0.3s ease-out;
    position: relative;
}

.aiwp-chat-widget__message--user {
    margin-left: auto;
    background: linear-gradient(135deg, #004aad 0%, #0066cc 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 74, 173, 0.25);
}

.aiwp-chat-widget__message--assistant {
    margin-right: auto;
    background: #ffffff;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Input wrapper mejorado */
.aiwp-chat-widget__input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background-color: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

.aiwp-chat-widget__input {
    flex: 1;
    border: 2px solid #e0e4e8;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background-color: #f8f9fa;
    color: #1a1a1a;
}

.aiwp-chat-widget__input:focus {
    border-color: #004aad;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 74, 173, 0.1);
}

.aiwp-chat-widget__input::placeholder {
    color: #8b949e;
}

.aiwp-chat-widget__send {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #004aad 0%, #0066cc 100%);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 74, 173, 0.3);
}

.aiwp-chat-widget__send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 74, 173, 0.4);
}

.aiwp-chat-widget__send:active {
    transform: translateY(0);
}

.aiwp-chat-widget__send::before {
    content: '→';
    font-weight: bold;
}

/* Animaciones */
@keyframes aiwp-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes aiwp-message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estado de carga */
.aiwp-chat-widget__typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    margin-bottom: 12px;
    margin-right: auto;
    max-width: 60px;
    background: #ffffff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.aiwp-chat-widget__typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #8b949e;
    animation: aiwp-typing-bounce 1.4s infinite ease-in-out;
}

.aiwp-chat-widget__typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.aiwp-chat-widget__typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes aiwp-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .aiwp-chat-widget {
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
        bottom: 0;
        right: 0;
        max-height: 100vh;
    }

    .aiwp-chat-widget-root {
        left: 0;
        right: 0;
        bottom: 0;
        top: 0;
        display: flex;
        align-items: flex-end;
    }

    .aiwp-chat-widget__body {
        height: calc(100vh - 100px);
    }
}
