/**
 * Chatbot Styles for Pinos Austral
 * Responsive design for mobile and desktop
 */

/* Reset and base styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Loading screen - OPTIMIZADO PARA SER MENOS INTRUSIVO */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading-content p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main container - OPTIMIZADO PARA MEJOR USO DEL ESPACIO */
.chatbot-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Contenedor ultra-optimizado para modo embebido */
body.embedded-mode .chatbot-container {
    padding: 4px;
    min-height: calc(100vh - 8px);
}

/* BotUI Container - MÁS ESPACIO PARA CONVERSACIÓN */
.botui-app-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    margin-bottom: 15px;
    min-height: 450px;
    flex: 1;
}

/* Contenedor más compacto en modo embebido */
body.embedded-mode .botui-app-container {
    border-radius: 6px;
    margin-bottom: 0px;
    min-height: calc(100vh - 8px);
}

/* Header - OPTIMIZADO PARA SER COMPACTO */
.chatbot-header {
    text-align: center;
    margin-bottom: 15px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-height: 60px;
    max-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* Header ULTRA-COMPACTO para modo embebido */
.chatbot-header.embedded-mode {
    margin-bottom: 6px;
    padding: 6px 12px;
    min-height: 32px;
    max-height: 32px;
    border-radius: 6px;
}

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

.header-logo h2 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 700;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Texto más pequeño en modo embebido */
.chatbot-header.embedded-mode .header-logo h2 {
    font-size: 0.9em;
    gap: 3px;
}

.company-name {
    font-size: 0.6em;
    color: #7f8c8d;
    font-weight: 400;
    display: block;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Texto aún más pequeño en modo embebido */
.chatbot-header.embedded-mode .company-name {
    font-size: 0.45em;
    margin-top: 0px;
}

.chatbot-header p {
    display: none; /* Ocultar para ahorrar espacio */
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Status más compacto en modo embebido */
.chatbot-header.embedded-mode .header-status {
    gap: 3px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* Indicador más pequeño en modo embebido */
.chatbot-header.embedded-mode .status-indicator {
    width: 5px;
    height: 5px;
}

.status-indicator.online {
    background-color: #27ae60;
}

.status-text {
    font-size: 0.8em;
    color: #27ae60;
    font-weight: 500;
    white-space: nowrap;
}

/* Texto de status más pequeño en modo embebido */
.chatbot-header.embedded-mode .status-text {
    font-size: 0.65em;
}

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

/* BotUI Container - MÁS ESPACIO PARA CONVERSACIÓN */
.botui-app-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    margin-bottom: 15px;
    min-height: 450px;
    flex: 1;
}

/* BotUI Customizations - MENSAJES MÁS COMPACTOS */
.botui-messages-container {
    padding: 20px;
    max-height: 550px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 transparent;
}

/* Contenedor de mensajes ultra-compacto en modo embebido */
body.embedded-mode .botui-messages-container {
    padding: 12px;
    max-height: calc(100vh - 120px);
}

.botui-messages-container::-webkit-scrollbar {
    width: 6px;
}

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

.botui-messages-container::-webkit-scrollbar-thumb {
    background-color: #bdc3c7;
    border-radius: 3px;
}

.botui-message {
    margin-bottom: 20px;
    animation: slideIn 0.4s ease-out;
}

/* Mensajes más compactos en modo embebido */
body.embedded-mode .botui-message {
    margin-bottom: 12px;
}

@keyframes slideIn {
    from { 
        opacity: 0; 
        transform: translateY(20px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.botui-message-content {
    padding: 14px 18px;
    border-radius: 20px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 15px;
    position: relative;
}

.botui-message-content.human {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    text-align: right;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.botui-message-content.bot {
    background-color: #f8f9fa;
    color: #2c3e50;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Action buttons */
.botui-actions-container {
    padding: 20px 25px;
    border-top: 1px solid #e9ecef;
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(5px);
}

/* Contenedor de acciones más compacto en modo embebido */
body.embedded-mode .botui-actions-container {
    padding: 12px 15px;
}

.botui-actions-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.botui-actions-buttons-button {
    padding: 14px 24px;
    border: 2px solid transparent;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.botui-actions-buttons-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.botui-actions-buttons-button:hover::before {
    left: 100%;
}

.botui-actions-buttons-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.botui-actions-buttons-button:active {
    transform: translateY(0);
}

/* Text input */
.botui-actions-text {
    display: flex;
    gap: 12px;
    align-items: center;
}

.botui-actions-text-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

.botui-actions-text-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: white;
}

.botui-actions-text-submit {
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 80px;
}

.botui-actions-text-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Chat actions */
.chat-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Acciones más compactas en modo embebido */
body.embedded-mode .chat-actions {
    gap: 8px;
    margin-bottom: 10px;
}

.action-button {
    padding: 15px 30px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Botones más compactos en modo embebido */
body.embedded-mode .action-button {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 20px;
}

.live-chat-button {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.live-chat-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(39, 174, 96, 0.4);
}

.restart-button {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

.restart-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(243, 156, 18, 0.4);
}

.action-button:active {
    transform: translateY(-1px);
}

/* Footer */
.chatbot-footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

/* Footer más compacto en modo embebido */
body.embedded-mode .chatbot-footer {
    padding: 10px;
    font-size: 11px;
}

.chatbot-footer strong {
    color: white;
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px;
    color: #6c757d;
}

.loading-dots {
    display: inline-block;
    position: relative;
    width: 50px;
    height: 12px;
    margin-right: 15px;
}

.loading-dots div {
    position: absolute;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #667eea;
    animation: loading-dots 1.2s linear infinite;
}

.loading-dots div:nth-child(1) { left: 0; animation-delay: -0.24s; }
.loading-dots div:nth-child(2) { left: 20px; animation-delay: -0.12s; }
.loading-dots div:nth-child(3) { left: 40px; animation-delay: 0; }

@keyframes loading-dots {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Error messages */
.error-message {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

/* Success messages */
.success-message {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

/* Error fallback */
.error-fallback {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.error-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    margin: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.error-content h3 {
    color: #e74c3c;
    margin-bottom: 20px;
}

.error-content ul {
    text-align: left;
    margin: 20px 0;
}

.retry-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.retry-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Mobile responsiveness - OPTIMIZADO PARA DISPOSITIVOS MÓVILES */
@media (max-width: 768px) {
    .chatbot-container {
        padding: 10px;
    }
    
    .chatbot-header {
        padding: 10px 15px;
        margin-bottom: 10px;
        min-height: 50px;
        max-height: 50px;
    }
    
    .header-logo h2 {
        font-size: 1.1em;
    }
    
    .company-name {
        font-size: 0.55em;
    }
    
    .status-text {
        font-size: 0.75em;
    }
    
    .botui-message-content {
        max-width: 90%;
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .botui-actions-buttons-button {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .action-button {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    .chat-actions {
        gap: 10px;
    }
    
    .botui-messages-container {
        padding: 20px;
        max-height: 400px;
    }
    
    .botui-actions-container {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        padding: 10px;
    }
    
    .chatbot-header {
        padding: 15px;
    }
    
    .header-logo h2 {
        font-size: 1.3em;
    }
    
    .botui-messages-container {
        padding: 15px;
        max-height: 350px;
    }
    
    .botui-actions-container {
        padding: 12px 15px;
    }
    
    .chat-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .action-button {
        width: 100%;
        max-width: 280px;
    }
    
    .error-content {
        padding: 30px 20px;
        margin: 15px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .botui-message-content.bot {
        border: 2px solid #2c3e50;
    }
    
    .botui-actions-text-input {
        border: 2px solid #2c3e50;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
        border: 4px solid #667eea;
    }
}