/* Chatbot Styles - Matches website-armonia Glassmorphism */

/* Floating Action Button */
.chatbot-toggler {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(249, 115, 22, 0.72);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s, background 0.3s;
    z-index: 1000;
    box-shadow:
        0 4px 18px rgba(249, 115, 22, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.chatbot-toggler::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        rgba(255,255,255,0.28) 0%,
        rgba(255,255,255,0.06) 50%,
        transparent 100%
    );
    pointer-events: none;
}

.chatbot-toggler:hover {
    transform: scale(1.1);
    background: rgba(249, 115, 22, 0.88);
    box-shadow:
        0 8px 28px rgba(249, 115, 22, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chatbot-toggler::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid white;
    z-index: 1;
}

.chatbot-toggler span {
    position: absolute;
    color: var(--white);
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.chatbot-toggler span:last-child,
.show-chatbot .chatbot-toggler span:first-child {
    opacity: 0;
    transform: rotate(90deg);
}

.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
    transform: rotate(0);
}

/* Chatbot Window */
.chatbot {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 999;
    border-radius: var(--radius);
    
    /* Glass Effect */
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.show-chatbot .chatbot {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.chatbot header {
    background: rgba(249, 115, 22, 0.78);
    backdrop-filter: blur(24px) saturate(1.8);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow:
        0 2px 16px rgba(249, 115, 22, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    padding: 14px 18px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.22) 0%,
        rgba(255, 255, 255, 0.04) 45%,
        transparent 65%
    );
    pointer-events: none;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.chatbot-avatar-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    border: 1.5px solid var(--accent);
}

.chatbot-header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    display: block;
    border: 1.5px solid rgba(255,255,255,0.5);
}

.chatbot-name-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chatbot header h2 {
    color: var(--white);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-serif);
    line-height: 1;
}

.chatbot-role {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.03em;
    font-family: var(--font-sans);
    line-height: 1;
}

.chatbot header .close-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--white);
    cursor: pointer;
    display: none;
}

/* Chatbox */
.chatbot .chatbox {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.chatbox::-webkit-scrollbar {
    width: 6px;
}
.chatbox::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Messages */
.chatbox .chat {
    display: flex;
    list-style: none;
}

.chatbox .outgoing {
    justify-content: flex-end;
    margin: 15px 0;
}

.chatbox .incoming span {
    width: 32px;
    height: 32px;
    color: var(--white);
    background: var(--accent);
    text-align: center;
    line-height: 32px;
    border-radius: 10px;
    margin-right: 10px;
    font-size: 1.1rem;
    align-self: flex-end;
    flex-shrink: 0;
}


.chatbox .chat p, 
.chatbox .chat .error {
    white-space: pre-wrap;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    max-width: 80%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chatbox .outgoing p {
    background: var(--accent);
    color: var(--white);
    border-radius: 14px 14px 2px 14px;
}

.chatbox .incoming p {
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
    border-radius: 14px 14px 14px 2px;
    border: 1px solid var(--glass-border);
}

.chatbox .chat .error {
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
}

/* Input Area */
.chatbot .chat-input {
    display: flex;
    gap: 8px;
    padding: 15px 20px;
    border-top: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.4);
    align-items: flex-end;
}

.chatbot .chat-input textarea {
    height: 45px;
    flex: 1;
    border: 1px solid rgba(0,0,0,0.1);
    outline: none;
    resize: none;
    max-height: 180px;
    padding: 12px 15px;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink);
    font-family: var(--font-sans);
    transition: all 0.2s;
}

.chatbot .chat-input textarea:focus {
    background: var(--white);
    border-color: var(--accent);
}

.chatbot .chat-input span {
    flex-shrink: 0;
    width: 45px;
    height: 45px;
    color: var(--ink-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.2s;
    pointer-events: none;
    opacity: 0.4;
}

/* Botón send visible cuando hay texto */
.chatbot .chat-input.has-text span {
    pointer-events: auto;
    opacity: 1;
    color: var(--accent);
    background: rgba(249, 115, 22, 0.1);
}

.chatbot .chat-input.has-text span:hover {
    transform: scale(1.05);
    background: rgba(249, 115, 22, 0.15);
}

.chatbot .chat-input.has-text span:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 490px) {
    .chatbot {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .chatbot .chatbox {
        flex: 1;
        height: auto;
        overflow-y: auto;
    }
    .chatbot header .close-btn {
        display: block;
    }
    .show-chatbot .chatbot-toggler {
        display: none;
    }
}
