/* Estilos para el chat de IA */
.ai-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 580px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.ai-chat-header {
    padding: 18px 22px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-chat-header h5 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-header .btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}

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

.ai-chat-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-settings, .btn-history {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-settings:hover, .btn-history:hover {
    background-color: rgba(255,255,255,0.2);
}

.ai-chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    max-height: 420px;
    background: #ffffff;
    border-radius: 0 0 20px 20px;
}

.ai-message {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease-in;
}

.ai-message.ai-user {
    flex-direction: row-reverse;
}

.ai-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-message.ai-assistant .ai-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-message.ai-user .ai-avatar {
    background: #28a745;
    color: white;
}

.ai-content {
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 20px;
    max-width: 300px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
    line-height: 1.5;
    white-space: normal;
    word-wrap: break-word;
    font-size: 15px;
    color: #333333;
    border: 1px solid #e2e8f0;
}

.ai-content p {
    margin: 0 0 6px 0;
}

.ai-content ul, .ai-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.ai-content li {
    margin-bottom: 3px;
}

/* Mejorar espaciado de viñetas */
.ai-content br + • {
    margin-top: 8px;
    display: inline-block;
}

/* Estilos para la lista de servicios */
.service-list {
    margin: 8px 0;
}

.service-item {
    margin-bottom: 8px;
    padding-left: 8px;
    line-height: 1.4;
}

.service-item:last-child {
    margin-bottom: 0;
}

/* Estilo para la sección de tip */
.tip-section {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #4f46e5;
}

/* Mejorar el highlight del tip */
.tip-section .highlight {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    margin-right: 6px;
}

.ai-content strong {
    font-weight: 600;
    color: #000000;
}

.ai-content em {
    font-style: italic;
    color: #666666;
}

.ai-content .highlight {
    background: #fff3cd;
    color: #856404;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* Mejorar espaciado entre mensajes */
.ai-message {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease-in;
}

.ai-content strong {
    color: #333;
    font-weight: 600;
}

.ai-message.ai-user .ai-content strong {
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.ai-message.ai-user .ai-content {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    box-shadow: 0 3px 12px rgba(79, 70, 229, 0.3);
    font-weight: 500;
}

.ai-content ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.ai-content li {
    margin-bottom: 4px;
    font-size: 14px;
}

.ai-chat-input {
    padding: 22px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    background: #ffffff;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.ai-chat-input input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 15px;
    transition: all 0.3s;
    outline: none;
    background: #f8f9fa;
    color: #2d3748;
}

.ai-chat-input input:focus {
    border-color: #4f46e5;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.ai-chat-input button {
    padding: 14px 16px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.ai-chat-input button:hover {
    transform: scale(1.05);
}

.ai-chat-input button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Botón flotante para abrir el chat */
.ai-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(79, 70, 229, 0.4);
    z-index: 9998;
    transition: all 0.3s;
    font-size: 22px;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

/* Mensaje de carga */
.ai-message.loading {
    opacity: 0.7;
}

.loading-dots {
    display: inline-block;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0; }
}

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

/* Scrollbar personalizado */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Paneles de configuración e historial */
.ai-settings-panel, .ai-history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    max-height: 80vh;
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 10001;
    display: flex;
    flex-direction: column;
}

.ai-settings-header, .ai-history-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-settings-header h6, .ai-history-header h6 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-settings-content, .ai-history-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.setting-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
}

.setting-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
}

.btn-save-settings {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s;
}

.btn-save-settings:hover {
    transform: scale(1.02);
}

.loading-history {
    text-align: center;
    color: #666;
    padding: 20px;
}

.history-item {
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-item:hover {
    background-color: #f8f9fa;
}

.history-item .query {
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
}

.history-item .timestamp {
    font-size: 12px;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chat-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 10px;
        right: 20px;
        left: 20px;
    }

    .ai-chat-toggle {
        bottom: 10px;
        right: 20px;
    }

    .ai-settings-panel, .ai-history-panel {
        width: calc(100vw - 40px);
        max-height: 80vh;
    }
}
