/* Chatbot flotante */
.chatbot-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
}

.chat-window {
    position: absolute;
    bottom: 4rem;
    right: 0;
    width: 20rem;
    max-width: calc(100vw - 1rem);
    height: 28rem;
    max-height: calc(100vh - 8rem);
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    animation: scaleIn 0.2s ease-out;
}

.chat-window.hidden {
    display: none;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-header {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    padding: 1rem;
    border-radius: 0.75rem 0.75rem 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
    min-width: 2rem;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
}

.message.user .message-avatar {
    background: #9ca3af;
    color: white;
}

.message-content {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.bot .message-content {
    background: white;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
}

.message-text {
    font-size: 0.875rem;
    line-height: 1.5;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    opacity: 0.7;
}

.typing-indicator {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0 1rem;
}

.typing-indicator.hidden {
    display: none;
}

.typing-bubble {
    background: white;
    padding: 0.75rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dots .dot {
    width: 0.5rem;
    height: 0.5rem;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

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

.message-form {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    background: white;
    border-radius: 0 0 0.75rem 0.75rem;
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.message-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.message-input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

.send-btn {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    opacity: 0.9;
}

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

.chat-toggle {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.hidden {
    display: none;
}

/* Media queries para dispositivos móviles */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 0.5rem;
    }
    
    .chatbot-container {
        bottom: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
    }
    
    .chat-window {
        position: fixed;
        bottom: 4.5rem;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        max-width: none;
        height: 70vh;
        max-height: 70vh;
    }
    
    .chat-toggle {
        width: 3rem;
        height: 3rem;
        position: fixed;
        bottom: 0.5rem;
        right: 0.5rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 2rem;
    }
    
    .feature-card {
        padding: 1.25rem;
    }
    
    .message-content {
        max-width: 85%;
        padding: 0.5rem 0.75rem;
    }
    
    .message-form {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .message-input {
        padding: 0.6rem 0.75rem;
        font-size: 16px; /* Evita el zoom en iOS */
    }
    
    .send-btn {
        padding: 0.6rem;
        min-width: 2.25rem;
    }
    
    .chat-header {
        padding: 0.75rem 1rem;
    }
    
    .messages-container {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        bottom: 0.25rem;
        right: 0.25rem;
        left: 0.25rem;
    }
    
    .chat-window {
        bottom: 4rem;
        left: 0.25rem;
        right: 0.25rem;
        height: 75vh;
        max-height: 75vh;
        border-radius: 0.5rem;
    }
    
    .chat-header {
        border-radius: 0.5rem 0.5rem 0 0;
        padding: 0.75rem;
    }
    
    .chat-header h3 {
        font-size: 0.8rem;
    }
    
    .message-form {
        border-radius: 0 0 0.5rem 0.5rem;
        padding: 0.5rem;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .messages-container {
        padding: 0.5rem;
    }
    
    .chat-toggle {
        width: 2.75rem;
        height: 2.75rem;
        bottom: 0.25rem;
        right: 0.25rem;
    }
}

/* Mejoras para accesibilidad táctil */
@media (hover: none) and (pointer: coarse) {
    .close-btn,
    .send-btn,
    .chat-toggle {
        min-height: 44px;
        min-width: 44px;
    }
    
    .message-input {
        min-height: 44px;
    }
}