/* ============================
   AI ASSISTANT CHATBOT
   ============================ */

/* Botón flotante */
.assistant-fab {
    position: fixed;
    bottom: 160px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    animation: assistant-pulse 3s ease-in-out infinite;
}

.assistant-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
}

.assistant-fab.active {
    animation: none;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

@keyframes assistant-pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(99, 102, 241, 0.7);
    }
}

/* Panel de chat */
.assistant-panel {
    position: fixed;
    bottom: 170px;
    right: 20px;
    width: 380px;
    max-height: 520px;
    background: rgba(22, 22, 40, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

.assistant-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header del panel */
.assistant-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

.assistant-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

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

.assistant-header-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.assistant-header-status {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
}

.assistant-header-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: all 0.2s;
}

.assistant-header-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Chat Messages */
.assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 320px;
    scroll-behavior: smooth;
}

.assistant-messages::-webkit-scrollbar {
    width: 4px;
}

.assistant-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Message Bubbles */
.assistant-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgFadeIn 0.3s ease;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.assistant-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.assistant-msg.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
}

/* Markdown en respuestas del bot */
.assistant-msg.bot strong {
    color: #a5b4fc;
}

.assistant-msg.bot code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
}

.assistant-msg.bot ul,
.assistant-msg.bot ol {
    padding-left: 18px;
    margin: 4px 0;
}

.assistant-msg.bot li {
    margin-bottom: 2px;
}

/* Typing Indicator */
.assistant-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.assistant-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Suggestions */
.assistant-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
}

.assistant-suggestion-btn {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.assistant-suggestion-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
}

/* Input Area */
.assistant-input-area {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.assistant-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 14px;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
    resize: none;
    max-height: 80px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.assistant-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.assistant-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
}

.assistant-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

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

/* Tool result indicator */
.assistant-tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #4ade80;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}

/* Welcome message */
.assistant-welcome {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    line-height: 1.6;
}

.assistant-welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    display: block;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .assistant-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .assistant-panel.open {
        transform: translateY(0);
    }

    .assistant-fab {
        bottom: 150px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
}

/* === MODO PÚBLICO (Carta Online) === */
.assistant-panel.assistant-public {
    background: rgba(26, 26, 46, 0.97);
}

.assistant-panel.assistant-public .assistant-header {
    background: linear-gradient(135deg, rgba(46, 117, 182, 0.2), rgba(74, 144, 194, 0.2));
}

.assistant-panel.assistant-public .assistant-avatar {
    background: linear-gradient(135deg, #2E75B6, #4A90C2);
}

.assistant-panel.assistant-public .assistant-msg.user {
    background: linear-gradient(135deg, #2E75B6, #4A90C2);
}

.assistant-panel.assistant-public .assistant-suggestion-btn {
    background: rgba(46, 117, 182, 0.15);
    border-color: rgba(46, 117, 182, 0.3);
    color: #7db8e0;
}

.assistant-panel.assistant-public .assistant-suggestion-btn:hover {
    background: rgba(46, 117, 182, 0.3);
}

.assistant-panel.assistant-public .assistant-send-btn {
    background: linear-gradient(135deg, #2E75B6, #4A90C2);
}

.assistant-fab.assistant-fab-public {
    background: linear-gradient(135deg, #fff, #f8f8ff);
    box-shadow: 0 4px 24px rgba(46, 117, 182, 0.35);
    bottom: 24px;
    right: 16px;
    width: 64px;
    height: 64px;
    overflow: hidden;
    padding: 0;
    border: 3px solid #E8B04A;
    animation: fab-glow-pulse 3s ease-in-out infinite;
}

.assistant-fab.assistant-fab-public:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 35px rgba(46, 117, 182, 0.5);
}

@keyframes fab-glow-pulse {

    0%,
    100% {
        box-shadow: 0 4px 24px rgba(46, 117, 182, 0.35), 0 0 0 0 rgba(232, 176, 74, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(46, 117, 182, 0.5), 0 0 0 10px rgba(232, 176, 74, 0);
    }
}

/* Robot waiter image */
.fab-robot-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    animation: fab-img-bounce 3s ease-in-out infinite;
}

@keyframes fab-img-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Speech bubble */
.fab-speech-bubble {
    position: fixed;
    bottom: 38px;
    right: 88px;
    background: #fff;
    color: #333;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: auto;
    cursor: pointer;
    animation: fab-bubble-show 8s ease-in-out infinite;
    border: 2px solid #E8B04A;
    z-index: 1000;
}

.fab-speech-bubble::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

@keyframes fab-bubble-show {

    0%,
    60%,
    100% {
        opacity: 0;
    }

    68%,
    92% {
        opacity: 1;
    }
}



.assistant-fab.assistant-fab-public.active .fab-speech-bubble {
    display: none;
}

.assistant-fab.assistant-fab-public.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: #dc2626;
    width: 56px;
    height: 56px;
    animation: none;
    font-size: 1.3rem;
    color: #fff;
}

.assistant-fab.assistant-fab-public.active .fab-robot-img {
    display: none;
}

@media (max-width: 480px) {
    .assistant-fab.assistant-fab-public {
        bottom: 16px;
        right: 12px;
        width: 58px;
        height: 58px;
    }

    .fab-speech-bubble {
        right: 64px;
        font-size: 0.75rem;
        padding: 8px 12px;
    }
}