/* Contenedor principal del chat - estilo moderno tipo ChatGPT/Claude */
#subvenciones-chat-container {
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Header del chat */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
}

/* Área de mensajes */
#subvenciones-chat-output {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar personalizada */
#subvenciones-chat-output::-webkit-scrollbar {
    width: 6px;
}

#subvenciones-chat-output::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#subvenciones-chat-output::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#subvenciones-chat-output::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mensajes base */
.chat-message {
    display: flex;
    margin-bottom: 0;
    animation: fadeInUp 0.3s ease-out;
}

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

/* Avatar del mensaje */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* Contenido del mensaje */
.message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
    position: relative;
}

/* Estilos para texto formateado */
.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content .list-item {
    margin: 4px 0;
    padding-left: 8px;
    line-height: 1.4;
}

.message-content .numbered-item {
    margin: 4px 0;
    padding-left: 8px;
    line-height: 1.4;
    font-weight: 500;
}

.message-content .info-icon {
    font-size: 16px;
    margin-right: 6px;
    display: inline-block;
}

/* Estilos para enlaces en mensajes */
.message-content .chat-link {
    color: #3b82f6;
    text-decoration: none;
    border-radius: 6px;
    padding: 2px 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.message-content .chat-link:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
    text-decoration: none;
}

/* Enlaces del propio sitio */
.message-content .chat-link.own-site {
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.2);
}

.message-content .chat-link.own-site:hover {
    background: rgba(5, 150, 105, 0.2);
    border-color: rgba(5, 150, 105, 0.4);
}

/* Enlaces externos */
.message-content .chat-link.external {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.1);
    border-color: rgba(124, 58, 237, 0.2);
}

.message-content .chat-link.external:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.4);
}

/* Iconos de enlaces */
.message-content .link-icon {
    font-size: 14px;
    opacity: 0.8;
}

.message-content .external-icon {
    font-size: 12px;
    opacity: 0.7;
    font-weight: bold;
}

/* Mensajes del usuario */
.chat-message.user {
    justify-content: flex-end;
}

.chat-message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    order: 2;
    margin-right: 0;
    margin-left: 12px;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

/* Mensajes del asistente */
.chat-message.llm {
    justify-content: flex-start;
}

.chat-message.llm .message-avatar {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
}

.chat-message.llm .message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Indicador de escritura */
.chat-message.llm.loading .message-content {
    background: #f3f4f6;
    color: #6b7280;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mensajes de error */
.chat-message.llm.error .message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

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

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

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Área de input - estilo moderno */
.chat-input-container {
    padding: 20px 24px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 100%;
}

/* Campo de entrada */
#subvenciones-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 22px;
    font-size: 15px;
    font-family: inherit;
    background: #f9fafb;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    line-height: 1.4;
}

#subvenciones-chat-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#subvenciones-chat-input::placeholder {
    color: #9ca3af;
}

/* Botón de envío */
#subvenciones-chat-submit {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 16px;
}

#subvenciones-chat-submit:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#subvenciones-chat-submit:active {
    transform: scale(0.98);
}

#subvenciones-chat-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Icono del botón (usando texto por simplicidad) */
#subvenciones-chat-submit::before {
    content: "→";
    font-weight: bold;
}

/* Responsive design */
@media (max-width: 768px) {
    #subvenciones-chat-container {
        margin: 16px;
        border-radius: 8px;
    }
    
    .chat-header {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    #subvenciones-chat-output {
        padding: 16px;
        min-height: 300px;
        max-height: 400px;
    }
    
    .chat-input-container {
        padding: 16px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #subvenciones-chat-container {
        margin: 8px;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    #subvenciones-chat-output {
        flex: 1;
        min-height: auto;
        max-height: none;
    }
    
    .message-content {
        max-width: 90%;
    }
}
