/* Estilos del Chatbot ArkoData */
.arkodata-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    filter: drop-shadow(0 8px 32px rgba(0, 123, 255, 0.15));
}

/* Botón flotante */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 123, 255, 0.4), 0 0 0 0 rgba(0, 123, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(0, 123, 255, 0.5), 0 0 20px rgba(0, 123, 255, 0.3);
    animation: pulse 2s infinite;
}

.chatbot-toggle:active {
    transform: translateY(0);
}

.chatbot-icon {
    display: block;
    line-height: 1;
}

/* Notificación */
.chat-notification {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes slideUp {
    0% { 
        transform: translateY(20px) scale(0.9);
        opacity: 0;
    }
    100% { 
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes messageSlide {
    0% {
        transform: translateY(10px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Ventana del chat */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    resize: both;
    min-width: 280px;
    min-height: 300px;
    max-width: 90vw;
    max-height: 80vh;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header del chat */
.chat-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%, #004494 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.chat-title .title-text {
    font-size: 16px;
    font-weight: 600;
}

.chat-title .subtitle {
    font-size: 11px;
    opacity: 0.8;
    display: block;
}

.chat-minimize {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.chat-minimize:hover {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #007bff transparent;
}

.chat-message {
    margin-bottom: 16px;
    max-width: 80%;
    animation: messageSlide 0.3s ease-out;
}

.user-message {
    margin-left: auto;
    text-align: right;
}

.bot-message {
    margin-right: auto;
}

.message-content {
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    word-break: break-word;
    hyphens: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.user-message .message-content {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.bot-message .message-content {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    color: #333;
    border: 1px solid rgba(0, 123, 255, 0.1);
}

.message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
}

.user-message .message-time {
    text-align: right;
}

.bot-message .message-time {
    text-align: left;
}

/* Indicador de escritura */
.typing-indicator .message-content {
    padding: 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6c757d;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Input del chat */
.chat-input-container {
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(233, 236, 239, 0.3);
    position: relative;
    min-height: 60px;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid rgba(0, 123, 255, 0.1);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input:focus {
    border-color: #007bff;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1), 0 4px 12px rgba(0, 123, 255, 0.1);
    transform: translateY(-1px);
}

.chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.chat-send:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004494 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.4);
}

/* Sugerencias */
.chat-suggestions {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-btn {
    background: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 123, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.suggestion-btn:hover {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* Auto-responsive design */
@media (max-width: 1200px) {
    .chat-window {
        width: 320px;
        height: 480px;
    }
}

@media (max-width: 768px) {
    .arkodata-chatbot {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        max-width: 350px;
        height: calc(100vh - 150px);
        max-height: 500px;
        right: -5px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    
    .chat-messages {
        padding: 16px 12px;
    }
    
    .chat-input-container {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        right: -8px;
        bottom: 65px;
        border-radius: 8px;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-title .title-text {
        font-size: 14px;
    }
    
    .chat-title .subtitle {
        font-size: 10px;
    }
    
    .chat-messages {
        padding: 12px 10px;
    }
    
    .message-content {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .chat-input {
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .chat-send {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .suggestion-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .chatbot-toggle {
        width: 52px;
        height: 52px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-window {
        height: calc(100vh - 100px);
        max-height: 400px;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .chat-window {
        width: calc(100vw - 12px);
        right: -6px;
    }
    
    .chatbot-toggle {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

/* Auto-hide for very small viewports */
@media (max-height: 400px) {
    .chat-window {
        height: calc(100vh - 80px);
    }
}

/* Desktop improvements */
@media (min-width: 1024px) {
    .chat-window {
        width: 380px;
        height: 550px;
    }
    
    .chatbot-toggle:hover {
        transform: translateY(-3px) scale(1.05);
    }
}

/* Dynamic viewport adjustments */
.chat-window {
    --chat-height: min(500px, 80vh);
    --chat-width: min(350px, 90vw);
    height: var(--chat-height);
    width: var(--chat-width);
}

/* Smooth transitions for resize */
.chat-window,
.chatbot-toggle {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Auto-adjust message text size */
.message-content {
    line-height: 1.5;
    word-break: break-word;
    hyphens: auto;
}

/* Flexible input area */
.chat-input-container {
    min-height: 60px;
}

/* Better scroll behavior */
.chat-messages {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #007bff transparent;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}